HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var data = [
3
{ x: 'Parking Difficult', value: 95 },
4
{ x: 'Sales Rep was Rude', value: 60 },
5
{ x: 'Poor Lighting', value: 45 },
6
{ x: 'Layout Confusing', value: 37 },
7
{ x: 'Sizes Limited', value: 30 },
8
{ x: 'Clothing Faded', value: 27 },
9
{ x: 'Clothing Shrank', value: 18 }
10
];
11
12
// create pareto chart with data
13
var chart = anychart.pareto(data);
14
// set chart title text settings
15
chart.title('Pareto Chart of Customer Complaints');
16
// set measure y axis title
17
chart.yAxis(0).title('Defect frequency');
18
// cumulative percentage y axis title
19
chart.yAxis(1).title('Cumulative Percentage');
20
// set interval
21
chart.yAxis(1).scale().ticks().interval(10);
22
23
// get pareto column series and set settings
24
var column = chart.getSeriesAt(0);
25
column.fill(function () {
26
if (this.rf < 10) {
27
return '#E24B26';
28
}
29
return this.sourceColor;
30
});
31
column.stroke(function () {
32
if (this.rf < 10) {
33
return '#60727B';
34
}
35
return this.sourceColor;
36
});
37
column.labels().enabled(true).format('{%RF}%');
38
column.tooltip().format('Value: {%Value}');
39
40
// get pareto line series and set settings
41
var line = chart.getSeriesAt(1);
42
line
43
.tooltip()
44
.format('Cumulative Frequency: {%CF}% \n Relative Frequency: {%RF}%');
45
46
// create first horizontal line marker
47
chart
48
.lineMarker(0)
49
.axis(chart.yAxis(1))
50
.value(10)
51
.stroke('#A5B3B3', 1, '10 2', 'round'); // sets stroke
52
53
// create second horizontal line marker
54
chart
55
.lineMarker(1)
56
.axis(chart.yAxis(1))
57
.value(60)
58
.stroke('#A5B3B3', 1, '10 2', 'round'); // sets stroke
59
60
// turn on the crosshair and set settings
61
chart.crosshair().enabled(true).xLabel(false);
62
63
// set container id for the chart
64
chart.container('container');
65
// initiate chart drawing
66
chart.draw();
67
});