Advertisement
Guest User

chart.php

a guest
Oct 13th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.73 KB | None | 0 0
  1. <!-- Content Wrapper. Contains page content -->
  2.   <div class="content-wrapper">
  3.     <!-- Content Header (Page header) -->
  4.     <section class="content-header">
  5.       <h1>
  6.         Chart
  7.       </h1>
  8.       <ol class="breadcrumb">
  9.         <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  10.         <li><a href="#">Charts</a></li>
  11.       </ol>
  12.     </section>
  13.  
  14.     <!-- Main content -->
  15.     <section class="content">
  16.       <div class="row">
  17.         <div class="col-md-6">
  18.           <!-- DONUT CHART -->
  19.           <div class="box box-danger">
  20.             <div class="box-header with-border">
  21.               <h3 class="box-title">Grafik Gender Siswa</h3>
  22.  
  23.               <div class="box-tools pull-right">
  24.                 <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
  25.                 </button>
  26.                 <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
  27.               </div>
  28.             </div>
  29.             <div class="box-body">
  30.               <canvas id="pieChart" style="height:250px"></canvas>
  31.             </div>
  32.             <!-- /.box-body -->
  33.           </div>
  34.           <!-- /.box -->
  35.  
  36.         </div>
  37.         <!-- /.col (LEFT) -->
  38.         <div class="col-md-6">
  39.           <!-- /.box -->
  40.  
  41.           <!-- BAR CHART -->
  42.           <div class="box box-success">
  43.             <div class="box-header with-border">
  44.               <h3 class="box-title">Grafik Tahun Kelahiran Siswa</h3>
  45.  
  46.               <div class="box-tools pull-right">
  47.                 <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
  48.                 </button>
  49.                 <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
  50.               </div>
  51.             </div>
  52.             <div class="box-body">
  53.               <div class="chart">
  54.                 <canvas id="barChart" style="height:230px"></canvas>
  55.               </div>
  56.             </div>
  57.             <!-- /.box-body -->
  58.           </div>
  59.           <!-- /.box -->
  60.  
  61.         </div>
  62.         <!-- /.col (RIGHT) -->
  63.       </div>
  64.       <!-- /.row -->
  65.  
  66.     </section>
  67.   </div>
  68.   <script>
  69. <script>
  70.   $(function () {
  71.     /* ChartJS
  72.      * -------
  73.      * Here we will create a few charts using ChartJS
  74.      */
  75.  
  76.     //--------------
  77.     //- AREA CHART -
  78.     //--------------
  79.  
  80.     // Get context with jQuery - using jQuery's .get() method.
  81.     var areaChartCanvas = $('#areaChart').get(0).getContext('2d')
  82.     // This will get the first returned node in the jQuery collection.
  83.     var areaChart       = new Chart(areaChartCanvas)
  84.  
  85.     var areaChartData = {
  86.       labels  : ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  87.       datasets: [
  88.         {
  89.           label               : 'Electronics',
  90.           fillColor           : 'rgba(210, 214, 222, 1)',
  91.           strokeColor         : 'rgba(210, 214, 222, 1)',
  92.           pointColor          : 'rgba(210, 214, 222, 1)',
  93.           pointStrokeColor    : '#c1c7d1',
  94.           pointHighlightFill  : '#fff',
  95.           pointHighlightStroke: 'rgba(220,220,220,1)',
  96.           data                : [65, 59, 80, 81, 56, 55, 40]
  97.         },
  98.         {
  99.           label               : 'Digital Goods',
  100.           fillColor           : 'rgba(60,141,188,0.9)',
  101.           strokeColor         : 'rgba(60,141,188,0.8)',
  102.           pointColor          : '#3b8bba',
  103.           pointStrokeColor    : 'rgba(60,141,188,1)',
  104.           pointHighlightFill  : '#fff',
  105.           pointHighlightStroke: 'rgba(60,141,188,1)',
  106.           data                : [28, 48, 40, 19, 86, 27, 90]
  107.         }
  108.       ]
  109.     }
  110.  
  111.     var areaChartOptions = {
  112.       //Boolean - If we should show the scale at all
  113.       showScale               : true,
  114.       //Boolean - Whether grid lines are shown across the chart
  115.       scaleShowGridLines      : false,
  116.       //String - Colour of the grid lines
  117.       scaleGridLineColor      : 'rgba(0,0,0,.05)',
  118.       //Number - Width of the grid lines
  119.       scaleGridLineWidth      : 1,
  120.       //Boolean - Whether to show horizontal lines (except X axis)
  121.       scaleShowHorizontalLines: true,
  122.       //Boolean - Whether to show vertical lines (except Y axis)
  123.       scaleShowVerticalLines  : true,
  124.       //Boolean - Whether the line is curved between points
  125.       bezierCurve             : true,
  126.       //Number - Tension of the bezier curve between points
  127.       bezierCurveTension      : 0.3,
  128.       //Boolean - Whether to show a dot for each point
  129.       pointDot                : false,
  130.       //Number - Radius of each point dot in pixels
  131.       pointDotRadius          : 4,
  132.       //Number - Pixel width of point dot stroke
  133.       pointDotStrokeWidth     : 1,
  134.       //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  135.       pointHitDetectionRadius : 20,
  136.       //Boolean - Whether to show a stroke for datasets
  137.       datasetStroke           : true,
  138.       //Number - Pixel width of dataset stroke
  139.       datasetStrokeWidth      : 2,
  140.       //Boolean - Whether to fill the dataset with a color
  141.       datasetFill             : true,
  142.       //String - A legend template
  143.       legendTemplate          : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].lineColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  144.       //Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
  145.       maintainAspectRatio     : true,
  146.       //Boolean - whether to make the chart responsive to window resizing
  147.       responsive              : true
  148.     }
  149.  
  150.     //Create the line chart
  151.     areaChart.Line(areaChartData, areaChartOptions)
  152.  
  153.     //-------------
  154.     //- LINE CHART -
  155.     //--------------
  156.     var lineChartCanvas          = $('#lineChart').get(0).getContext('2d')
  157.     var lineChart                = new Chart(lineChartCanvas)
  158.     var lineChartOptions         = areaChartOptions
  159.     lineChartOptions.datasetFill = false
  160.     lineChart.Line(areaChartData, lineChartOptions)
  161.  
  162.     //-------------
  163.     //- PIE CHART -
  164.     //-------------
  165.     // Get context with jQuery - using jQuery's .get() method.
  166.     var pieChartCanvas = $('#pieChart').get(0).getContext('2d')
  167.     var pieChart       = new Chart(pieChartCanvas)
  168.     var PieData        = [
  169.       {
  170.         value    : 700,
  171.         color    : '#f56954',
  172.         highlight: '#f56954',
  173.         label    : 'Chrome'
  174.       },
  175.       {
  176.         value    : 500,
  177.         color    : '#00a65a',
  178.         highlight: '#00a65a',
  179.         label    : 'IE'
  180.       },
  181.       {
  182.         value    : 400,
  183.         color    : '#f39c12',
  184.         highlight: '#f39c12',
  185.         label    : 'FireFox'
  186.       },
  187.       {
  188.         value    : 600,
  189.         color    : '#00c0ef',
  190.         highlight: '#00c0ef',
  191.         label    : 'Safari'
  192.       },
  193.       {
  194.         value    : 300,
  195.         color    : '#3c8dbc',
  196.         highlight: '#3c8dbc',
  197.         label    : 'Opera'
  198.       },
  199.       {
  200.         value    : 100,
  201.         color    : '#d2d6de',
  202.         highlight: '#d2d6de',
  203.         label    : 'Navigator'
  204.       }
  205.     ]
  206.     var pieOptions     = {
  207.       //Boolean - Whether we should show a stroke on each segment
  208.       segmentShowStroke    : true,
  209.       //String - The colour of each segment stroke
  210.       segmentStrokeColor   : '#fff',
  211.       //Number - The width of each segment stroke
  212.       segmentStrokeWidth   : 2,
  213.       //Number - The percentage of the chart that we cut out of the middle
  214.       percentageInnerCutout: 50, // This is 0 for Pie charts
  215.       //Number - Amount of animation steps
  216.       animationSteps       : 100,
  217.       //String - Animation easing effect
  218.       animationEasing      : 'easeOutBounce',
  219.       //Boolean - Whether we animate the rotation of the Doughnut
  220.       animateRotate        : true,
  221.       //Boolean - Whether we animate scaling the Doughnut from the centre
  222.       animateScale         : false,
  223.       //Boolean - whether to make the chart responsive to window resizing
  224.       responsive           : true,
  225.       // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
  226.       maintainAspectRatio  : true,
  227.       //String - A legend template
  228.       legendTemplate       : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'
  229.     }
  230.     //Create pie or douhnut chart
  231.     // You can switch between pie and douhnut using the method below.
  232.     pieChart.Doughnut(PieData, pieOptions)
  233.  
  234.     //-------------
  235.     //- BAR CHART -
  236.     //-------------
  237.     var barChartCanvas                   = $('#barChart').get(0).getContext('2d')
  238.     var barChart                         = new Chart(barChartCanvas)
  239.     var barChartData                     = areaChartData
  240.     barChartData.datasets[1].fillColor   = '#00a65a'
  241.     barChartData.datasets[1].strokeColor = '#00a65a'
  242.     barChartData.datasets[1].pointColor  = '#00a65a'
  243.     var barChartOptions                  = {
  244.       //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  245.       scaleBeginAtZero        : true,
  246.       //Boolean - Whether grid lines are shown across the chart
  247.       scaleShowGridLines      : true,
  248.       //String - Colour of the grid lines
  249.       scaleGridLineColor      : 'rgba(0,0,0,.05)',
  250.       //Number - Width of the grid lines
  251.       scaleGridLineWidth      : 1,
  252.       //Boolean - Whether to show horizontal lines (except X axis)
  253.       scaleShowHorizontalLines: true,
  254.       //Boolean - Whether to show vertical lines (except Y axis)
  255.       scaleShowVerticalLines  : true,
  256.       //Boolean - If there is a stroke on each bar
  257.       barShowStroke           : true,
  258.       //Number - Pixel width of the bar stroke
  259.       barStrokeWidth          : 2,
  260.       //Number - Spacing between each of the X value sets
  261.       barValueSpacing         : 5,
  262.       //Number - Spacing between data sets within X values
  263.       barDatasetSpacing       : 1,
  264.       //String - A legend template
  265.       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>',
  266.       //Boolean - whether to make the chart responsive
  267.       responsive              : true,
  268.       maintainAspectRatio     : true
  269.     }
  270.  
  271.     barChartOptions.datasetFill = false
  272.     barChart.Bar(barChartData, barChartOptions)
  273.   })
  274.   </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement