Html code for plot chart

how can write the html code for plot the chart or graph .
I used this code …but it’s not working.

script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"</script>
  script 
setChartLibrary("google-chart");
        setChartTitle("Temp_in");
        setChartType("lineGraph");
        setAxisName("Time","Temperature");
        plotChart("time_stamp","temp_in");
script

https://cloud.boltiot.com/static/js/boltCommands.js does not have the functions that you are trying to call.

Bolt Cloud has predefined functions that uses setChartLibrary, setChartTitle.

To use them, you have to directly save the file in .js format.

plotChart() is a function that is defined in https://cloud.boltiot.com/static/js/boltGraph-2.0.0.js But don’t try to use that too. It won’t give you any response.

Correct way is -

setChartLibrary(“google-chart”);
setChartTitle(“Temp_in”);
setChartType(“lineGraph”);
setAxisName(“Time”,“Temperature”);
plotChart(“time_stamp”,“temp_in”);

And save the file as in javascript extension to use the functions.

I have made a custom gauge graph without google-chart as a project. You can see over here - Solid and Angular Gauge (custom) with Bolt Data

But I need to write the code for html extension…so how can I write.

It will not function if you write in html extension.

When you save in HTML format, you are creating an html file itself. Similar to the COFFEESHOP sample from the course.

When you save in .js format, you see the an html page that was already written on the bolt cloud, and only the JS script you saved is called in that. It takes inputs from other JS scripts that has google chart libraries present.

Bolt Cloud has the script https://www.gstatic.com/charts/loader.js running on the server when you save it in JS format. It has to be first initialised, formats and parameters are set. Only then we get to use a readymade functions like setChartLibrary, setChartTitle.

1 Like