i have problem highchart. have put date database can't visualize correct graph. show full code , img of visualization have now. please me on that, i'm blocked 3 days in thing.
well js inizialize graph , call ajax function is:
$(function () { var cs = document.getelementbyid('alunni').firstchild.nodevalue; var rend = $('#alunni') var options = { chart: { plotbackgroundcolor: null, plotborderwidth: null, plotshadow: false, renderto: rend[0] }, title: { text: 'numero di studenti iscritti per ogni anno di corso' }, tooltip: { pointformat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotoptions: { pie: { allowpointselect: true, cursor: 'pointer', datalabels: { enabled: true, color: '#000000', connectorcolor: '#000000', format: '<b>{point.name}</b>: {point.percentage:.1f} %' } } }, series: [{ type: 'pie', name: 'percentuale di alunni: ', }] }; $.ajax({ type: 'post', url: 'alunnixclasse.php', async: false, data: {'cs': cs}, datatype: 'json', success: function(data) { options.series[0].data = data; }, error: function(data){ alert("chiamata fallita, si prega di riprovare..."); } }); console.log(options.series); var chart = new highcharts.chart(options); }); and php use take date:
<?php include "connect.php"; $codscu = $_post['cs']; $query = "select * alunni alunni.codscu = $codscu "; $query2 = "select total.totalun total total.codscu = $codscu "; $risultato = mysql_query($query); $risultato2 = mysql_query($query2); $data = ""; $elem = mysql_fetch_array($risultato); $tot = mysql_fetch_array($risultato2); ($i = 0; $i <5; $i++) { $anno = ""; switch($i) { case 0: { $anno = "primo anno"; $value = ($elem['anno_1'] * 100) / $tot['totalun']; break; } case 1: { $anno = "secondo anno"; $value = ($elem['anno_2'] * 100) / $tot['totalun']; break; } case 2: { $anno = "terzo anno"; $value = ($elem['anno_3'] * 100) / $tot['totalun']; break; } case 3: { $anno = "quarto anno"; $value = ($elem['anno_4'] * 100) / $tot['totalun']; break; } case 4: { $anno = "quinto anno"; $value = ($elem['anno_5'] * 100) / $tot['totalun']; break; } } if ($i != 4) { $data = $data."['".$anno."', ".number_format($value, 1,".","")."], "; } else { $data = $data."['".$anno."', ".number_format($value, 1,".","")."]"; } } print json_encode($data); ?> can me please... don't know error!
Comments
Post a Comment