You can use krisk for Declarative Visualization. You don't have to use krisk.plot
package, and directly use Chart
class to make any charts that are supported by ECharts.
In [1]:
# Use this when you want to nbconvert the notebook (used by nbviewer)
from krisk import init_notebook; init_notebook()
Out[1]:
In [4]:
from krisk import Chart
In [5]:
chart = Chart()
chart
Out[5]:
Here you see that there is a blank figure for chart that you want to use. You can inspect the characteristic of the chart by using its option
member.
In [11]:
chart.option
Out[11]:
As soon as Chart objects are build, the chart option will be using this minimum Python dictionary. This template will translate to JSON object that represent ECharts option.
Eventhough there is no visualization in the plot, you can still tweak other type of customization. Here is an example if you want to add a title and a theme to the figure.
In [6]:
chart.set_title('This is a blank visualization', x_pos='center')
chart.set_theme('vintage')
Out[6]:
There is no plot visualization since there is no data, but we can still customization like theme and title. This also benefit you for saving the figure later to be used as a basis for other plots.
With minimal effort, you can insert all type of charts. Here below we change x-axis name for each of the bar. The value of every bar is what we want to insert as a series
data.
In [7]:
chart.option['series'] = [{'data': [10, 3, 7, 4, 5], 'name': 'continent', 'type': 'bar'}]
chart.option['xAxis'] = {'data': ['Americas', 'Asia', 'Africa', 'Oceania', 'Europe']}
chart
Out[7]:
There is so much more you can do with declarative visualization, as krisk only acts as a thin wrapper on top of ECharts when used without krisk.plot
. For all complex customization that you can do with the ECharts option, you can head over to http://echarts.baidu.com/option.html