HTMLcopy
1
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-pareto.min.js"></script>
3
<div id="container1"></div>
CSScopy
6
1
html, body, #container1 {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// set data
4
var data = [
5
{x: 'Heart disease', value: 659041},
6
{x: 'Alzheimer disease', value: 150005},
7
{x: 'Cancer', value: 599601},
8
{x: 'Accidents', value: 173040},
9
{x: 'Kidney disease', value: 51567},
10
{x: 'Suicide', value: 47511},
11
{x: 'CLRD', value: 156979},
12
{x: 'Stroke', value: 121499},
13
{x: 'Diabetes', value: 87647},
14
{x: 'Influenza and pneumonia', value: 49783}
15
];
16
17
// create a pareto chart
18
var chart = anychart.pareto();
19
// feed the data into the chart
20
chart.data(data);
21
22
// set the chart title
23
chart.title('Number of Deaths for 10 Leading Causes of Death in U.S. in 2019');
24
// set the measure y axis title
25
chart.yAxis(0).title('Number of deaths');
26
// set the cumulative percentage y axis title
27
chart.yAxis(1).title('Cumulative percentage');
28
29
// use one of the pre-built palettes for coloring
30
chart.palette(anychart.palettes.earth);
31
32
// configure the visual settings of the first series
33
chart.getSeries(0).normal().fill("#c98411", 0.3);
34
chart.getSeries(0).hovered().fill("#c98411", 0.1);
35
chart.getSeries(0).selected().fill("#c98411", 0.5);
36
chart.getSeries(0).normal().hatchFill("forward-diagonal", "#c98411", 1, 15);
37
chart.getSeries(0).hovered().hatchFill("forward-diagonal", "#c98411", 1, 15);
38
chart.getSeries(0).selected().hatchFill("forward-diagonal", "#c98411", 1, 15);
39
chart.getSeries(0).normal().stroke("#c98411");
40
chart.getSeries(0).hovered().stroke("#c98411", 2);
41
chart.getSeries(0).selected().stroke("#c98411", 4);
42
43
// configure the visual settings of the second series
44
chart.getSeries(1).normal().stroke("#991e00", 4, "4 4", "round");
45
46
// set the chart container id
47
chart.container('container1');
48
// draw the chart
49
chart.draw();
50
51
});