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.format.inputDateTimeFormat('yyyy-MM-dd');
2
3
anychart.onDocumentReady(function () {
4
5
var json = [
6
['2018-01-04', 1000],
7
['2018-01-05', 20000],
8
['2018-01-06', 30000]
9
];
10
11
var chart = anychart.area();
12
chart.credits().enabled(false);
13
14
var series = chart.area(json);
15
16
var dateTimeScale = anychart.scales.dateTime();
17
dateTimeScale.ticks().interval('day',1);
18
chart.xScale(dateTimeScale);
19
20
// This moves the plot itself, which is OK
21
// series.left(30);
22
// series.right(30);
23
24
// This doesn't work because it moves both first and last label
25
//chart.xAxis().labels().offsetX(-30);
26
// This doesn't work because it moves all the labels, even the ones in the middle
27
//chart.xAxis().labels().padding().left(50);
28
29
chart.xAxis().labels().format(function () {
30
return anychart.format.dateTime(this.value, anychart.format.outputDateFormat());
31
});
32
33
chart.yGrid().enabled(true);
34
chart.yGrid().stroke({dash: "3 5", color: 'lightgray'});
35
chart.xGrid().enabled(true);
36
chart.xGrid().stroke({dash: "3 5", color: 'lightgray'});
37
38
39
// draw
40
chart.container("container");
41
chart.draw();
42
});