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
// create data set on our data
3
var dataSet = anychart.data.set([
4
['Jan', 51],
5
['Feb', 91],
6
['Mar', 34],
7
['Apr', 47],
8
['May', 63],
9
['June', 58],
10
['July', 56],
11
['Aug', 77],
12
['Sep', 99],
13
['Oct', 106],
14
['Nov', 88],
15
['Dec', 56]
16
]);
17
18
// map data for the first series, take x from the zero column and value from the first column of data set
19
var seriesData = dataSet.mapAs({ x: 0, value: 1 });
20
21
// create line chart
22
var chart = anychart.line();
23
// turn on chart animation
24
chart.animation(true);
25
// turn on the crosshair
26
chart
27
.crosshair()
28
.enabled(true)
29
.yLabel({
30
enabled: false
31
})
32
.yStroke(null);
33
// set chart title text settings
34
chart.title('Step Line Chart (backward)');
35
36
// create stepLine series with mapped data
37
chart
38
.stepLine()
39
.data(seriesData)
40
.name('Value')
41
.stepDirection('backward');
42
43
// set container id for the chart
44
chart.container('container');
45
// initiate chart drawing
46
chart.draw();
47
});