Advertisement
cecepsuwanda

chart

Sep 10th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.03 KB | None | 0 0
  1. <html>
  2.     <head>
  3.      <title>Contoh </title>
  4.      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>        
  5.      <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>        
  6.     </head>
  7.     <body> 
  8.        
  9.        
  10.         <div class="container">
  11.             <canvas id="myChart" width="50" height="50"></canvas>
  12.         </div>
  13.        
  14.         <script>
  15.             var ctx = $("#myChart").get(0).getContext("2d");
  16.             var myChart = new Chart(ctx);
  17.            
  18.             var areaChartData = {
  19.                                   labels: ["January", "February", "March", "April", "May", "June", "July"],
  20.                                   datasets: [
  21.                                     {
  22.                                       label: "Electronics",
  23.                                       fillColor: "rgba(210, 214, 222, 1)",
  24.                                       strokeColor: "rgba(210, 214, 222, 1)",
  25.                                       pointColor: "rgba(210, 214, 222, 1)",
  26.                                       pointStrokeColor: "#c1c7d1",
  27.                                       pointHighlightFill: "#fff",
  28.                                       pointHighlightStroke: "rgba(220,220,220,1)",
  29.                                       data: [65, 59, 80, 81, 56, 55, 40]
  30.                                     },
  31.                                     {
  32.                                       label: "Digital Goods",
  33.                                       fillColor: "rgba(60,141,188,0.9)",
  34.                                       strokeColor: "rgba(60,141,188,0.8)",
  35.                                       pointColor: "#3b8bba",
  36.                                       pointStrokeColor: "rgba(60,141,188,1)",
  37.                                       pointHighlightFill: "#fff",
  38.                                       pointHighlightStroke: "rgba(60,141,188,1)",
  39.                                       data: [28, 48, 40, 19, 86, 27, 90]
  40.                                     }
  41.                                   ]
  42.                                 };
  43.            
  44.             var barChartOptions = {
  45.                                       //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  46.                                       scaleBeginAtZero: true,
  47.                                       //Boolean - Whether grid lines are shown across the chart
  48.                                       scaleShowGridLines: true,
  49.                                       //String - Colour of the grid lines
  50.                                       scaleGridLineColor: "rgba(0,0,0,.05)",
  51.                                       //Number - Width of the grid lines
  52.                                       scaleGridLineWidth: 1,
  53.                                       //Boolean - Whether to show horizontal lines (except X axis)
  54.                                       scaleShowHorizontalLines: true,
  55.                                       //Boolean - Whether to show vertical lines (except Y axis)
  56.                                       scaleShowVerticalLines: true,
  57.                                       //Boolean - If there is a stroke on each bar
  58.                                       barShowStroke: true,
  59.                                       //Number - Pixel width of the bar stroke
  60.                                       barStrokeWidth: 2,
  61.                                       //Number - Spacing between each of the X value sets
  62.                                       barValueSpacing: 5,
  63.                                       //Number - Spacing between data sets within X values
  64.                                       barDatasetSpacing: 1,
  65.                                       //String - A legend template
  66.                                       legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].fillColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>",
  67.                                       //Boolean - whether to make the chart responsive
  68.                                       responsive: true,
  69.                                       maintainAspectRatio: true
  70.                                     };
  71.             barChartOptions.datasetFill = false;           
  72.             myChart.Bar(areaChartData, barChartOptions);                       
  73.         </script>
  74.     </body>
  75.  
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement