Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Highcharts Example</title>
- </head>
- <body>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <?php
- include "koneksi.php";
- $sql="SELECT nama_band,vote
- FROM tb_voting2 GROUP BY nama_band";
- $result=mysql_query($sql);
- $series=array();
- $total=0;
- while($record=mysql_fetch_array($sql)){
- $total+=$record['vote'];
- $series[]="{name:'".$record['nama_band']."',data:[".$record['vote']."]}";
- }
- ?>
- <script type="text/javascript">
- $(function () {
- $('#container').highcharts(
- {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Total Vote'
- },
- xAxis: {
- categories: ['nama band'],
- labels: {
- align: 'right',
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- title: {
- text: 'Votes'
- }
- },
- legend: {
- enabled: true
- },
- tooltip: {
- formatter: function() {
- var point = this.point,
- s = this.series.name +':<b>'+ this.y +' vote</b><br/>';
- return s;
- }
- },
- plotOptions: {
- column: {
- cursor: 'pointer',
- pointPadding: 0.2,
- borderWidth: 0,
- dataLabels: {
- enabled: true,
- formatter: function() {
- return this.series.name +'='+ (this.y/100).toFixed(2) +' %';
- }
- }
- }
- },
- series: [<?php echo implode(',',$series);?>]
- });
- });
- </script>
- <script src="js/highcharts.js"></script>
- <script src="js/modules/exporting.js"></script>
- <div id="container" style="min-width: 310px; height: 750px; margin: 0 auto"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement