Morris area chart jquery/php -


i have problem morris chart. tried many times , in many different ways create morris area chart data situated in html table failed.

this way used extract data table:

$('.tabella_dati').click(function () {      var table = $("#datatbl tbody");     var $data = table.find('tr').each(function (i, tr) {         var righe = $('td', tr).map(function (i, td) {             return $(td).text();         });         var $ciao = json.stringify(righe);                     $.post('charts', {data: $ciao}, function (data) {             alert(data);         });     }).text(); 

i tried , without post method. post method tried create chart in php function in way:

function morris() {     $data = input::get('data');     echo '<script>morris.area({element: "morris-area-chart",'     . 'data: '.$data.'}, xkey: '.$data.', ykeys: '.$data.')</script>'; 

xkey , ykeys wrong, know.

sorry bad english , thanks.

so...this table table

function buildtable($arrfilled, $arrdates) {     $mesi = array("1" => "january",         "2" => "february",         "3" => "march",         "4" => "april",         "5" => "may",         "6" => "june",         "7" => "july",         "8" => "august",         "9" => "september",         "10" => "october",         "11" => "november",         "12" => "december");     echo '<table id="datatbl" class="table">';     echo '<thead>';     echo '<th class="text-center">country</th>';     foreach ($arrfilled $k => $v) {         $arr = explode("_", $k);         echo '<th class="text-center">' . $mesi[$arr[1]] . "<br>" . $arr[0] . '</th>';     }     echo '</thead>';     echo '<tbody>';     $i = 0;     $countries = array_keys($arrdates);     foreach ($countries $c) {         echo '<tr>';         echo '<td class = "text-center">' . $countries[$i] . '</td>';         foreach ($arrfilled $k => $v) {             $valore = isset($arrdates[$c][$k]) ? $arrdates[$c][$k] : $v;             if ($valore != 0) {                 echo '<td class="text-center" bgcolor="#add8e6">' . $valore . '</td>';             } else {                 echo '<td class="text-center">' . $valore . '</td>';             }         }         echo '</tr>';         $i++;     }     echo '</tbody>';     echo '</table>'; }  function table() {     $mesi = input::get('month');     $array = [];     ($i = 0; $i <= $mesi - 1; $i++) {         $arraymesi[$i] = $i;         $array[date("y_n", strtotime("-$arraymesi[$i] month"))] = 0;     }     $countries = db::table('countries')->get();     $country_index = 0;     $arrdates = [];     foreach ($countries $c) {         $arrcountires[] = $c->country_name;         $subscription = db::table('subscription')->select('quantity', 'country_id', db::raw('concat(year(date), "_" , month(date)) meseanno'))                         ->where('country_id', '=', $c->country_id)                         ->groupby('meseanno')->get();         foreach ($subscription $s) {             $arrdates[$arrcountires[$country_index]][$s->meseanno] = $s->quantity;         }         $country_index++;     }     return $this->buildtable($array, $arrdates); } 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -