Last active
August 29, 2015 14:06
-
-
Save xor-xor/405e8667c6b44bcb2c79 to your computer and use it in GitHub Desktop.
example for line_chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import requests | |
API_KEY = 'xxx' | |
API_URL = 'http://127.0.0.1:7272/api/v0.1/{}'.format(API_KEY) | |
API_URL_PUSH = '/'.join((API_URL, 'push')) | |
API_URL_TILECONFIG = '/'.join((API_URL, 'tileconfig')) | |
TILE_TEMPLATE = 'line_chart' | |
TILE_KEY = 'line_chart_test' | |
def main(): | |
# sending data | |
data = { | |
"subtitle": "subtitle", | |
"description": "description", | |
"series_list": [[["2014-09-16", 1000], ["2014-09-17", 0], ["2014-09-18", 1000]]], | |
} | |
data_jsoned = json.dumps(data) | |
data_to_push = { | |
'tile': TILE_TEMPLATE, | |
'key': TILE_KEY, | |
'data': data_jsoned, | |
} | |
resp = requests.post(API_URL_PUSH, data=data_to_push) | |
if resp.status_code != 200: | |
print(resp.text) | |
return | |
# sending config | |
tile_config = { | |
"seriesDefaults": { | |
"trendline": {"color": "white", "show": True} | |
} | |
} | |
tile_config_jsoned = json.dumps(tile_config) | |
data_to_push = { | |
'value': tile_config_jsoned, | |
} | |
resp = requests.post( | |
'/'.join((API_URL_TILECONFIG, TILE_KEY)), | |
data=data_to_push, | |
) | |
if resp.status_code != 200: | |
print(resp.text) | |
return | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
details: | |
page_title: Testing Dashboard | |
layout: | |
- row_1_of_2: | |
- col_1_of_2: | |
- tile_template: line_chart | |
tile_id: line_chart_test | |
title: xxx | |
classes: | |
- col_1_of_2: | |
- tile_template: empty | |
tile_id: empty | |
title: Empty Tile | |
classes: | |
- row_1_of_2: | |
- col_1_of_2: | |
- tile_template: empty | |
tile_id: empty | |
title: Empty Tile | |
classes: | |
- col_1_of_2: | |
- tile_template: empty | |
tile_id: empty | |
title: Empty Tile | |
classes: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment