-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
77 lines (71 loc) · 2.23 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SVG Chart Display</title>
<style>
body {
background-color: black;
color: white;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="path/to/canvas2svg.js"></script> <!-- Make sure to include canvas2svg.js -->
</head>
<body>
<div style="position: relative; height:60vh; width:90vh">
<canvas id="myChart"></canvas>
</div>
<script>
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['入门', '普及-', '普及/提升-', '普及+/提高', '提高+/省选-', '省选/NOI-', 'NOI/NOI+/CTSC'],
datasets: [{
label: 'Colors',
data: [50, 27, 5, 1, 0, 0, 1],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(255, 159, 64, 0.2)',
'rgba(255, 205, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(201, 203, 207, 0.2)'
],
borderColor: [
'rgb(255, 99, 132)',
'rgb(255, 159, 64)',
'rgb(255, 205, 86)',
'rgb(75, 192, 192)',
'rgb(54, 162, 235)',
'rgb(153, 102, 255)',
'rgb(201, 203, 207)'
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
// Create canvas2svg 'fake' context
var c2s = C2S(500,500);
// new chart on 'fake' context
var mySvg = new Chart(c2s, myChart.options);
// Now mySvg contains the SVG representation of the chart
// You can manipulate mySvg as needed
</script>
</body>
</html>