HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create a funnel chart
4
var chart = anychart.funnel([
5
{x: "Qualified", value: 45},
6
{x: "Proposal", value: 32},
7
{x: "Negotiation", value: 11},
8
{x: "Review", value: 15},
9
{x: "Signed", value: 20},
10
{x: "Payed", value: 22}
11
]);
12
13
// go through all points of the end to the beginning
14
for (var i = chart.getStat("count") - 1;i > 0; i--){
15
// get the point and the point before it
16
currentPoint = chart.getPoint(i);
17
previousPoint = chart.getPoint(i - 1);
18
19
// calculate the difference of values
20
diff = currentPoint.get("value") - previousPoint.get("value");
21
22
// and put it into the data
23
currentPoint.set("diff", diff);
24
25
// color the columns depending on the difference
26
if (diff > 0) {
27
currentPoint.set("fill", "#31C45D");
28
currentPoint.set("stroke", {color: anychart.color.darken("#31C45D", 0.05)});
29
} else
30
{
31
currentPoint.set("fill", "#F39232");
32
currentPoint.set("stroke", {color: anychart.color.darken("#F39232", 0.05)});
33
}
34
}
35
36
// display the diff in tooltip
37
// the diff wasn't in the original dataset, but we've added it
38
var tooltip = chart.tooltip();
39
tooltip.format("Change: {%diff}");
40
41
chart.neckHeight(0);
42
43
chart.title("Points Customization");
44
chart.container("container");
45
chart.draw();
46
});