-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Starting a discussion for a wrapper proposal for V2 dashboard creating and updating:
https://api.plot.ly/v2/dashboards#create
I'm not aware of any formal dashboard JSON spec documentation, but this dashboard is almost exhaustive in its options usage:
https://plot.ly/dashboard/jackluo:430/view
JSON: https://plot.ly/dashboard/jackluo:430/view.json
The only thing that it is missing is a table (an embedded plotly grid), which this dashboard has:
https://plot.ly/dashboard/jackp:16818
https://plot.ly/dashboard/jackp:16818.json
All of the options for styling embedded plotly grids (through URL query parameters) are here:
http://help.plot.ly/add-a-table-to-spectacle-editor/
Creating a dashboard
create_dashboard()
This call to create_dashboard would create the first 2 rows of this dashboard, plus a 3rd row with a table and a markdown cell:
https://plot.ly/dashboard/jackluo:430/view
# First row has 1 graph
row1 = list( dict( type='plot', url='https://plot.ly/~jackluo/400' ) )
# Second row has 2 graphs
# These dashboard cells have titles
row2 = list(
dict( type='plot', url='https://plot.ly/~jackluo/402',
title='Average rotor diameter by manufacturer' ),
dict( type='plot', url='https://plot.ly/~jackluo/404',
title='Number of turbines by manufacturer' ) )
markdown_text = ""## Jack Luo | Plotly\n\nDownload original dataset here: \nhttp://www.nature.com/articles/sdata201560\n"
table = dict(
type = 'table',
url = 'https://plot.ly/~datasets/2798',
show_row_numbers = False,
text_transform = 'uppercase',
header_font_weight = 300,
header_background = '%23ab63fa'
)
# Third row has 1 table and 1 text box
# All table styling options are here: http://help.plot.ly/add-a-table-to-spectacle-editor/
row3 = list(
table,
dict( type='text', text=markdown_text ),
)
dashboard = dict(
rows = list( row1, row2, row3 ),
foreground_color = "#cccccc",
box_background_color = "#020202",
links = [ { "url": "http://www.nature.com/articles/sdata201560",
"title": "| Download dataset here" } ],
title = "US Wind Turbine Dataset",
box_border_color = "#020202",
header_foreground_color = "#cccccc",
header_background_color = "#151515",
background_color = "#151515",
logo_url = "https://astrogeology.usgs.gov/images/usgs_logo_main_2x.png",
box_header_background_color = "#020202"
)
dashboard_url = create_dashboard( dashboard )
Updating a dashboard's top-level attributes
update_dashboard()
Rewrite a top-level attribute of the dashboard (ie something in the "settings" key of https://plot.ly/dashboard/jackluo:430/view.json)
new_links = list(
dict( url = "http://www.nature.com/articles/sdata201560",
title = "| Download dataset here" ),
dict( url = "#", title = "Last updated " + datetime_string ) )
update = dict( links = new_links )
update_dashboard( dashboard_url, update )
Appending or updating a dashboard row
update_dashboard_row()
Update or append one row at a time by passing the row index and
new_row = list(
dict( type='plot', url='https://plot.ly/~jackluo/423',
title='Blade Length' ),
dict( type='plot', url='https://plot.ly/~jackluo/425',
title='Rotor Density' ) )
# Rewrite the first row of the dashboard
update_dashboard_row( new_row, 1 )
# Append a new row to the dashboard
update_dashboard_row( new_row )
cc @charleyferrari @cldougl @theengineear @Kully @thejackluo @chriddyp
This was the simplest, no-frills API that I could think of, but there are probably better ways. 👍 if you think this looks good or chime in below to suggest some alternate proposals.
📉 📊 📈
🔢 📈 📊
📉 📊 🔢