json - HighCharts - Filling a heatmap from SQL Query -
im trying fill highcharts heatmap data returned sql query.
what have in js file is
$(function () { var chart; $(document).ready(function() { $.getjson("php/all-counties-sales-data-box.php", function(json) { chart = new highcharts.chart({ chart: { renderto: 'chart-box-combined', type: 'heatmap', margintop: 40, marginbottom: 80, plotborderwidth: 1 }, title: { text: 'sales per employee per weekday' }, xaxis: { categories: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] }, yaxis: { categories: ['lucozade', 'rockstar', 'sprite', 'monster', '7up', 'fanta', 'coke'], title: null }, coloraxis: { min: 0, mincolor: '#ffffff', maxcolor: highcharts.getoptions().colors[0] }, legend: { align: 'right', layout: 'vertical', margin: 0, verticalalign: 'top', y: 25, symbolheight: 280 }, tooltip: { formatter: function () { return '<b>' + this.series.xaxis.categories[this.point.x] + '</b> sold <br><b>' + this.point.value + '</b> items on <br><b>' + this.series.yaxis.categories[this.point.y] + '</b>'; } }, series: [{ name: 'sales per shell', borderwidth: 1, data: [[0, 0, 10], [0, 1, 19], [0, 2, 8], [0, 3, 24], [0, 4, 67], [0, 5, 67], [0, 6, 67], [1, 0, 92], [1, 1, 58], [1, 2, 78], [1, 3, 117], [1, 4, 48], [1, 5, 48], [1, 6, 48], [2, 0, 35], [2, 1, 15], [2, 2, 123], [2, 3, 64], [2, 4, 52], [3, 0, 72], [3, 1, 132], [3, 2, 114], [3, 3, 19], [3, 4, 16], [4, 0, 38], [4, 1, 5], [4, 2, 8], [4, 3, 117], [4, 4, 115], [5, 0, 88], [5, 1, 32], [5, 2, 12], [5, 3, 6], [5, 4, 120], [6, 0, 13], [6, 1, 44], [6, 2, 88], [6, 3, 98], [6, 4, 96], [7, 0, 31], [7, 1, 1], [7, 2, 82], [7, 3, 32], [7, 4, 30], [8, 0, 85], [8, 1, 97], [8, 2, 123], [8, 3, 64], [8, 4, 84], [9, 0, 47], [9, 1, 114], [9, 2, 31], [9, 3, 48], [9, 4, 91], [10, 0, 47], [11, 0, 47], ], datalabels: { enabled: true, color: '#000000' } }] }); }); }); });
and im trying fill data query
$sth = mysql_query("select sum(profit) profitsum factsales group shelltype, salemonth"); $rows1 = array(); $rows1['profit'] = 'profitsum'; while($rr = mysql_fetch_assoc($sth)) { $rows1['series'][] = $rr['profitsum']; } $result = array(); array_push($result,$rows1);
what need change "series" data filled data returned sql query?
heres json response requested
[{"profit":"profitsum","data":[1329230,1796743,1789417,1327813,1457103,1198845,1859826,1770589,1555410,1310369,2183499,1212897,6424306,6426002,6345153,6167415,6969392,5974880,6407699,6278843,6622002,5962102,5198177,5386392,72991,2321397,1751565,2029890,642041,1314314,1322492,1557859,1647784,1831767,1347480,1739353,1742597,1636006,1728247,1709689,1206645,1383206,1119153,1378317,1527356,1937898,1485322,1404498,1868629,1635265,1860456,1293870,1485349,2031389,1834402,1291372,1838382,1616009,781641,1421830,1763592,1279535,1123468,2024766,975863,1461843,1318585,1137336,1111721,1407705,2349652,1260858,1144070,1219659,1378615,1354139,2015115,1408858,2650864,1810850,1380157,1844909,2055306,1913532,1701963]}]
Comments
Post a Comment