-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbarChart.js
54 lines (47 loc) · 1.04 KB
/
barChart.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import * as d3 from 'd3';
import bar from 'britecharts/dist/umd/bar.min.js';
import colors from 'britecharts/dist/umd/colors.min.js';
const data = [
{
"name": "Radiating",
"value": 0.08167
},
{
"name": "Opalescent",
"value": 0.0492
},
{
"name": "Shining",
"value": 0.02782
},
{
"name": "Vibrant",
"value": 0.04253
},
{
"name": "Vivid",
"value": 0.02702
},
{
"name": "Brilliant",
"value": 0.02288
}
];
let barContainer = d3.select('.js-container');
let containerWidth = barContainer.node() ? barContainer.node().getBoundingClientRect().width : false;
let barChart = new bar();
barChart
.margin({
left: 120,
right: 20,
top: 20,
bottom: 40
})
.isHorizontal(true)
.hasPercentage(true)
.percentageAxisToMaxRatio(1.3)
.width(containerWidth)
.colorSchema(colors.colorSchemas.britecharts)
.height(300);
barContainer.datum(data).call(barChart);
export default barChart;