1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> <?php //get data from database and add to array // $result = mysql_query("SELECT * FROM table WHERE client='Ford'"); // while($row = mysql_fetch_array($result)) // { // $dog[] = $row['brand']; // $dogamounts[] = $row['cost']; // } $dog = array('Jeff', 'Bouncer','Cecil'); $dogamounts = array('25', '10','65'); ?> <script> $(function () { $('#container').highcharts({ chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: 'Browser market shares January, 2016 to May, 2015' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [{ name: 'Brands', colorByPoint: true, data: [ <?php foreach ($dog as $key => $value) { echo "{ name: '$value', y: $dogamounts[$key] }," ; } ?> ] }] }); }); </script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> |
