changxin commited on
Commit
717913e
1 Parent(s): b344af9

Upload chartjs.html

Browse files
Files changed (1) hide show
  1. wps-test/ui/chartjs.html +26 -0
wps-test/ui/chartjs.html ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <head><meta chartset="utf-8">
2
+ <script src="https://cdn.staticfile.org/Chart.js/3.9.1/chart.js"></script>
3
+ </head>
4
+ <body>
5
+ <div style="width:600px;height:500px;margin:auto">
6
+ <canvas id="myChart" width="400" height="300"></canvas>
7
+ </div>
8
+ <script>
9
+ const ctx = document.getElementById('myChart');
10
+ const myChart = new Chart(ctx, {type: 'bar',
11
+ data: {labels: ['Red', 'Blue', 'Yellow', 'Green'],
12
+ datasets: [{label: '# 票数',data: [12, 19, 3, 5],
13
+ backgroundColor: ['rgba(255, 99, 132, 0.2)','rgba(54, 162, 235, 0.2)','rgba(255, 206, 86, 0.2)','rgba(75, 192, 192, 0.2)'],
14
+ borderColor: ['rgba(255, 99, 132, 1)','rgba(54, 162, 235, 1)','rgba(255, 206, 86, 1)','rgba(75, 192, 192, 1)'],
15
+ borderWidth: 1}]
16
+ },
17
+ options: {scales: {y: {beginAtZero: true}}}
18
+ });
19
+ </script>
20
+ </body>
21
+ <script>
22
+ function fx(){
23
+ var a=canvas.get(0).toDataURL();
24
+ alert(a)
25
+ }
26
+ </script>