Free Echarts
Free eCharts a cornerstone feature. The catalog of Shimoku has now all the power of personalization of eCharts! The proposed usage is:
1) Visit
https://echarts.apache.org/examples/en/index.html#chart-type-line and pick a chart you want to plot, for instance https://echarts.apache.org/examples/en/editor.html?c=line-style
2) Play
in the eCharts console to tune it until you got precissely what you want. Add the data you want to the eCharts console to check out that everything works as you want.
3) Copy
the eCharts console code and paste it into your Python code as a string and use the raw_options
as input of s.plt.free_echarts()
4) É Voila!
This way of using the function assumes certain aspects of the charts being used, not all charts will work. When it does not work use the next method as it requires more information to be provided.
Note You cannot add eCharts functions such as from https://echarts.apache.org/examples/en/editor.html?c=line-aqi you must get rid of those for it to work!
You can also build it without copy pasting the data, just passing the rest of the options
from eCharts. Use options
and data
as input of s.plt.free_echarts()
As it can be seen in the previous example the position of the data has been defined inside the options of the chart by using #set_data#
in the desired locations. This will tell the SDK where it should put the data. In the function call the parameter fields is used to specify how the data should be unpacked in that location, in the previous example it will unpack each column as a list of values. These are the possible unpacking options:
Using this df as data: df = [{col1: val1, col2: val2}, {col1: val3, col2: val4}]
String: When passing an string the values will be unpacked as the list of values of that column:
Tuple: When passing a tuple it will unpack the values as a list of lists of the values in the df:
Dict: When passing a dictionary it will be unpacked as a list of dictionaries with the keys being the keys provided in the mapping, the columns inside of the values of the mapping can be mapped as lists too:
With these mapping options most of the charts in the echarts library can be codified with Shimoku using our own data/data set model, so the data doesn't need to be hard coded inside of the charts. This way filtering and aggregating is possible.
Trick
Use eCharts console https://echarts.apache.org/examples/en/index.html to prepare your chart and when you have what you want you can just copy paste it to the Free eCharts with raw input.
Last updated