caparol6991

Untitled

Feb 9th, 2020
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $dataPoints = array(
  4.   array(
  5.     array("x" => 1451586600000, "y" => 96.709),
  6.     array("x" => 1454265000000, "y" => 94.918),
  7.     array("x" => 1456770600000, "y" => 95.152),
  8.     array("x" => 1459449000000, "y" => 97.070),
  9.     array("x" => 1462041000000, "y" => 97.305),
  10.     array("x" => 1464719400000, "y" => 89.854),
  11.     array("x" => 1467311400000, "y" => 88.158),
  12.     array("x" => 1469989800000, "y" => 87.989),
  13.     array("x" => 1472668200000, "y" => 86.366),
  14.     array("x" => 1475260200000, "y" => 81.650),
  15.     array("x" => 1477938600000, "y" => 85.789),
  16.     array("x" => 1480530600000, "y" => 83.846),
  17.     array("x" => 1483209000000, "y" => 84.927),
  18.     array("x" => 1485887400000, "y" => 82.609),
  19.     array("x" => 1488306600000, "y" => 81.428),
  20.     array("x" => 1490985000000, "y" => 83.259),
  21.     array("x" => 1493577000000, "y" => 83.153),
  22.     array("x" => 1496255400000, "y" => 84.180),
  23.     array("x" => 1498847400000, "y" => 84.840),
  24.     array("x" => 1501525800000, "y" => 82.671),
  25.     array("x" => 1504204200000, "y" => 87.496),
  26.     array("x" => 1506796200000, "y" => 86.007),
  27.     array("x" => 1509474600000, "y" => 87.233),
  28.     array("x" => 1512066600000, "y"=> 86.276)
  29. ),
  30. array(
  31.  array("x"=> 1451586600000, "y" => 73.5555),
  32.  array("x"=> 1454265000000, "y" => 74.1625),
  33.  array("x"=> 1456770600000, "y" => 75.3980),
  34.  array("x"=> 1459449000000, "y" => 76.0965),
  35.  array("x"=> 1462041000000, "y" => 74.8165),
  36.  array("x"=> 1464719400000, "y" => 74.9660),
  37.  array("x"=> 1467311400000, "y" => 74.4805),
  38.  array("x"=> 1469989800000, "y" => 74.7355),
  39.  array("x"=> 1472668200000, "y" => 74.8155),
  40.  array("x"=> 1475260200000, "y" => 73.2275),
  41.  array("x"=> 1477938600000, "y" => 72.6315),
  42.  array("x"=> 1480530600000, "y" => 71.4610),
  43.  array("x"=> 1483209000000, "y" => 72.9025),
  44.  array("x"=> 1485887400000, "y" => 70.5750),
  45.  array("x"=> 1488306600000, "y" => 69.0955),
  46.  array("x"=> 1490985000000, "y" => 70.0565),
  47.  array("x"=> 1493577000000, "y" => 72.5320),
  48.  array("x"=> 1496255400000, "y" => 73.8350),
  49.  array("x"=> 1498847400000, "y" => 76.0255),
  50.  array("x"=> 1501525800000, "y" => 76.1465),
  51.  array("x"=> 1504204200000, "y" => 77.1570),
  52.  array("x"=> 1506796200000, "y" => 75.4075),
  53.  array("x"=> 1509474600000, "y" => 76.7690),
  54.  array("x"=> 1512066600000, "y" => 76.5950)
  55. ),
  56. array(
  57.  array("x"=> 2451586600000, "y" => 73.5555),
  58.  array("x"=> 2454265000000, "y" => 74.1625),
  59.  array("x"=> 2456770600000, "y" => 75.3980),
  60.  array("x"=> 2459449000000, "y" => 76.0965),
  61.  array("x"=> 2462041000000, "y" => 74.8165),
  62.  array("x"=> 2464719400000, "y" => 74.9660),
  63.  array("x"=> 2467311400000, "y" => 74.4805),
  64.  array("x"=> 2469989800000, "y" => 74.7355),
  65.  array("x"=> 2472668200000, "y" => 74.8155),
  66.  array("x"=> 2475260200000, "y" => 73.2275),
  67.  array("x"=> 2477938600000, "y" => 72.6315),
  68.  array("x"=> 2480530600000, "y" => 71.4610),
  69.  array("x"=> 2483209000000, "y" => 72.9025),
  70.  array("x"=> 2485887400000, "y" => 70.5750),
  71.  array("x"=> 2488306600000, "y" => 69.0955),
  72.  array("x"=> 2490985000000, "y" => 70.0565),
  73.  array("x"=> 2493577000000, "y" => 72.5320),
  74.  array("x"=> 2496255400000, "y" => 73.8350),
  75.  array("x"=> 2498847400000, "y" => 76.0255),
  76.  array("x"=> 2501525800000, "y" => 76.1465),
  77.  array("x"=> 2504204200000, "y" => 77.1570),
  78.  array("x"=> 2506796200000, "y" => 75.4075),
  79.  array("x"=> 2509474600000, "y" => 76.7690),
  80.  array("x"=> 2512066600000, "y" => 76.5950)
  81. ));
  82.  
  83. $names = array("EUR","PLN","INDR");
  84. ?>
  85. <!DOCTYPE HTML>
  86. <html>
  87. <head>
  88. <script>
  89. window.onload = function () {
  90.  
  91. var chart = new CanvasJS.Chart("chartContainer", {
  92.     animationEnabled: true,
  93.     title:{
  94.         text: "Comparison of Exchange Rates"
  95.     },
  96.     subtitles: [{
  97.         text: "GBP & EUR to INR",
  98.         fontSize: 18
  99.     }],
  100.     axisY: {
  101.         includeZero: false,
  102.         prefix: "₹"
  103.     },
  104.     legend:{
  105.         cursor: "pointer",
  106.         itemclick: toggleDataSeries
  107.     },
  108.     toolTip: {
  109.         shared: true
  110.     },
  111.     data: [
  112.     ]
  113. });
  114.  
  115. <?php for($i = 0; $i < count($dataPoints);$i++):?>
  116. var newSeries =   {
  117.     type: "area",
  118.     name: "<?php echo $names[$i]?>",
  119.     showInLegend: "true",
  120.     xValueType: "dateTime",
  121.     xValueFormatString: "MMM YYYY",
  122.     yValueFormatString: "₹#,##0.##",
  123.     dataPoints: <?php echo json_encode($dataPoints[$i]); ?>
  124.   };
  125.   chart.options.data.push(newSeries);
  126. <?php endfor ?>
  127.  
  128. chart.render();
  129.  
  130. function toggleDataSeries(e){
  131.     if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
  132.         e.dataSeries.visible = false;
  133.     }
  134.     else{
  135.         e.dataSeries.visible = true;
  136.     }
  137.     chart.render();
  138. }
  139.  
  140. }
  141. </script>
  142. </head>
  143. <body>
  144. <div id="chartContainer" style="height: 370px; width: 100%;"></div>
  145. <script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
  146. </body>
  147. </html>
RAW Paste Data