Guest User

Untitled

a guest
Aug 28th, 2020
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div id="chartGeneration" style="height: 370px; width: 100%;"></div>
  2.  
  3. <script type="text/javascript">
  4.     $(document).ready(function(){
  5.         var dataPoints = [];
  6.         var finalData = [];
  7.         var counter = 0;
  8.         var colors = ["#1979a9", "#e84a5f", "#33FF77", "#251f44"];
  9.         var chart = new CanvasJS.Chart("chartGeneration",{
  10.             animationEnabled: true,
  11.             title: {
  12.                 text: "Berdasar Generasi ",
  13.                 fontFamily: "arial black",
  14.                 fontColor: "#695A42"
  15.             },
  16.             data: finalData
  17.         });
  18.         $.getJSON("<?php echo base_url('home/ChartOfGenerationAll');?>", function(data) {
  19.             $.each(data, function(key, val){
  20.                 var data = {};
  21.                 var dataPointR = [];
  22.                 data["type"] = "stackedColumn";
  23.                 data["legendText"] = key;
  24.                 data["color"] = colors[counter++];
  25.                 data["showInLegend"] = true;
  26.                 data["name"] = key;
  27.                 $.each(val, function (key2, val2) {
  28.                     dataPointR.push({"y": parseInt(val2.jumlah), "label": val2.cabang});
  29.                 });
  30.  
  31.                 data["dataPoints"] = dataPointR;
  32.                 finalData.push(data);
  33.             });
  34.             //console.log(finalData);
  35.             chart.render();
  36.         });
  37.     });
  38. </script>
RAW Paste Data