Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON, Codeigniter, Highcharts and AJAX
    primarykey
    data
    text
    <p>I'm using CI (+HMVC) for showing a Highcharts with an ajax event on a form.</p> <p>My pb is to create valids Series for the chart. I have to create 6 series from mysql DB. My chart code is inpired by <a href="https://stackoverflow.com/questions/11851122/blank-page-highchart-in-using-jquery-to-call-json-arrary">blank page highchart in using jquery to call json arrary</a>.</p> <p>My View (<code>&lt;?=$instance_graph?&gt;</code> is everywhere because I want to be able to instance multiple charts)</p> <pre><code>$(document).ready(function() { $('#submit&lt;?=$instance_graph?&gt;').click(function() { $('#rendu_graph&lt;?=$instance_graph?&gt;').html(''); var form_data = { from : $('#from[name=from&lt;?=$instance_graph?&gt;]').val(), to : $('#to[name=to&lt;?=$instance_graph?&gt;]').val(), parametre : $('#parametre[name=parametres&lt;?=$instance_graph?&gt;]').val(), ajax : '1' }; $.ajax({ url: "&lt;?= site_url('graph_meteo/ajax_graph'); ?&gt;", type: 'POST', async : false, data: form_data, dataType:'json', success: function(data) { //alert(msg) ; //$('#rendu_graph&lt;?=$instance_graph?&gt;').html(msg); var chartSeriesData=[]; $.each(data, function(i,item){ var series_name = item.name; var series_data = item.data; var series = {data: item.data,name:series_name}; chartSeriesData.push(series); }); console.log(chartSeriesData) ; chart = new Highcharts.Chart({ //Début du Highchar chart: { renderTo: 'rendu_graph&lt;?=$instance_graph?&gt;', type: 'spline' }, title: { text: 'Graph' }, subtitle: { text: 'Title' }, xAxis: { type: 'datetime' }, yAxis: { title: { text: 'param 1' } }, tooltip: { formatter: function () { return '&lt;b&gt;' + this.series.name + '&lt;/b&gt;&lt;br/&gt;' + Highcharts.dateFormat('%a %d %b %H:%M', this.x) + ': ' + this.y + ' m'; } }, series: chartSeriesData }) </code></pre> <p>The console.log of the series created :</p> <pre><code>[Object { data="[Date.UTC(2013,02,06,14,15),65.09375]", name="Station 1"}, Object { data="[Date.UTC(2013,02,06,14,15),65.09375]", name="Station 1"}, Object { data="[Date.UTC(2013,02,06,14,15),65.09375]", name="Station 1"}, Object { data="[Date.UTC(2013,02,06,14,30),63.425]", name="Station 1"}. </code></pre> <p><img src="https://i.stack.imgur.com/sZG5s.jpg" alt="image"></p> <p>And of course I have one serie for each object with no plot:</p> <p><img src="https://i.stack.imgur.com/haQxA.jpg" alt="enter image description here"></p> <p>edit :I'm looking for a way to have a nice working graph with these data ( 1 lines) and I want my code working for many lines/series. My big pb is to start from Query result to chart series format. An example could be nice answer.</p> <p>I hope you could help me before I became mad!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload