Charts

The Charts API allows you to create an instant visualization of your data. The chart displays properly in all modern browsers and mobile devices. The chart can also show dynamic data by loading new data automatically.

Use the Charts API to present numerical data stored in ThingSpeak Channels on charts. Supported chart types are line, bar, column, spline, and step. Options include size, color, and labels.


Creating a Chart

To create a chart, open the following URL, replacing CHANNEL_ID and FIELD_ID with values from one of your Channels.

http://api.thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID

Valid chart parameters:
  • title (string) Chart title, default: Channel name (optional)
  • xaxis (string) Chart's x-axis label, default: "Date" (optional)
  • yaxis (string) Chart's y-axis label, default: field name (optional)
  • color (string) Line color, default: red (optional)
  • bgcolor (string) Background color, default: white (optional)
  • type (line/bar/column/spline) Type of chart, default: line (optional)
  • width (integer) Chart width in pixels, iframe width will be 20px larger, default chart width: 400. Set to auto to automatically adjust chart size based on its parent container. (optional)
  • height (integer) Chart height in pixels, iframe height will be 20px larger, default chart height: 200. Set to auto to automatically adjust chart size based on its parent container. (optional)
  • dynamic (true/false) Make chart update automatically every 15 seconds, default: false (optional)
  • step (true/false) Draw chart as a step chart, default: false (optional)
  • export (true/false) Show export buttons, so that chart can be saved as an image, default: false (optional)
  • yaxismin (decimal) Minimum value of chart's Y-Axis; if blank the value is auto-calculated (optional)
  • yaxismax (decimal) Maximum value of chart's Y-Axis; if blank the value is auto-calculated (optional)

Valid feed parameters:
  • api_key (string) Read API Key for this specific Channel (optional--no key required for public channels)
  • results (integer) Number of entries to retrieve, 8000 max, default of 100 (optional)
  • days (integer) Number of 24-hour periods before now to include in feed (optional)
  • start (datetime) Start date in format YYYY-MM-DD%20HH:NN:SS (optional)
  • end (datetime) End date in format YYYY-MM-DD%20HH:NN:SS (optional)
  • timezone (string) Timezone identifier for this request (optional)
  • offset (integer) Timezone offset that results should be displayed in. Please use the timezone parameter for greater accuracy. (optional)
  • status (true/false) Include status updates in feed by setting "status=true" (optional)
  • location (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)
  • min (decimal) Minimum value to include in response (optional)
  • max (decimal) Maximum value to include in response (optional)
  • round (integer) Round to this many decimal places (optional)
  • timescale (integer or string) Get first value in this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • sum (integer or string) Get sum of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • average (integer or string) Get average of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • median (integer or string) Get median of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
Please note that the results parameter is not compatible with timescale, sum, average, or median.



Embedding a Chart

To place a ThingSpeak Chart on your webpage, use the Chart API as the source of an iframe.

Chart Embed Code:

<iframe width="450" height="250" style="border: 1px solid #cccccc;" src="http://thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID"></iframe>


Example Chart:

Embedding a Dynamic Chart

To place a dynamic ThingSpeak Chart on your webpage, use the Chart API as the source of an iframe and add the chart parameter ”dynamic=true”.

Chart Embed Code:

<iframe width="450" height="250" style="border: 1px solid #cccccc;" src="http://thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID?dynamic=true"></iframe>


Example Chart: