-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
154 lines (145 loc) · 3.5 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<html>
<head>
<style>
body {
width: 75%;
margin: auto;
}
</style>
<script type="text/javascript">
window.onload = function() {
var chart1 = new CanvasJS.Chart("chartContainer1", {
theme: "light2", // "light1", "dark1", "dark2"
animationEnabled: true,
exportEnabled: true,
title: {
text: "Export Chart Data as JSON"
},
subtitles: [{
text: "When exportEnabled is set to true"
}],
data: [{
// Change type to "bar", "area", "spline", "pie",etc.
type: "column",
dataPoints: [{
label: "apple",
y: 10
}, {
label: "orange",
y: 15
}, {
label: "banana",
y: 25
}, {
label: "mango",
y: 30
}, {
label: "grape",
y: 28
}]
}]
});
var chart2 = new CanvasJS.Chart("chartContainer2", {
theme: "light2", // "light1", "dark1", "dark2"
animationEnabled: true,
title: {
text: "Export Chart Data as JSON"
},
subtitles: [{
text: "When exportEnabled is set to false"
}],
data: [{
// Change type to "bar", "area", "spline", "pie",etc.
type: "column",
dataPoints: [{
label: "apple",
y: 10
}, {
label: "orange",
y: 15
}, {
label: "banana",
y: 25
}, {
label: "mango",
y: 30
}, {
label: "grape",
y: 28
}]
}]
});
var chart3 = new CanvasJS.Chart("chartContainer3", {
theme: "light2", // "light1", "dark1", "dark2"
animationEnabled: true,
zoomEnabled: true,
title: {
text: "Export Chart Data as JSON"
},
subtitles: [{
text: "When exportEnabled is set to false and zoomEnabled is set to true"
}],
data: [{
// Change type to "bar", "area", "spline", "pie",etc.
type: "column",
dataPoints: [{
label: "apple",
y: 10
}, {
label: "orange",
y: 15
}, {
label: "banana",
y: 25
}, {
label: "mango",
y: 30
}, {
label: "grape",
y: 28
}]
}]
});
chart1.render();
chart2.render();
chart3.render();
//CanvasJSDataAsJSON(chart, ["Filename"]); //Filename is optional - defaults to "chart-data"
CanvasJSDataAsJSON(chart1, "Chart Data");
CanvasJSDataAsJSON(chart2, "Chart Data");
CanvasJSDataAsJSON(chart3, "Chart Data");
}
</script>
</head>
<body>
<h1 id="exportcanvasjschartdataasjson">Export CanvasJS Chart Data as JSON</h1>
<p>This plugin allows you to export and save <a href="https://canvasjs.com/" target="_blank">CanvasJS</a> Chart's data as JSON. Check out <a href="https://github.com/vishwas-r/Export-CanvasJS-Chart-Data-as-JSON/">Github Repository</a> for more info / examples.</p>
<h4 id="howtouse">How to Use?</h4>
<ul>
<li>Create and Render CanvasJS Chart</li>
<li>Call CanvasJSDataAsJSON method with chart and filename as parameter</li>
</ul>
<pre><code>var chart = new CanvasJS.Chart("chartContainer", {
.
.
.
//Chart Options
.
.
.
});
chart.render();
CanvasJSDataAsJSON(chart, "filename");
</code></pre>
<h4>Live Example</h4>
<p>Example 1: When exportEnabled property is set to true</p>
<div id="chartContainer1" style="height: 360px; width: 60%; border: 1px solid black;"></div>
<br/>
<p>Example 2: When exportEnabled property is set to false</p>
<div id="chartContainer2" style="height: 360px; width: 60%; border: 1px solid black;"></div>
<br/>
<p>Example 3: When exportEnabled property is set to false and zoomEnabled is set to true</p>
<div id="chartContainer3" style="height: 360px; width: 60%; border: 1px solid black;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"> </script>
<script src="dist/canvasjsasjson.min.js"> </script>
</body>
</html>