-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcPlot.js
More file actions
31 lines (26 loc) · 793 Bytes
/
dcPlot.js
File metadata and controls
31 lines (26 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//create chart objects
bChart = dc.barChart("#dcPlot");
var chart = document.getElementById("dcPlot");
//load the data
const data = d3.csv("Pilot - BCRP_Summary_Results_AllSubjects_Edited.csv");
//create crossfilters
const crossdata = crossfilter(data);
const all = crossdata.groupAll();
const subjectsDimension = crossdata.dimension((d) => d.TotalSubjects);
const groupBySubjects = subjectsDimension
.group()
.reduceSum((d) => d.TotalSubjects / 100);
const ethnicityDimension = crossdata.dimension((d) => d.ethnicity);
//Define chart attributes
bChart
.width(800)
.height(500)
.group(groupBySubjects)
.x(d3.scaleLinear().domain([0, 10]))
.dimension(ethnicityDimension)
.centerBar(true)
.gap(2)
.yAxis()
.ticks(1000000);
bChart.turnOnControls(true);
dc.renderAll();