Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <script type="text/javascript" src = "http://canvasjs.com/wp-content/themes/bootstrap_child/assets/js/jquery-1.8.3.min.js"> </script>
- <script type="text/javascript" src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
- </head>
- <body>
- <div id="chartContainer" class="chart">
- <script type="text/javascript">
- data=[
- {
- "Date": "2014-01-30",
- "CarsParked": "1",
- "RevenueWithTip": "0",
- "Revenue": "0",
- "Tip": "0",
- },
- {
- "Date": "2014-01-31",
- "CarsParked": "10",
- "RevenueWithTip": "10",
- "Revenue": "7",
- "Tip": "3",
- },
- {
- "Date": "2014-02-28",
- "CarsParked": "28",
- "RevenueWithTip": "55",
- "Revenue": "47",
- "Tip": "8",
- }];
- var len = data.length;
- $.each(data, function(i, v) {
- chart(v.Date,v.Tip,v.Revenue,len);
- });
- function chart (dates,Tip,Rev,len) {
- var chart = new CanvasJS.Chart("chartContainer", {
- title: {
- text: "Revenue",
- fontSize: 15
- },
- axisX: {
- gridColor: "Silver",
- tickColor: "silver",
- valueFormatString: "DD/MMM"
- },
- toolTip: {
- shared:true
- },
- theme: "theme2",
- axisY: {
- gridColor: "Silver",
- tickColor: "silver"
- },
- legend: {
- verticalAlign: "center",
- horizontalAlign: "right"
- },
- data: [
- {
- type: "line",
- showInLegend: true,
- lineThickness: 2,
- name: "Tip",
- markerType: "square",
- color: "#F08080",
- dataPoints: [
- {
- x: new Date(dates),
- y: parseInt(Tip)
- }
- ]
- },
- {
- type: "line",
- showInLegend: true,
- name: "Revenue",
- color: "#20B2AA",
- lineThickness: 2,
- dataPoints: [
- {
- x: new Date(dates),
- y: parseInt(Rev)
- }
- ]
- }
- ],
- legend: {
- cursor: "pointer",
- itemclick: function(e) {
- if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
- e.dataSeries.visible = false;
- } else {
- e.dataSeries.visible = true;
- }
- chart.render();
- }
- }
- });
- chart.render();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement