-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.html
160 lines (125 loc) · 4.02 KB
/
4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<html>
<style>
#chartdiv {
width: 100%;
height: 500px;
}
</style>
<!-- Resources -->
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<body>
<div id="chartdiv"></div>
</body>
<!-- Chart code -->
<script>
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.paddingRight = 20;
chart.data = generateChartData();
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.minPeriod="1mm";
dateAxis.baseInterval = {
"timeUnit": "minute",
"count": 20
};
dateAxis.dateFormatter.dateFormat = "HH:mm:ss";
dateAxis.tooltipDateFormat = "HH:mm, d MMMM";
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
let value1Axis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.tooltip.disabled = true;
valueAxis.title.text = "Unique visitors";
value1Axis.title.text = "Quantiry";
var series = chart.series.push(new am4charts.LineSeries());
//var series1 = this.chart.series.push(new am4charts.ColumnSeries());
// series1.dataFields.valueY = "quantity";
// series1.dataFields.categoryX = "date";
var series1 = this.chart.series.push(new am4charts.ColumnSeries());
series1.dataFields.valueY = "quantity";
series1.dataFields.dateX = "date";
series1.name = "Sales1";
series1.yAxis = value1Axis;
value1Axis.renderer.opposite = true;
series1.strokeWidth = 3;
series1.columns.template.fillOpacity = .8;
series.dataFields.dateX = "date";
series.dataFields.valueY = "visits";
series.yAxis = valueAxis;
series.tooltipText = "Visits: [bold]{valueY}[/]";
series.fillOpacity = 0.3;
series.name = "Sales";
chart.cursor = new am4charts.XYCursor();
chart.cursor.lineY.opacity = 0;
chart.scrollbarX = new am4charts.XYChartScrollbar();
chart.scrollbarX.series.push(series);
chart.events.on("datavalidated", function () {
dateAxis.zoom({start:0.8, end:1});
});
function generateChartData() {
var chartData = [];
// current date
var firstDate = new Date();
// now set 500 minutes back
firstDate.setMinutes(firstDate.getDate() - 500);
// and generate 500 data items
var visits = 500;
t=0;
// for (var i = 0; i < ; i++) {
// var newDate = new Date(firstDate);
// // each time we add one minute
// newDate.setHours(0, 0, t, i);
// // some random number
// visits += Math.round((Math.random()<0.5?1:-1)*Math.random()*10);
// // add data item to the array
// chartData.push({
// date: newDate,
// visits: visits
// });
// t++;
// if(t==59) {
// t=1;
// }
// }
chartData[0]={
date:new Date(2019,04,11,23,11,00,100),
visits:1400,
quantity:100
}
chartData[1]={
date:new Date(2019,04,11,23,11,01,100),
visits:1,
quantity:15
}
chartData[2]={
date:new Date(2019,04,11,23,11,01,200),
visits:110,
quantity:20
}
chartData[3]={
date:new Date(2019,04,11,23,11,01,300),
visits:50,
quantity:50
}
chartData[4]={
date:new Date(2019,04,11,23,11,02,400),
visits:2,
quantity:90
}
chartData[4]={
date:new Date(2019,04,11,23,11,03,500),
visits:200,
quantity:300
}
// chartData.push({
// date: newDate,
// visits: visits
// });
return chartData;
}
</script>
<!-- HTML -->
</html>