Scaling values | ThingSpeak API | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.

Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Scaling values
No permission to create posts
April 18, 2011
2:51 pm
New Member
Forum Posts: 1
Member Since:
April 18, 2011
sp_UserOfflineSmall Offline

Working with engineers and non-engineers I have to convert between metric and standard (US units) a lot.  I adopted as a general rule that I store all my data in metric - so I send my data to ThingSpeak in metric.  But this is not necessary how I want to display them.  I was wondering if you could have two float values with each chart - a scale and an offset.  The display value would be scale * database_value + offset.  If I do not want to use it, than the default values should be scale = 1 and offset = 0.  For converting deg C to deg F I set scale to 1.8 and offset to 32.  For % I set scale to 100 and offset to 0.  I would need this for each chart (so I would like to pass this as an argument when I create the chart (just like timescale=10).  SO I could actually show deg C and deg F on the same page!

April 18, 2011
3:21 pm

Forum Posts: 457
Member Since:
March 14, 2011
sp_UserOfflineSmall Offline

This is a very specific request, would you be able to do it in JavaScript instead?


Here's how you would do it, using the code from our homepage as an example:



The first step is copying both <script> tags completely into your page.  You'll also want to add the container for the chart:

<div id="chart-container" style="width: 500px; height: 260px; padding-left: 20px; float: left;"></div>

Then use your channel's id (instead of 9) in the line that begins with:


Looking at the line that says:

chartData.push([getChartDate(this.created_at), parseFloat(p)]);

This needs to be changed to:

chartData.push([getChartDate(this.created_at), 1.8*parseFloat(p)+32]);


That should do it for you, if you need more help tell me your channel id and I'll write the complete example for you.


April 18, 2011
8:39 pm
Natick, MA

Forum Posts: 411
Member Since:
January 18, 2011
sp_UserOfflineSmall Offline

BTW. You can put Lee's example inside of a Plugin, so you don't have to have this running external to ThingSpeak. Good luck and let us know how it turns out.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
31 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457