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
// set the gaps
21
var xScale = chart.xScale();
22
xScale.minimumGap(0.1);
23
xScale.maximumGap(0.1);
24
25
// This moves the plot itself, which is OK
26
// series.left(30);
27
// series.right(30);
28
29
// This doesn't work because it moves both first and last label
30
//chart.xAxis().labels().offsetX(-30);
31
// This doesn't work because it moves all the labels, even the ones in the middle
32
//chart.xAxis().labels().padding().left(50);
33
34
chart.xAxis().labels().format(function () {
35
return anychart.format.dateTime(this.value, anychart.format.outputDateFormat());
36
});
37
38
chart.yGrid().enabled(true);
39
chart.yGrid().stroke({dash: "3 5", color: 'lightgray'});
40
chart.xGrid().enabled(true);
41
chart.xGrid().stroke({dash: "3 5", color: 'lightgray'});
42
43
44
// draw
45
chart.container("container");
46
chart.draw();
47
});