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
// set data
3
var data = [
4
{x: 'Heart disease', value: 659041},
5
{x: 'Alzheimer disease', value: 150005},
6
{x: 'Cancer', value: 599601},
7
{x: 'Accidents', value: 173040},
8
{x: 'Kidney disease', value: 51567},
9
{x: 'Suicide', value: 47511},
10
{x: 'CLRD', value: 156979},
11
{x: 'Stroke', value: 121499},
12
{x: 'Diabetes', value: 87647},
13
{x: 'Influenza and pneumonia', value: 49783}
14
];
15
16
// create a pareto chart
17
var chart = anychart.pareto();
18
// feed the data into the chart
19
chart.data(data);
20
21
// set the chart title
22
chart.title('Number of Deaths for 10 Leading Causes of Death in U.S. in 2019');
23
// set the measure y-axis title
24
chart.yAxis(0).title('Number of deaths');
25
// set the cumulative percentage y-axis title
26
chart.yAxis(1).title('Cumulative percentage');
27
28
// use one of the pre-built palettes for coloring
29
chart.palette(anychart.palettes.earth);
30
31
// configure the visual settings of the first series
32
chart.getSeries(0).normal().fill('#c98411', 0.3);
33
chart.getSeries(0).hovered().fill('#c98411', 0.1);
34
chart.getSeries(0).selected().fill('#c98411', 0.5);
35
chart.getSeries(0).normal().hatchFill('forward-diagonal', '#c98411', 1, 15);
36
chart.getSeries(0).hovered().hatchFill('forward-diagonal', '#c98411', 1, 15);
37
chart.getSeries(0).selected().hatchFill('forward-diagonal', '#c98411', 1, 15);
38
chart.getSeries(0).normal().stroke('#c98411');
39
chart.getSeries(0).hovered().stroke('#c98411', 2);
40
chart.getSeries(0).selected().stroke('#c98411', 4);
41
42
// configure the visual settings of the second series
43
chart.getSeries(1).normal().stroke('#991e00', 4, '4 4', 'round');
44
45
// configure the pareto column series tooltip format
46
var column = chart.getSeriesAt(0);
47
column.tooltip().format('Value: {%Value}');
48
49
// configure the pareto line series tooltip format
50
var line = chart.getSeriesAt(1);
51
line
52
.tooltip()
53
.format('Cumulative Frequency: {%CF}% \n Relative Frequency: {%RF}%');
54
55
// set the pareto line series labels
56
line.labels().enabled(true).anchor('right-bottom').format('{%CF}%');
57
58
// set the chart container id
59
chart.container('container');
60
// draw the chart
61
chart.draw();
62
63
});