Skip to content

Commit

Permalink
feat(public): using plotly
Browse files Browse the repository at this point in the history
To answer EDA questions at
#20 (comment)
  • Loading branch information
Berkmann18 committed Aug 17, 2020
1 parent 35489f5 commit 8b88ce3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
15 changes: 15 additions & 0 deletions public/plot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ac-learn charts</title>
</head>
<body>
<!-- <canvas id="labels" width="400" height="400"></canvas> -->
<div id="plot"></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js" charset="utf-8"></script>
<script src="plot.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions public/plot.js
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8b88ce3

Please sign in to comment.