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: 'Food is tasteless', value: 65 },
4
{ x: 'Wait time', value: 109 },
5
{ x: 'Unfriendly staff', value: 12.5 },
6
{ x: 'Not clean', value: 45 },
7
{ x: 'Overpriced', value: 250 },
8
{ x: 'To noisy', value: 27 },
9
{ x: 'Food not fresh', value: 35 },
10
{ x: 'Small portions', value: 170 },
11
{ x: 'Not atmosphere', value: 35 },
12
{ x: 'Food is to salty', value: 35 }
13
];
14
15
// create pareto chart with data
16
var chart = anychart.pareto(data);
17
// set chart title text settings
18
chart.title('Pareto Chart of Restaurant Complaints');
19
// set measure y axis title
20
chart.yAxis(0).title('Defect frequency');
21
// cumulative percentage y axis title
22
chart.yAxis(1).title('Cumulative Percentage');
23
// turn on chart animation
24
chart.animation(true);
25
26
// create horizontal line marker
27
chart
28
.lineMarker()
29
.value(80)
30
.axis(chart.yAxis(1))
31
.stroke('#A5B3B3', 1, '5 2', 'round'); // sets stroke
32
33
// get pareto column series and set settings
34
var column = chart.getSeriesAt(0);
35
column.tooltip().format('Value: {%Value}');
36
37
// get pareto line series and set settings
38
var line = chart.getSeriesAt(1);
39
line.seriesType('spline').markers(true);
40
line.yScale().ticks().interval(10);
41
line.labels().enabled(true).anchor('right-bottom').format('{%CF}%');
42
line
43
.tooltip()
44
.format('Cumulative Frequency: {%CF}% \n Relative Frequency: {%RF}%');
45
46
// turn on the crosshair and set settings
47
chart.crosshair().enabled(true).xLabel(false);
48
49
// set container id for the chart
50
chart.container('container');
51
// initiate chart drawing
52
chart.draw();
53
});