Go Down

Topic: ThingSpeak Live Chart, multi channel, second axis, historical data, csv export (Read 35118 times) previous topic - next topic


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



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


Can someone tell me how can I manually chose the colour for new graphs?
I am wondering the same thing. Anyone know where the line colors are set?


Aprox 3-4 months this script do not update automaticly, just if I reload a browser. I tried Chrome, Firefox..but same.
In developer option of browser I see that it really updateing every 15second but I got error code:

Request URL:https://www.thingspeak.com/channels/579443/feed/last.json?callback=jQuery31105319498312513714_1559958872281&offset=0&location=false;key=xxxxxxxxxxxxxxxxx&_=xxxxxxxxxxxxxxx
Request method:GET
Remote address:
Status code:

So error code 301 Moved Permanently. I read on google that it means that some links are not accessable any more.
Can someone fix this?


If I am not wrong it mean that original code used http instead of https that now is mandatory.


If I am not wrong it mean that original code used http instead of https that now is mandatory.
Thx for replay..
All thingspeak links in codes are with https.
Do u have any other suggestion?


Sorry, I wrote a complete useless response!

I tested both the original page and the modified one by Mr_ToR.
You are right, it didn't update but I get this error
net::ERR_ABORTED 422 (Unprocessable Entity)

Code: [Select]
GET https://thingspeak.com/channels/9354/feed/last.json?callback=jQuery191003508808604683611_1560321345885&offset=0&location=false;key=XXXXXXXXXXXXXXXX&_=1560321345892 net::ERR_ABORTED 422 (Unprocessable Entity)

Unfortunately I am not able to spot the error that should be in this line

Code: [Select]
$.getJSON('https://www.thingspeak.com/channels/'+channelKeys[channelIndex].channelNumber+'/feed/last.json?callback=?&offset=0&location=false;key='+channelKeys[channelIndex].key, function(data)

after last.json since till json I get the last data. My suspect is on the callback.


True..I realised the same. But is tehre anyone who can give us advise or change those few lines of code to work again?
Btw I getting two error messages:
Status code: 422 Unprocessable Entity
Status code: 301 Moved Permanently


Btw..I asked the same question on thingspeak thread and I got explanation that "Callback Parameter Deprecated" is from now deprecated. Look at link:
The post number 9.
He even mentioned link for cahnges at:


Ok, it seams to be that I have enough knowledge to fix. :)
I realised with help of:
with R2019a and their explanation:
Code: [Select]
Callback Parameter Deprecated

    JSONP is no longer supported by the ThingSpeak API.

    If your code uses the callback parameter in a request to api.thingspeak.com, remove callback=? from the URL.

    For private channels, provide the read API key as part of the URL (for example ?api_key=READ_API_KEY). Public channels do not require an API key.

    For more information, see https://community.thingspeak.com/forum/announcements/jsonp-requests-callback-parameter-are-deprecated/#p8653.

that u need to modify next lines in this script from top of page:
line: 93,149 and 378
and to remove
Code: [Select]
 from line as to replace
Code: [Select]
Code: [Select]
Before (line 93):
Code: [Select]
$.getJSON('https://www.thingspeak.com/channels/'+channelNumber+'/feed.json?callback=?&offset=0&results=2500;key='+key, function(data)
After (line 93):  
Code: [Select]
$.getJSON('https://api.thingspeak.com/channels/'+channelNumber+'/feed.json?&offset=0&results=2500;key='+key, function(data)

Repeat for all of three line. I realised that second line giving the error 301 and first 422


Well done!
So callback is related to error 422 and www to error 301!

I made the same changes and don't get errors any more.


PS. Take care that the read API is in clear text on the source HTML page.


Hello everyone,

Has anyone managed to use the code as a Plugin that is displayed in Channel view?

For me there is no data loaded when I am using it as a Plugin in Channel view on ThingSpeak.com
I can only get data to load as a standard .html file loaded in a browser.

Go Up