Skip to content

Commit

Permalink
feat: validation set + chart + data (#16)
Browse files Browse the repository at this point in the history
* fix(security): fixed some vulnerabilities

Fixed a few vulnerabilities, bumped dependencies and added some security measures

* feat: add validation sets

* refactor(index): use validationSet

* chore(package): change/add dependencies

* refactor(index): updated test cases

* chore(public): added an HTML chart

* chore(labels): added 40 new instances

* build(circleci): bump node to v10

* fix(index): minor tweak
  • Loading branch information
Berkmann18 authored Jul 20, 2019
1 parent 2b08af1 commit ad113b1
Show file tree
Hide file tree
Showing 11 changed files with 1,097 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

docker_defaults: &docker_defaults
docker:
- image: circleci/node:8.14.0
- image: circleci/node:10

commands:
prep_env:
Expand Down
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
_*.js
dist
dist
public/*.min.js
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"scripts": {
"build": "kcd-scripts build",
"lint": "kcd-scripts lint",
"test": "snyk test && kcd-scripts test",
"test": "kcd-scripts test",
"validate": "kcd-scripts validate",
"commit": "git-cz",
"doc:lint": "documentation lint src/index.js",
Expand Down Expand Up @@ -49,17 +49,19 @@
"javascript-lemmatizer": "0.0.2",
"limdu": "^0.9.4",
"serialization": "^0.2.0",
"train-test-split": "^1.0.0"
"tvt-split": "^1.0.2"
},
"devDependencies": {
"anychart-nodejs": "^1.3.8",
"codecov": "^3.5.0",
"cz-conventional-changelog": "^2.1.0",
"cz-conventional-changelog": "^3.0.1",
"documentation": "^12.0.1",
"eslint-config-kentcdodds": "^14.3.4",
"git-cz": "^3.2.1",
"jsdom": "^15.1.1",
"kcd-scripts": "^1.5.2",
"semantic-release": "^15.13.18",
"snyk": "^1.193.1"
"snyk": "^1.195.1"
},
"eslintIgnore": [
"node_modules",
Expand Down
16 changes: 16 additions & 0 deletions public/chart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!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>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js" type="text/javascript"></script>
<!-- https://raw.githubusercontent.com/anomal/RainbowVis-JS/master/rainbowvis.js -->
<!-- <script src="rainbowvis.min.js" type="text/javascript"></script> -->
<script src="chart.js"></script>
</body>
</html>
184 changes: 184 additions & 0 deletions public/chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/* eslint-disable no-console */
/* global Chart */
const ctx = document.getElementById('labels').getContext('2d')

// 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),
// ]);

// return data //[categories, dataset]
// } catch (error) {
// console.log('Error downloading one or more files:', error);
// }
// }

// const rainbow = new Rainbow();

// const init = async () => {
// const [CATEGORIES, DATASET] = await loadData();
// rainbow.setNumberRange(1, CATEGORIES.length);
// rainbow.setSpectrum('red', 'blue'); //purple

// const colours = CATEGORIES.map((_, i) => `#${rainbow.colourAt(i)}`);

// /**
// * Organise a dataset for ChartJS.
// * @param {[...{label: string, category: string}]} data Dataset
// * @param {string} caption Caption of the chart
// * @returns {Object} Data for ChartJS
// */
// const organize = (data, caption = 'Data') => {
// const res = {
// labels: CATEGORIES,
// datasets: {
// label: caption,
// data: new Array(CATEGORIES.length).fill(0),
// backgroundColor: colours
// }
// }

// data.forEach(instance => {
// const idx = CATEGORIES.indexOf(instance.category);
// res.datasets.data[idx]++;
// });
// // console.log('dataset=', res.dataset.backgroundColor);
// return res;
// };

// const data = organize(DATASET);
// console.log('data=', data);

// const chart = new Chart(ctx, {
// type: 'bar',
// data,
// options: {
// scales: {
// yAxes: [{
// ticks: {
// beginAtZero: true
// }
// }]
// }
// }
// });
// console.log(chart);
// }

const myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [
'blog',
'bug',
'business',
'code',
'content',
'design',
'doc',
'eventOrganizing',
'example',
'financial',
'fundingFinding',
'ideas',
'infra',
'maintenance',
'null',
'platform',
'plugin',
'projectManagement',
'question',
'review',
'security',
'talk',
'test',
'tool',
'translation',
'tutorial',
'userTesting',
'video',
],
datasets: [
{
label: 'Categories',
data: [
1,
17,
2,
47,
0,
8,
17,
0,
1,
1,
0,
23,
5,
26,
197,
11,
4,
1,
5,
1,
6,
0,
8,
13,
1,
0,
0,
0,
],
backgroundColor: [
'#ff0000',
'#ff0000',
'#f60009',
'#ec0013',
'#e3001c',
'#d90026',
'#d0002f',
'#c60039',
'#bd0042',
'#b3004c',
'#aa0055',
'#a1005e',
'#970068',
'#8e0071',
'#84007b',
'#7b0084',
'#71008e',
'#680097',
'#5e00a1',
'#5500aa',
'#4c00b3',
'#4200bd',
'#3900c6',
'#2f00d0',
'#2600d9',
'#1c00e3',
'#1300ec',
'#0900f6',
],
},
],
},
options: {
scales: {
yAxes: [
{
ticks: {
beginAtZero: true,
},
},
],
},
},
})

console.log(myChart)

// init();
Loading

0 comments on commit ad113b1

Please sign in to comment.