GitHub Stars¶
1 · Static page
The stars history of any public GitHub repository. A script fetches the data from an API, gives it to a <source-table>, and the components query it in the browser.
The script sets
source_table.datato the records it fetched, then callssource_table.load(true): every component of the table is refreshed.
See the code
# GitHub Stars
Show the Stars History of any public GitHub repository.
<div>
<input id="repo_input"></input>
<button id="submit_button">Get Stars</button>
</div>
<source-table name="stars_history"></source-table>
<score-card
table="stars_history"
title="Nb Stars"
measure="max(nb_stars)">
</score-card>
<line-chart
table="stars_history"
by="date"
measure="nb_stars"
sort-by="date">
</line-chart>
<script>
const source_table = document.querySelector("source-table");
const repo_input = document.getElementById("repo_input");
const load_data = async () => {
const repo = repo_input.value;
const response = await fetch(`https://unytics.io/github_star_history/?repo=${repo}`)
source_table.data = await response.json();
await source_table.load(true);
}
const submit_button = document.getElementById("submit_button");
submit_button.onclick = load_data;
</script>
<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>