public
Description: Example code and wiki pages for the Swivel API.
Home | Edit | New

Chart API Details

The Swivel chart data format

To chart data in Swivel, you need to follow two simple rules.

  1. Headers (dates, string labels) in the top row and first column
  2. Numbers in the middle (everywhere else)

Swivel understands a broad range of date and number formats. The most common Excel formats are supported, as well as some other typical technical formats. If you’re not sure if Swivel will understand a format, we encourage you to create a new spreadsheet and paste the data into the interface to see if Swivel gets it.

Chart create parameters

ParameterRequiredExample
dataN
data=date,visits
Jan-09,50
Feb-09,100
Mar-09,200
Apr-09,400
May-09,800
Jun-09,1600
The data for this chart.
descriptionN
description=Visitors to Site
The description of this chart.
group_idN
group_id=12345
The id of the group that you want to publish the chart to. If this parameter is not passed, it will default to your drafts group. Pass an empty group_id to publish the chart publicly.
nameN
name=Visits
The name of the chart. Appears in the browse interface.
optionsN
options={
 'format': {
  'axis.y.format': {
   'pfx': '',
   'c': true,
   'sfx': ''},
  'axis.y.range': {
   'from': 0,
   'to': 80285},
  'axis.x.format': {
   'p': -1,
   'ns': true,
   't': 'g'}}}
A set of options, stored in JSON, that describe the look and feel of the chart. To understand the options, it’s probably easiest to manually create the look and feel that you want in the web interface, do a GET to see what the saved JSON is, and then copy and modify the JSON from that chart as needed.

XML format of the HTTP response

<?xml version="1.0" encoding="UTF-8"?>
<chart>
  <created-at type="datetime">2009-05-15T17:41:20-07:00</created-at>
  <description nil="true"></description>
  <group-id type="integer">1</group-id>
  <id type="integer">CHART_ID</id>
  <name>Profit and Revenue</name>
  <options nil="true"></options>
  <person-id type="integer">1</person-id>
  <secret>zbNpCIOEZqqL7KtfRY8imA==</secret>
  <updated-at type="datetime">2009-05-15T17:41:20-07:00</updated-at>
</chart>
ParameterData type
created-atdatetime
When the chart was created.
descriptionstring
The description of the chart given by the chart creator.
group-idinteger
The id of the group that this chart is in. Public charts have a nil group id.
idinteger
The id of the chart. Use this id to access the chart in GET, PUT and DELETE queries.
namestring
The name for this chart that is displayed in the browsing interface.
optionsstring
A set of options, stored in JSON, that describe the look and feel of the chart. To understand the options, it’s probably easiest to manually create the look and feel that you want in the web interface, do a GET to see what the saved JSON is, and then copy and modify the JSON from that chart as needed.
person-idinteger
The id of the person who owns this chart.
secretstring
A random string that provides temporary (5 minute) anonymous access to the chart. A request to charts/1.xml?secret=secret will work for 5 minutes. Useful for embedding charts without providing a username and password. For longer-term embedding, you can use the embed code provided through the web interface.
updated-atdatetime
When the chart was updated.

Chart update parameters

Chart update parameters are the same as chart create parameters, with one additional option:

ParameterRequiredExample
modeN
mode=replace
mode=append
replace: Default. Removes existing data from the chart and replaces it with new data passed in the data parameter.
append: Adds new data, passed in the data, parameter to the bottom row of your data set.
Last edited by gerad, Fri Nov 06 15:58:08 -0800 2009
Home | Edit | New
Versions: