forked from CodeYellowBV/chartist-plugin-legend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
120 lines (112 loc) · 3.28 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Legend examples</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.9.8/chartist.min.css">
<style>
.ct-chart {
position: relative;
}
.ct-legend {
position: relative;
z-index: 10;
list-style: none;
}
.ct-legend li {
position: relative;
padding-left: 23px;
margin-bottom: 3px;
cursor: pointer;
}
.ct-legend li:before {
width: 12px;
height: 12px;
position: absolute;
left: 0;
content: '';
border: 3px solid transparent;
border-radius: 2px;
}
.ct-legend li.inactive:before {
background: transparent;
}
.ct-legend.ct-legend-inside {
position: absolute;
top: 0;
right: 0;
}
.ct-legend .ct-series-0:before {
background-color: #d70206;
border-color: #d70206;
}
.ct-legend .ct-series-1:before {
background-color: #f05b4f;
border-color: #f05b4f;
}
.ct-legend .ct-series-2:before {
background-color: #f4c63d;
border-color: #f4c63d;
}
.ct-legend .ct-series-3:before {
background-color: #d17905;
border-color: #d17905;
}
.ct-legend .ct-series-4:before {
background-color: #453d3f;
border-color: #453d3f;
}
</style>
</head>
<body>
<div style="max-width: 700px; margin: 0 auto;">
<div class="ct-chart ct-chart-line"></div>
<div class="ct-chart ct-chart-pie"></div>
<div class="ct-chart ct-chart-bar"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.9.8/chartist.min.js"></script>
<script src="chartist-plugin-legend.js"></script>
<script>
new Chartist.Line('.ct-chart-line', {
labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
series: [
[12, 9, 7, 8, 5],
[2, 1, 3.5, 7, 3],
[1, 3, 4, 5, 6]
]
}, {
fullWidth: true,
chartPadding: {
right: 40
},
plugins: [
Chartist.plugins.legend({
legendNames: ['Blue pill', 'Red pill', 'Purple pill'],
})
]
});
new Chartist.Pie('.ct-chart-pie', {
labels: ['Piece A', 'Piece B', 'Piece C', 'Piece D'],
series: [20, 10, 30, 40]
}, {
showLabel: false,
plugins: [
Chartist.plugins.legend()
]
});
new Chartist.Bar('.ct-chart-bar', {
labels: ['First quarter of the year', 'Second quarter of the year', 'Third quarter of the year', 'Fourth quarter of the year'],
series: [
{"name": "Money A", "data": [60000, 40000, 80000, 70000]},
{"name": "Money B", "data": [40000, 30000, 70000, 65000]},
{"name": "Money C", "data": [8000, 3000, 10000, 6000]}
]
}, {
plugins: [
Chartist.plugins.legend()
]
});
</script>
</body>
</html>