Leftronic Data Format

Each type of customizable widget expects JSON data in a particular format, as specified below.

Number, Horizontal/Vertical Bars, Dial, Sparkline, and Line Graph Widgets:

You can supply a number in the following format. The data are automatically timestamped with the time at which we receive the data (relevant for sparklines and line graphs).

{"number": 120}

Optionally, you can include a prefix, suffix, and/or timestamp (in seconds since the Unix epoch).

{"prefix": "$", "number": 33}
{"suffix": "%", "number": 110, "timestamp": 1455083491}

For sparkline/line graph widgets:

{"timestamp": 1329205474, "number": 11}
{"timestamp": 1319585517, "number": 4302, "suffix": "MB/s"}

You can send a “delta” instead of a “number” key. For example, if tracking revenue, you can just send the incremental dollar amounts and we will modify the number accordingly:

{"prefix": "$", "delta": 299}

The above example will add $299 to the most recent value in the number stream. The number stream must already have an initial value in it. When sending deltas, there is a small chance the push will get rejected if you are sending many deltas very quickly. In that case, our API will not return “Success!” but an error message instead. You should monitor the return value and try the delta again if it failed.

USA Map and World Map Widgets:

{"latitude": 37.8, "longitude": -122.6}

Optionally, add custom text that will appear on hover, and choose a color for your map point (red, blue, green, purple, and yellow only):

{"latitude": 37.8, "longitude": -122.6, "color": "blue", "title": "title text", "body": "body text"}

Text Feed Widgets:

{"title": "myTitle", "msg": "myMsg", "imgUrl": "http://goo.gl/uqHsk", "date": "Jan 4, 2015"}

Leaderboard Widgets:

Leaderboards take a list of dictionaries, each dictionary containing a name and a value. The value must be a number.

{"leaderboard": [{"name": "Cheryl", "value": 57}, {"name": "Megan", "value": 32}, {"name": "Marisa", "value": 23}, {"name": "Frankie", "value": 11}, {"name": "Keeley", "value": 7}, {"name": "Kristen", "value": 3}, {"name": "Kelly", "value": 3}]}

You can also optionally add a prefix or suffix key to the value:

{"leaderboard": [{"name": "Cheryl", "value": 57, "prefix": "$"}, {"name": "Megan", "value": 15, "prefix": "$"}]}

You can push a single leaderboard item at a time instead of the whole leaderboard. If you push in an item with a name that already exists on the leaderboard, it will replace it. Use the leaderboardItem key as follows:

{"leaderboardItem": {"name": "Cesar", "value": 1962}}

Pie Chart Widgets:

Pie charts follow essentially the same format as the leaderboard widgets:

{"chart": [{"name": "Cheryl", "value": 57}, {"name": "Megan", "value": 32}, {"name": "Marisa", "value": 23}, {"name": "Frankie", "value": 11}, {"name": "Keeley", "value": 7}, {"name": "Kristen", "value": 3}, {"name": "Kelly", "value": 3}]}

You can also optionally add a prefix or suffix key to the value:

{"chart": [{"name": "Cheryl", "value": 57, "prefix": "$"}, {"name": "Megan", "value": 15, "prefix": "$"}]}

List Widgets:

{"list": [{"listItem": "Cheryl"}, {"listItem": "Megan"}, {"listItem": "Marisa"}, {"listItem": "Frankie"}, {"listItem": "Keeley"}, {"listItem": "Kristen"}, {"listItem": "Kelly"}]}

You can optionally push in a single List Item at a time, which will push this item to the top of an existing list:

{"listItem": "Kim", "date": "Feb 15, 2016"}

Bar Chart Widgets:

Bar charts follow essentially the same format as the leaderboard widgets:

{"chart": [{"name": "Cheryl", "value": 57}, {"name": "Megan", "value": 32}, {"name": "Marisa", "value": 23}, {"name": "Frankie", "value": 11}, {"name": "Keeley", "value": 7}, {"name": "Kristen", "value": 3}, {"name": "Kelly", "value": 3}]}

You can also optionally add a color key to the value:

{"chart": [{"name": "Cheryl", "value": 57, "color": "yellow"}, {"name": "Megan", "value": 15, "color": "red"}]}

Image Widgets:

This takes a URL to an image to be displayed.

{"imgUrl": "http://goo.gl/uqHsk"}

Label Widgets:

The labels are bare text, which can be useful for displaying titles or other identifiers on the dashboard.

{"label": "Battlecruiser operational"}

XY (scatter plot) Widgets:

{"x": 15, "y": 83}

Table Widgets:

The table is a list of lists, where the first list is the header row, and each of the following lists is a row in the table.

{"table": [ ["header1", "header2", "header3"], ["R1C1", "R1C2", "R1C3"], ["R2C1", "R2C2", "R2C3"], ["R3C1", "R3C2", "R3C3"] ]}

You can optionally push a single table row at a time. This will insert the row at the top of an existing table as follows:

{"tableRow": ["Col 1 value", "Col 2 value", "Col 3 value"]}

Gallery Widgets:

The “msg” parameter is optional. Note: The gallery widget API is compatible with the text feed API.

{"title": "myTitle", "msg": "myMsg", "imgUrl": "http://goo.gl/uqHsk"}

HTML Widgets:

This can be used to push arbitrary HTML onto your dashboard. Use CSS and JavaScript in this at your own risk, as doing so could disrupt the functionality of the dashboard.

{"html": "<pre>
<h3>Hello world!</h3>
</pre>
"}

Multi-Bar Widgets:

This can be used to push multi-bar data onto your dashboard. This format is similar to the table widget format; in that the data is an array of arrays. Each sub-array represents a bar in the bar chart, and is preceded by the name for that bar. The first row’s column headers will each correspond to a segment in a bar, after the first header, which is unused.

{"matrix":[["Years","Barcelona","Real Madrid","Atlético"],["2010",95,102,62],["2011",114,121,53],["2012",115,103,65],["2013",100,104,77]]}

Note that the first element of the first array is not displayed and you can use an empty string if desired.