-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathechart3.html
138 lines (134 loc) · 4.2 KB
/
echart3.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
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<head>
<!-- Include the ECharts file you just downloaded -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.1.2/papaparse.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;500;600&display=swap" rel="stylesheet">
<style>
.chart {
height: 600px;
width: 100%;
}
</style>
</head>
<body>
<div class="chart" id="echarts-3"></div>
<script src="shared.js"></script>
<script>
function drawEChart3(data, title, headers) {
const dateList = data?.Date;
const myChart = echarts.init(document.getElementById("echarts-3"));
const series = [];
headers?.forEach((h) => {
const _data = data?.[h];
series.push({
data: parseNumbers(_data),
type: "line",
name: h,
smooth: false,
smoothMonotone: "x",
symbol: "none",
lineStyle: {
type: h === "Current Allocated" ? "solid" : "dotted",
width: 2.5,
},
emphasis: {
focus: "series",
},
});
});
const _color = ["#009E96", "#062587", "#AF69C5"];
const _media = JSON.parse(JSON.stringify(media));
_media[0].option.grid.bottom = '80';
const option = {
title: {
text: title,
...titleStyle,
},
color: _color,
textStyle,
xAxis: {
type: "category",
data: dateList,
axisTick: {
alignWithLabel: true,
},
},
tooltip: {
trigger: "axis",
confine: true
},
legend: {
...legendStyle,
data: [
{
name: "Current Allocated",
},
{
name: "Projected Allocated",
icon: "path://M335 1316 c-63 -28 -125 -122 -125 -191 0 -71 62 -164 127 -192 18 -7 58 -13 90 -13 72 0 125 28 168 88 27 39 30 52 30 117 0 65 -3 78 -30 117 -43 61 -95 88 -170 87 -33 0 -73 -6 -90 -13z, M1035 1313 c-76 -40 -115 -103 -115 -188 0 -121 85 -205 205 -205 121 0 205 84 205 205 0 84 -39 148 -112 186 -46 24 -140 25 -183 2z, M1714 1298 c-61 -42 -94 -102 -94 -173 0 -71 33 -131 94 -172 41 -28 57 -33 107 -33 76 0 115 16 161 68 76 84 76 190 0 274 -46 52 -85 68 -161 68 -50 0 -66 -5 -107 -32z",
},
{
name: "Total Authorized",
icon: "path://M335 1316 c-63 -28 -125 -122 -125 -191 0 -71 62 -164 127 -192 18 -7 58 -13 90 -13 72 0 125 28 168 88 27 39 30 52 30 117 0 65 -3 78 -30 117 -43 61 -95 88 -170 87 -33 0 -73 -6 -90 -13z, M1035 1313 c-76 -40 -115 -103 -115 -188 0 -121 85 -205 205 -205 121 0 205 84 205 205 0 84 -39 148 -112 186 -46 24 -140 25 -183 2z, M1714 1298 c-61 -42 -94 -102 -94 -173 0 -71 33 -131 94 -172 41 -28 57 -33 107 -33 76 0 115 16 161 68 76 84 76 190 0 274 -46 52 -85 68 -161 68 -50 0 -66 -5 -107 -32z",
},
],
},
calculable: true,
grid: {
show: true,
top: "70",
bottom: "60",
},
yAxis: {
type: "value",
name: "$STORE Tokens Issued",
nameLocation: "middle",
nameGap: "80",
nameTextStyle: {
color: "#333",
},
nameTextStyle: {
fontSize: 14,
},
axisLabel,
},
series: series,
media: _media
};
myChart.setOption(option);
resizeChart(myChart);
}
// drawEChart3
$.get(googleSheetUrl + "1834631508&single=true&output=csv", function (csvStr) {
// parse data using Papa Parse
let data = Papa.parse(csvStr, {
skipEmptyLines: true,
header: false,
})?.data;
const title = data?.[0]?.[0];
let headers = data?.[1];
data = data?.slice(2);
const array_data = [];
// prepapre data
headers?.forEach((h) => {
const index = headers?.findIndex((header) => header === h);
const _d = [];
data?.forEach((d) => {
_d.push(d[index]);
});
array_data[h] = _d;
});
headers = headers?.slice(1);
// draw data
drawEChart3(array_data, title, headers);
});
</script>
</body>
</html>