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
// create column chart
3
var chart = anychart.column();
4
5
var data = [
6
['Eyeshadows', 16252],
7
['Eyeliner', 8525],
8
['Eyebrow pencil', 1451],
9
['Nail polish', 10169],
10
['Lipstick', 15198],
11
['Lip gloss', 17489]
12
];
13
14
15
// create first series with mapped data
16
var series = chart.column(data);
17
18
// set rendering settings
19
series.rendering()
20
// set point function to drawing
21
.point(drawer)
22
.updatePoint(drawer);
23
24
// set container id for the chart and initiate chart drawing
25
chart.container('container').draw();
26
});
27
28
function drawer() {
29
// if missing (not correct data), then skipping this point drawing
30
if (this.missing) {
31
return;
32
}
33
34
// get shapes group
35
var shapes = this.shapes || this.getShapesGroup(this.pointState);
36
// calculate the left value of the x-axis
37
var leftX = this.x - this.pointWidth / 2;
38
// calculate the right value of the x-axis
39
var rightX = leftX + this.pointWidth;
40
// calculate the half of point width
41
var rx = this.pointWidth / 2;
42
43
shapes['path']
44
// resets all 'path' operations
45
.clear()
46
// draw cone
47
.moveTo(leftX, this.zero)
48
.lineTo(leftX + rx, this.value)
49
.lineTo(rightX, this.zero)
50
// set fill settings, gradient
51
.fill(["0 " + anychart.color.darken(shapes['path'].fill().color, 0.35),
52
"0.40 " + anychart.color.darken(shapes['path'].fill().color, 0.35),
53
"0.85 " + anychart.color.lighten(shapes['path'].fill().color, 0.35),
54
"1 " + anychart.color.lighten(shapes['path'].fill().color, 0.35)])
55
// set stroke settings
56
.stroke('1.5 ' + anychart.color.darken(shapes['path'].fill().color, 0.5))
57
// close by connecting the last point with the first straight line
58
.close();
59
}