Inserting Table into Dashboard


#1

I am having trouble inserting a table into a dashboard. I am able to insert the table manually in the web interface, but not programmatically. I suspect that I am not specifying the ‘boxType’ correctly, but I have tried ‘plot’,‘text’ and ‘table’ to the same result.

Any help would be appreciated.

::::::CODE:::::

Using the fileId_from_url function from the documentation:

fileId_1 = fileId_from_url(url_1)

box_a={
‘type’: ‘box’,
‘boxType’: ‘plot’,
‘text’: fileId_1,
‘title’: ‘’
}

my_dboard.insert(box_a)
py.dashboard_ops.upload(my_dboard, page_id)


PlotlyRequestError Traceback (most recent call last)
in ()
64
65
—> 66 py.dashboard_ops.upload(my_dboard, page_id)

C:\ProgramData\Anaconda3\envs\social\lib\site-packages\plotly\plotly\plotly.pyc in upload(cls, dashboard, filename, sharing, auto_open)
1468
1469 except exceptions.PlotlyRequestError:
-> 1470 res = v2.dashboards.create(data)
1471 res.raise_for_status()
1472

C:\ProgramData\Anaconda3\envs\social\lib\site-packages\plotly\api\v2\dashboards.pyc in create(body)
15 “”“Create a dashboard.”""
16 url = build_url(RESOURCE)
—> 17 return request(‘post’, url, json=body)
18
19

C:\ProgramData\Anaconda3\envs\social\lib\site-packages\plotly\api\v2\utils.pyc in request(method, url, **kwargs)
151 content = response.content if response else 'No content’
152 raise exceptions.PlotlyRequestError(message, status_code, content)
–> 153 validate_response(response)
154 return response

C:\ProgramData\Anaconda3\envs\social\lib\site-packages\plotly\api\v2\utils.pyc in validate_response(response)
77 message = content if content else 'No Content’
78
—> 79 raise exceptions.PlotlyRequestError(message, status_code, content)
80
81

PlotlyRequestError: {u’direction’: u’vertical’, u’sizeUnit’: u’px’, u’second’: {u’type’: u’box’, u’boxType’: u’empty’}, u’size’: 750, u’type’: u’split’, u’first’: {u’type’: u’box’, u’text’: u’harbinger.ai:53’, u’boxType’: u’table’, u’title’: u’’}} is not valid under any of the given schemas

Failed validating ‘oneOf’ in schema[‘properties’][‘layout’]:
{‘oneOf’: [{‘type’: ‘null’}, {’$ref’: ‘#/definitions/container’}]}

On instance[‘layout’]:
{u’direction’: u’vertical’,
u’first’: {u’boxType’: u’table’,
u’text’: u’harbinger.ai:53’,
u’title’: u’’,
u’type’: u’box’},
u’second’: {u’boxType’: u’empty’, u’type’: u’box’},
u’size’: 750,
u’sizeUnit’: u’px’,
u’type’: u’split’}


#2

When I pull the box back down after updating online I get the ‘plot’ boxType.

recent_dboard = py.dashboard_ops.get_dashboard(‘36385509036’)
recent_dboard.get_box(1)

{u’boxType’: u’plot’,
u’fileId’: u’harbinger.ai:53’,
u’shareKey’: None,
u’title’: u’’,
u’type’: u’box’}


#3

There is both an error with the fileId_from_url function from the docs and your original code.

It looks like if your plot has a name that appears in the url after the number that identifies it, it is getting kept in the fileId, which should not be the case. For example, if https://plot.ly/~AdamKulidjian/104/scatterplot-matrix/ is a url, the file ID should be AdamKulidjian:104. We will update the docs to correct the function.

Also, you must assign the fileId to the fileId key in your box. It’s assigned to the text.


#4

Good news, the documentation has been fixed! Woohoo!

Check out the new url parsing function here: https://plot.ly/python/create-online-dashboard/#add-a-box


#5

Great! I’ll try it out tonight and give you an update.

Thanks for your help!


#6

Looks, great now. Thanks!