diff --git a/package.json b/package.json index 2107bc2..05dcc21 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "git-cz": "^3.2.1", "jsdom": "^15.1.1", "kcd-scripts": "^1.5.2", + "plotly.js-dist": "^1.54.1", "semantic-release": "^15.13.18", "snyk": "^1.195.1" }, diff --git a/public/plot.html b/public/plot.html new file mode 100644 index 0000000..08db1ab --- /dev/null +++ b/public/plot.html @@ -0,0 +1,15 @@ + + + + + + + ac-learn charts + + + +
+ + + + \ No newline at end of file diff --git a/public/plot.js b/public/plot.js new file mode 100644 index 0000000..5add654 --- /dev/null +++ b/public/plot.js @@ -0,0 +1,37 @@ +/* eslint-disable no-console */ +const loadData = async () => { + try { + const data = await Promise.all([ + // fetch('../src/categories.json').then(res => res.json(), console.error), + // fetch('../src/labels.json').then(res => res.json(), console.error), + fetch('../playground/categoryPartitions.json').then( + res => res.json(), + console.error, + ), + ]) + + return data //[categories, dataset, categoryPartitions] + } catch (error) { + console.log('Error downloading one or more files:', error) + } +} + +const build = async () => { + const [/* categories, */ data] = await loadData() + console.log(data) + const q1Plot = { + x: Object.keys(data), + y: Object.values(data).map(ctr => ctr.overall), + type: 'bar', + } + + const vizData = [q1Plot] + const layout = { + title: 'Label Distribution', + } + + // eslint-disable-next-line no-undef + Plotly.newPlot('plot', vizData, layout, {scrollZoom: true}) +} + +build()