Re: [visualization-api] Load google charts from external JS file

2018-06-12 Thread Ella Sherilyn Ramos
this works, thank you!

On Friday, June 8, 2018 at 10:11:44 PM UTC+8, Daniel LaLiberte wrote:
>
> You need to change google.setOnLoadCallback to google.*charts*
> .setOnLoadCallback.
>
> On Thu, Jun 7, 2018 at 11:29 PM Ella Sherilyn Ramos <
> ella.sher...@gmail.com > wrote:
>
>> I am having trouble displaying google charts from an external JS script, 
>> inline script on my HTML works. 
>>
>> I called the loader on the  of my HTML file.
>>
>> 
>>
>>
>> https://www.gstatic.com/charts/loader.js";>
>>
>>
>>
>> 
>>
>> And then I have an external JS file (app.js) being loaded as well on my 
>> HTML file. This is the content. 
>>
>> $(function() {
>>   google.charts.load('current', {packages: ['corechart']});
>>   google.setOnLoadCallback(drawLineChart);
>>
>>
>>   function drawLineChart(values, labels){
>>   // Define the chart to be drawn.
>> var data = new google.visualization.DataTable();
>>
>>
>>
>>
>> var speed = values.speed;
>> var soc = values.soc;
>> var dataArray = [];
>>
>>
>> for (i=0;i>   var tempArray = []
>>   tempArray.push(new Date(labels[i]))
>>   tempArray.push(speed[i])
>>   tempArray.push(soc[i])
>>   dataArray.push(tempArray)
>> }
>>
>>
>> console.log(dataArray);
>> data.addColumn('datetime', 'Time of Day');
>> data.addColumn('number', 'Speed');
>> data.addColumn('number', 'SOC');
>> data.addRows(dataArray);
>>
>>
>> var options  = {
>>   legend: { position: 'top', maxLines: 3 }
>> }
>>
>>
>> // Instantiate and draw the chart.
>> var chart = new google.visualization.LineChart(document.
>> getElementById("lineChart"));
>> console.log("chart: ", chart);
>> chart.draw(data, options);
>> }
>>
>> });
>>
>>
>> It gives me this error.
>>
>> jQuery.Deferred exception: google.setOnLoadCallback is not a function 
>> TypeError: google.setOnLoadCallback is not a function
>>
>> Any idea how to load it properly? 
>>
>> Thank you. 
>>
>>   
>>
>> -- 
>> 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/ebd21b81-4fa4-4ae4-8b4c-cc3d0bb7690d%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Daniel LaLiberte 
> dlali...@google.com5CC, 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/fde57497-dbaa-4d1e-84f1-cadebd185453%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [visualization-api] Load google charts from external JS file

2018-06-08 Thread 'Daniel LaLiberte' via Google Visualization API
You need to change google.setOnLoadCallback to google.*charts*
.setOnLoadCallback.

On Thu, Jun 7, 2018 at 11:29 PM Ella Sherilyn Ramos <
ella.sherilyn.ra...@gmail.com> wrote:

> I am having trouble displaying google charts from an external JS script,
> inline script on my HTML works.
>
> I called the loader on the  of my HTML file.
>
> 
>
>
> https://www.gstatic.com/charts/loader.js";>
>
>
>
> 
>
> And then I have an external JS file (app.js) being loaded as well on my
> HTML file. This is the content.
>
> $(function() {
>   google.charts.load('current', {packages: ['corechart']});
>   google.setOnLoadCallback(drawLineChart);
>
>
>   function drawLineChart(values, labels){
>   // Define the chart to be drawn.
> var data = new google.visualization.DataTable();
>
>
>
>
> var speed = values.speed;
> var soc = values.soc;
> var dataArray = [];
>
>
> for (i=0;i   var tempArray = []
>   tempArray.push(new Date(labels[i]))
>   tempArray.push(speed[i])
>   tempArray.push(soc[i])
>   dataArray.push(tempArray)
> }
>
>
> console.log(dataArray);
> data.addColumn('datetime', 'Time of Day');
> data.addColumn('number', 'Speed');
> data.addColumn('number', 'SOC');
> data.addRows(dataArray);
>
>
> var options  = {
>   legend: { position: 'top', maxLines: 3 }
> }
>
>
> // Instantiate and draw the chart.
> var chart = new google.visualization.LineChart(document.getElementById
> ("lineChart"));
> console.log("chart: ", chart);
> chart.draw(data, options);
> }
>
> });
>
>
> It gives me this error.
>
> jQuery.Deferred exception: google.setOnLoadCallback is not a function
> TypeError: google.setOnLoadCallback is not a function
>
> Any idea how to load it properly?
>
> Thank you.
>
>
>
> --
> 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/ebd21b81-4fa4-4ae4-8b4c-cc3d0bb7690d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Daniel LaLiberte 
dlalibe...@google.com5CC, 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/CAOtcSJMziKJyOygu8opvcrpfXifagQvsc2HcsxBLxcsRur_%2B0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.