Repository navigation
Expand file tree
/
Copy pathshowLineChart.js
More file actions
118 lines (115 loc) · 2.15 KB
/
Copy pathshowLineChart.js
File metadata and controls
118 lines (115 loc) · 2.15 KB
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
import ApexCharts from "https://code4fukui.github.io/apexcharts.js/ApexCharts.js";
//import { annotations } from "./annotations.js";
import { DateTime } from "https://js.sabae.cc/DateTime.js";
/*
cosnt series = [
{
data: [
[time, value],
...
],
name: "name",
}
];
*/
export const showLineChart = (divlinechart, opt) => {
const title = opt.title;
const series = opt.series;
const height = opt.height || 350;
const annotations = opt.annotations;
const yaxis = opt.yaxis;
const formatter = opt.formatter;
const options = {
series,
annotations,
yaxis,
chart: {
height,
type: "line",
toolbar: {
show: true
},
animations: {
enabled: false,
},
},
//colors: ['#77B6EA', '#545454'],
/*
dataLabels: {
enabled: true,
},
*/
stroke: {
width: 2,
curve: "straight",
},
title: {
text: title || "",
align: "center",
},
/*
grid: {
borderColor: '#e7e7e7',
row: {
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
opacity: 0.5
},
},
*/
/*
markers: {
size: 1
},
*/
/*
xaxis: {
categories: months.map(i => Math.floor(i / 100) + "/" + i % 100),
title: {
text: 'Month'
}
},
*/
xaxis: {
type: 'datetime',
labels: {
datetimeUTC: false,
datetimeFormatter: {
year: 'yyyy',
month: 'yyyy/M',
day: 'M/d',
hour: 'HH:mm',
}
}
},
/*
yaxis: {
title: {
text: 'Temperature'
},
min: 5,
max: 40
},
*/
legend: {
position: "top",
horizontalAlign: "center",
showForSingleSeries: true,
//offsetY: -25,
//offsetX: -5
},
tooltip: {
x: {
formatter: val => {
//return new DateTime(val).toString();
return new DateTime(val).day.toString();
},
},
y: {
formatter,
}
},
};
const chart = new ApexCharts(divlinechart, options);
chart.render();
return chart;
};