ThingSpeak Live Chart, multi channel, second axis, historical data, csv export

Here is a HTML JavaScript web page to display multiple series and channels in real time.

You must edit the page source/ JavaScript to enter your channel information.

If you have lots of series, it is helpful to click the “Hide All” button, and then click on the series names you are interested in to show them. Clicking and dragging vertically on the chart will select a range to zoom in to.

Check the “Update Chart” checkbox to enable realtime charting. With more than about 8 channels, this causes ThingSpeak to cache and delay the data, so I have it unchecked.

It also features buttons to load historical data 8000 points at a time. Select which channel you want to load, and how many sequential loads to try. Then click the “Load More Historical Data” button. Loading too much data causes ThingSpeak to first delay the data, and then (error 404) refuse to return data. After ten loads or so, I often cannot load any more data.

The three bars export button at the top right has an option to download a .csv file containing the data from the chart.

This is public domain. Please edit it to access other Internet of Things data services. Please post upgrades here.

The charting library is called HighStock. It is awesome! HighSoft, the owners say, "Do you want to use Highstock for a personal or non-profit project? Then you can use Highchcarts for free under the Creative Commons Attribution-NonCommercial 3.0 License. "

ThingSpeakMultichannel.html (19.2 KB)

Are you awae of a tutorial in interfacing Arduino to HighStock ?

Perhaps I should describe how I use this live chart. I have an Arduino Mega that collects data from Dallas temperature sensors, DHT22 humidity sensors, a light sensor, flow meters, and a hall effect RPM counter. It has an ethernet shield and sends the data to a free cloud data service called ThingSpeak I can then access the data from anywhere in the world with a browser. Thingspeak comes with a primitive live chart, but it doesn't plot multiple series, etc. I programmed the javascript Multichannel HTML webpage to do better data analysis. A large part of the effort was learning how to use the HishStock library with HighSoft's excellent API reference ( I shared Multichannel so others in the Arduino community don't have to learn HighStock. My Multichannel page is hosted on a server, so I can access it from anywhere, though I could load the page into my browser off my hard drive.

Perhaps you could ask a more specific question about which aspect of this project your interested in?

At the risk of asking too much it would be of great assistance to a lot of readers of this post if you could briefly describe in list form the steps to be mastered to produce graphs like your excellent example. Perhaps something that would show how to plot data from say two analog inputs, for the enlightenment of all. Regards

Wow turgo, this is amazingly cool. 8) I'm adapting it for a few projects of mine. OK if I post it into github and then do modifications from there? I'll add some examples of making changes. I'm finding a few issues, but this is a great bit of JS, though not perfect (for those people in search of the holy grail) way cool. thanks for sharing it

Hi neil,

It would be great if you improved it and posted it to github. Be sure to put a link here also.

This was my first javaScript project, so I'm interested to see how an experienced JS programmer improves it.

hi turgo, great splash with JS I'm actually a newbie @ JS as well, and finding my way through all the amazing JS stuff to be able to display basic data.

I've posted your version here It can be forked and other people can add comments. Github being an amazing place to share code. For anybody looking to see what it takes to modify turgo's KS At the above github reference click/step into "ThingSpeakMultichannel001.html" then press the "Blame" button and the new window will show the modifications by line number in light yellow "b8238f46 »" For any 3rd person to make modifications, copy ThingSpeakMultichannel001.html into a file of your own, and then from the line numbers shown in the "Blame" view make the modifications in your file.

For the hell of it I've also put it up here where it runs on the web however it seems like there isn't a way of sharing it. If it can find away of sharing it, it would be easy for anyone to make small changes to - add their channel numbers and fields - and see what happens, no website needed. Neil

This is great, appreciate all the effort and making available to the rest of us. I have been able to get this to work fine with my data from ThingSpeak. I was wondering if there is a way to change the type of chart or way of displaying the information? I am using the spline chart type in ThingSpeak and would like to see something similar with the highcharts. I am new at this and tried to see an option in the code, but could not. Thanks!

It will take some effort for you to learn how to use the Highstock library. The website is: The demo's page shows all the types of charts Highstock supports:

To make my chart display splines, change line 310, which is a commented out line, to:

type: 'spline',

I noticed that spline slows the display down considerably with a large data set.

Much appreciated! Thats exactly what I wanted to know. And so, that can be changed to any of the chart types (area, bar, column, etc).

And, yes... all this takes lots of effort ! :astonished: It's always easier with some help though.

Please help with plugin, where i need insert data, and what ? HTML, CSS, JavaScript ? If possible post separated code HTML, CSS, JavaScript. Thanks.

Turgo, thank you so much for figuring out the java script and the charts api. This is exactly the help I needed. I appreciate your help with this.

Sincerely, halciber

Is there an easy way to add additional data to the chart, but in "column" format? And is it possible to have more than two different y-axis (for temperature, pressure, humidity, ...)?

How could this be achieved?

Thank you very much for this fantastic work!!

There´s a very little mistake in:
tooltip: {
valueDecimals: 1,
valueSuffix: ‘°F’,
%1:%M:%S %p’ <----- the %1 should be replaced by %H

I have modified your web page for my project, and one problem I have is that I didn´t find a way of modifying the valueSuffix for different series. Could you please help me? Thanks in advance.

Hi Turgo, thanks heaps for this. I struggled with Highcharts before admitting defeat, so it's a great help to have your code.

Can I add to the request for multiple tooltip suffixes - so that the tip displays units for the relevant axis.

Also do you think it would be straightforward to scale the two axes differently? I know from Highcharts that there are floor and ceiling values that you can include in the formatting code.

best wishes, Andrew

Dear Turgo, (or anyone else)

Could you please help how to define different units for tooltip valueSuffix when multiple series are used? Right now in your code everything shows up as temperature. I can get it to work in Highcharts examples but non of them includes values being used from Thingspeak since i'm having a bit of a problem understanding how you got thingspeak data to appear in chart. I'm not very good with javascript :-) The 'series' show like the following in the highcharts example, however the series part in your code is just 'series: []' so i can not figure out where to include that tooltip valueSuffix per series.

series: [{ name: 'Rainfall', type: 'column', yAxis: 1, data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], tooltip: { valueSuffix: ' mm' }

}, { name: 'Sea-Level Pressure', type: 'spline', yAxis: 2, data: [1016, 1016, 1015.9, 1015.5, 1012.3, 1009.5, 1009.6, 1010.2, 1013.1, 1016.9, 1018.2, 1016.7], marker: { enabled: false }, dashStyle: 'shortdot', tooltip: { valueSuffix: ' mb' }

}, { name: 'Temperature', type: 'spline', data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6], tooltip: { valueSuffix: ' °C' }

OK disregard my last message because i got it to work here is the working code

however there is only one problem i just can not get the 'opposite: true' to work for one of the 'yAxis:' data. So both of the Y axises appear on the right side. I just need to get one of the axises appear on the opposite side. Please someone help :-)

ok, disregard the last one as well :-) somehow the code works differently here, i tried 'opposite: false' instead of 'opposite: true' and it worked. apparently all y-axis are 'opposite: true' by default in Turgo's code somehow. so anyone is free to check it out there :-) good luck :D

A very big thanks!!! It works our of the box :D

Can someone tell me how can I manually chose the colour for new graphs? Thx