Hi Daniel,
This works for me! thanks so much for your help! :)

On Friday, 27 December 2019 02:16:50 UTC+8, Daniel LaLiberte wrote:
>
> Hi Dyana,
>
> In the data that you generate, all the month data is actually strings, not 
> numbers, because you have added quotes.  
>
>   echo "['".$row['month']."',".$row['result_ind']."],";
>
> Remove the single quotes around the month values, so it will be:
>
>   echo "[".$row['month'].",".$row['result_ind']."],";
>
> Hope that helps.
>
> On Wed, Dec 25, 2019 at 11:10 PM dyana fadzil <[email protected] 
> <javascript:>> wrote:
>
>> Hi All,
>>
>> can help me teach and check on this google chart i have tried, seems the 
>> trendline is not showing when querying data from mysqli. The month and the 
>> result is both in integer format. Attached is the image of the chart and 
>> the trendline is not working. Can help me on this? i have been stuck here 
>> long time already.. 
>>
>> Thank you!
>>
>> my Coding part is like this:
>>
>>
>>
>>
>> <?php
>>    include ('connection.php');
>> ?>
>>
>>
>> <html>
>>    <head>
>>       <title>Google Charts Tutorial</title>
>>       <script type = "text/javascript" src = "
>> https://www.gstatic.com/charts/loader.js";>
>>       </script>
>>       <script type = "text/javascript" src = "
>> https://www.google.com/jsapi";>
>>       </script>
>>       <script type = "text/javascript">
>>          google.charts.load('current', {packages: ['corechart']});     
>>       </script>
>>    </head>
>>    
>>    <body>
>>       <div id = "container" style = "width: 550px; height: 400px; margin: 
>> 0 auto">
>>       </div>
>>       <script language = "JavaScript">
>>        function drawChart() {
>>       var data = google.visualization.arrayToDataTable([
>>          ['Month', 'Performance %'],
>>          <?php 
>>           $query = "SELECT month , result_ind FROM performance GROUP BY 
>> month";
>>
>>
>>           $exec = mysqli_query($db,$query);
>>           while($row = mysqli_fetch_assoc($exec)){
>>
>>
>>           echo "['".$row['month']."',".$row['result_ind']."],";
>>          }
>>         ?>
>>        ]);
>>
>>
>>                
>>             // Set chart options
>>             var options = {
>>                'title':'Month vs %',
>>                'width':550,
>>                'height':400,
>>                
>>                 trendlines: {
>>                 0: {
>>                 type: 'exponential',
>>                 color: 'green',
>>                 visibleInLegend: true,
>>       }
>>     }  // Draw a trendline for data series 0.
>>             };
>>
>>
>>             // Instantiate and draw the chart.
>>             var chart = new google.visualization.ScatterChart(document.
>> getElementById('container'));
>>             chart.draw(data, options);
>>          }
>>          google.charts.setOnLoadCallback(drawChart);
>>       </script>
>>    </body>
>> </html>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google Chart API" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-chart-api/f319de46-86dd-4c57-ba6a-f37a313ca182%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-chart-api/f319de46-86dd-4c57-ba6a-f37a313ca182%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
> [email protected] <javascript:>   Cambridge MA
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-chart-api/0322b478-b4da-4cc6-9a9e-55cbe93ec1ca%40googlegroups.com.

Reply via email to