Files
leporello-js/docs/examples/plot/index.js

51 lines
656 B
JavaScript
Raw Normal View History

2023-07-17 05:21:05 +03:00
import _ from 'https://unpkg.com/lodash-es'
const url = 'https://api.github.com/search/repositories?q=stars:%3E1&sort=stars'
const resp = await fetch(url)
const repos = await resp.json()
const langs = _(repos.items)
.map(r => r.language)
.filter(l => l != null)
.countBy()
.toPairs()
.map(([language, count]) => ({language, count}))
2023-07-17 05:27:25 +03:00
.value()
2023-07-17 05:21:05 +03:00
import {barY} from "https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6/+esm";
2023-10-02 03:36:13 +03:00
/*
Move the cursor to the following line and see the plot displayed alongside the code
*/
2023-07-17 05:21:05 +03:00
barY(langs, {x: "language", y: "count", sort: {x: "y", reverse: true}, fill: 'purple'})
.plot()
2023-07-17 05:27:25 +03:00