Charts don't have attribute 'ref'

Trying to get either the html code or web components from charts like this:

y = [randint(0,100) for x in range(100)]
date_list = [base - timedelta(days=x) for x in range(100)]
file_html(TimeSeries(y, index=date_list, title=‘TS’, ylabel=‘values’, filename=‘ts_test.html’), CDN, “ts chart”)

``

gives me this error:

AttributeError: ‘TimeSeries’ object has no attribute ‘ref’

``

Is there anything simpler than what is suggested here:

Thanks, Mat

Hi Mat,

At the moment there are open discussions about how to address this and some other issues regarding the current Charts design.

I’ve actually had some more thought about this and actually there is a way a bit simpler to make it works (comparing to the answer you linked). As you want to simple embed you chart you can call if without any of the output (filename, server or notebook) arguments and call show. This will make chart build it’s underlying plot object (which is what you need to pass to file_html). Here’s a working version of your code:

from datetime import timedelta
base = datetime.datetime.now()
y = [randint(0,100) for x in range(100)]
date_list = [base - timedelta(days=x) for x in range(100)]
ts = TimeSeries(y, index=date_list, title=‘TS’, ylabel=‘values’)
ts.show()
fh = file_html(ts.chart.plot, CDN, “ts chart”)
print fh

``

Cheers

Fabio

···

On Friday, January 9, 2015 at 6:45:17 AM UTC+1, Mathieu Drapeau wrote:

Trying to get either the html code or web components from charts like this:

y = [randint(0,100) for x in range(100)]
date_list = [base - timedelta(days=x) for x in range(100)]
file_html(TimeSeries(y, index=date_list, title=‘TS’, ylabel=‘values’, filename=‘ts_test.html’), CDN, “ts chart”)

``

gives me this error:

AttributeError: ‘TimeSeries’ object has no attribute ‘ref’

``

Is there anything simpler than what is suggested here:

http://stackoverflow.com/questions/27051734/bokeh-python-cannot-get-html-source-for-bar-plots-in-bokeh

Thanks, Mat