Skip to content

Commit 8fe6810

Browse files
committed
Added Example
1 parent 327d640 commit 8fe6810

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

dist/example.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<script type="text/javascript">
5+
window.onload = function () {
6+
7+
var chart = new CanvasJS.Chart("chartContainer", {
8+
theme: "light2", // "light1", "dark1", "dark2"
9+
animationEnabled: true,
10+
exportEnabled: true,
11+
title:{
12+
text: "Basic Column Chart"
13+
},
14+
data: [
15+
{
16+
// Change type to "bar", "area", "spline", "pie",etc.
17+
type: "column",
18+
dataPoints: [
19+
{ label: "apple", y: 10 },
20+
{ label: "orange", y: 15 },
21+
{ label: "banana", y: 25 },
22+
{ label: "mango", y: 30 },
23+
{ label: "grape", y: 28 }
24+
]
25+
}
26+
]
27+
});
28+
chart.render();
29+
30+
//CanvasJSAsCSV(chart, ["Filename"]); //Filename is optional - defaults to "chart-data"
31+
32+
CanvasJSDataAsJSON(chart, "Chart Data");
33+
}
34+
</script>
35+
</head>
36+
<body>
37+
<div id="chartContainer" style="height: 400px; width: 50%; margin: auto;"></div>
38+
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"> </script>
39+
<script src="canvasjsasjson.min.js"> </script>
40+
</body>
41+
</html>

index.html

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<html>
2+
3+
<head>
4+
<style>
5+
body {
6+
width: 75%;
7+
margin: auto;
8+
}
9+
</style>
10+
<script type="text/javascript">
11+
window.onload = function() {
12+
var chart = new CanvasJS.Chart("chartContainer", {
13+
theme: "light2", // "light1", "dark1", "dark2"
14+
animationEnabled: true,
15+
exportEnabled: true,
16+
title: {
17+
text: "Basic Column Chart"
18+
},
19+
data: [{
20+
// Change type to "bar", "area", "spline", "pie",etc.
21+
type: "column",
22+
dataPoints: [{
23+
label: "apple",
24+
y: 10
25+
}, {
26+
label: "orange",
27+
y: 15
28+
}, {
29+
label: "banana",
30+
y: 25
31+
}, {
32+
label: "mango",
33+
y: 30
34+
}, {
35+
label: "grape",
36+
y: 28
37+
}]
38+
}]
39+
});
40+
chart.render();
41+
//CanvasJSDataAsJSON(chart, ["Filename"]); //Filename is optional - defaults to "chart-data"
42+
CanvasJSDataAsJSON(chart, "Chart Data");
43+
}
44+
</script>
45+
</head>
46+
47+
<body>
48+
<h1 id="exportcanvasjschartdataasjson">Export CanvasJS Chart Data as JSON</h1>
49+
<p>This plugin allows you to export and save CanvasJS Chart's data as JSON.</p>
50+
<h2 id="canvasjs">CanvasJS</h2>
51+
<p>CanvasJS is an HTML5 &amp; JavaScript based Charting Library that runs on all modern devices including iPhone, Android, Desktops, etc. Charts are beautiful and API is very simple to use.</p>
52+
<h4 id="canvasjsfeatures">CanvasJS Features:</h4>
53+
<ul>
54+
<li>Simple API and easy to use</li>
55+
<li>Supports 30+ different types of Charts / Graphs</li>
56+
<li>10x faster than conventional Flash / SVG based Charting Libraries</li>
57+
<li>Comes with Several beautiful looking themes</li>
58+
<li>Well Maintained and Updated Documentation</li>
59+
<li>Works across browsers (Chrome, Firefox, Safari, IE8+)</li>
60+
<li>Can be integrated with Serverside and Frontend technologies like ASP.Net, PHP, Spring MVC, JSP, jQuery, Angular, React, etc.</li>
61+
</ul>
62+
<h4 id="howtouse">How to Use?</h4>
63+
<ul>
64+
<li>Create and Render CanvasJS Chart</li>
65+
<li>Call CanvasJSDataAsJSON method with chart and filename as parameter</li>
66+
</ul>
67+
<pre><code>var chart = new CanvasJS.Chart("chartContainer", {
68+
.
69+
.
70+
.
71+
//Chart Options
72+
.
73+
.
74+
.
75+
});
76+
chart.render();
77+
78+
CanvasJSDataAsJSON(chart, "filename");
79+
</code></pre>
80+
<h4>Live Example</h4>
81+
<div id="chartContainer" style="height: 400px; width: 60%;"></div>
82+
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"> </script>
83+
<script src="dist/canvasjsasjson.min.js"> </script>
84+
</body>
85+
86+
</html>

0 commit comments

Comments
 (0)