Hi fanny,

The data needs to be in JavaScript, but you have it in php. Converting it
to a string in php that represents the JavaScript is one way to do it.  But
this message might give you some other ideas:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/google-visualization-api/Kw6PI-L7g6Y/PEF8JshrGwAJ


On Wed, Apr 20, 2016 at 7:12 AM, fanny André <ramdamal...@gmail.com> wrote:

> Bonjour et merci pour la réponse :)
>
> Mon $chart est justement une variable qui stock mon tableau de dates.
> En voici un echo :
>
> *[["Vick
> vaporub","2016-03-16","2016-03-19"],["Actifed","2016-03-10","2016-03-31"],["Aspirine","2016-04-10","2016-04-15"]]*
>
>
> Avez vous une autre idée ?
> *Merci*
>
>
> Le mercredi 20 avril 2016 13:00:17 UTC+2, Daniel LaLiberte a écrit :
>>
>> You have to store your $chart data in a JavaScript variable, and the
>> value that you pass to dataTable.addRows() has to be an array of arrays.  I
>> don't know enough php to write that for you, but that should help.
>>
>> On Wed, Apr 20, 2016 at 3:13 AM, fanny André <ramda...@gmail.com> wrote:
>>
>>> Bonjour,
>>>
>>> Voila j'essai de mettre en place la Timeline Google Charts avec mes
>>> données en BDD.
>>> Ce sont des dates de prise de médicament à afficher... Début et fin de
>>> prise
>>> J'ai lu la doc de Google mais je n'arrive toujours pas a afficher mon
>>> graph....
>>>
>>> Est ce que quelqu'un pourrait m'aider ??!
>>> Merci :)
>>> Voila ce que j'ai dans mon fichier :
>>>
>>> Code : Tout sélectionner
>>> <http://forum.phpfrance.com/php-debutant/timeline-google-charts-mysql-t275977.html#>
>>> <script type="text/javascript" src="../js/jquery1.11.3.js"></script>
>>> <script src="https://www.google.com/jsapi"; type="text/javascript"></
>>> script>
>>> <script type="text/javascript" src="
>>> https://www.gstatic.com/charts/loader.js";></script>
>>> </head>
>>> <body>
>>> <?php
>>> include_once("../inc/connexion.php");
>>>    $query = $mysqli -> query("SELECT * FROM medicament
>>>    INNER JOIN compte
>>>    ON medicament.cp_id = compte.cp_id
>>>    WHERE compte.cp_id = $id_cp
>>>    ");
>>>    $results = array();
>>>    while($rows = $query -> fetch_array()){
>>>    $results[] = $rows;
>>>    $chart = array();
>>>    foreach($results as $result)
>>>    {
>>>    $chart[] = array($result['med_nom'], (int)$result['debut_prise'
>>> ],(int)$result['fin_prise']);
>>>    }
>>>    $chart = json_encode($chart);
>>>    }
>>>    echo $chart;
>>> ?>
>>>
>>> <div id="timeline" style="height: 180px;"></div>
>>>
>>> <script type="text/javascript" src="
>>> https://www.gstatic.com/charts/loader.js";></script>
>>>     <script type="text/javascript">
>>>       google.charts.load('current', {'packages':['timeline']});
>>>       google.charts.setOnLoadCallback(drawChart);
>>>       function drawChart() {
>>>         var container = document.getElementById('timeline');
>>>         var chart = new google.visualization.Timeline(container);
>>>         var dataTable = new google.visualization.DataTable();
>>>
>>>         dataTable.addColumn({ type: 'string', id: 'med_nom' });
>>>         dataTable.addColumn({ type: 'date', id: 'debut_prise' });
>>>         dataTable.addColumn({ type: 'date', id: 'fin_prise' });
>>>         dataTable.addRows([$chart]);
>>>
>>>         chart.draw(dataTable);
>>>       }
>>>     </script>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Google Visualization API" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to google-visualization-api+unsubscr...@googlegroups.com.
>>> To post to this group, send email to google-visua...@googlegroups.com.
>>> Visit this group at
>>> https://groups.google.com/group/google-visualization-api.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/google-visualization-api/640f9cb3-bed0-4f88-85d3-64df4df1ca96%40googlegroups.com
>>> <https://groups.google.com/d/msgid/google-visualization-api/640f9cb3-bed0-4f88-85d3-64df4df1ca96%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
>> dlali...@google.com   5CC, Cambridge MA
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-visualization-api+unsubscr...@googlegroups.com.
> To post to this group, send email to
> google-visualization-api@googlegroups.com.
> Visit this group at
> https://groups.google.com/group/google-visualization-api.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-visualization-api/1aea31e3-8905-412a-8df4-123c6ec82f82%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/1aea31e3-8905-412a-8df4-123c6ec82f82%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
dlalibe...@google.com <dlalibe...@google.com>   5CC, Cambridge MA

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJMRaiFEip8R7RE-5eX%2BrdF_%3D_U_hzCR-yuN%2Brgn6ZmG8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to