Shimoku docs
  • 🚀QuickStart
    • Installation & Setup
    • Minimal APP example
    • Extended Example
    • Templates & tutorials
  • 🤖Artificial Intelligence
    • Classification
      • Train Classification
        • Train Classification Outputs
      • Predict Classification
        • Predict Classification Outputs
    • Generate Insights
      • Generate Insights Outputs
  • 🛠️Building Web App
    • Environment
      • Overview
      • Environment Variables
    • Management
      • Managing Universes
      • Managing Workspaces
      • Managing Boards
    • Menu
      • Changing the Menu Path
      • Updating the Menu Path
      • Deleting the Menu Path
    • Grid
      • Using the Grid
    • Theming
      • Colors Usage
    • Actions
    • Modals
    • IO
  • 💡Elements
    • Summary
    • Charts
      • Table
        • Buttons Column
        • Filters
        • Search bars
        • Colored labels
      • HTML
        • Raw HTML
        • Beautiful Titles
        • Background Indicators
        • Click to New Tab
        • Box With Button
        • Panel
      • Indicators
        • Indicator
        • Grouped Indicators
        • Vertical Indicators
        • Color by Value
        • Gauge Indicator
        • Indicators with Header
      • Scatter Charts
        • Scatter
        • Scatter with Effect
      • Line Charts
        • Line
        • Predictive Line
        • Segmented Line
        • Marked Line
        • Line With Confidence Area
        • Top Bottom Line Charts
        • Summary Line
      • Area Charts
        • Area
        • Stacked Area
        • Segmented Area
        • Top Bottom Area Charts
      • Bar Charts
        • Bar
        • Stacked Bar
        • Horizontal Bar
        • Stacked Horizontal Bar
        • Zero Centered Bar
      • Pie Charts
        • Pie
        • Doughnut
        • Rose
      • Gauge Charts
        • Shimoku Gauge
        • Speed Gauge
      • Input forms
        • Group chained Inputs
        • List input search
        • Conditional inputs
        • Audio input
        • Drag & Drop
      • Line and Bar
      • Waterfall
      • Annotated Chart
      • Heatmap
      • Radar
      • Sunburst
      • Tree
      • Treemap
      • Sankey Diagram
      • Funnel chart
      • iFrame
    • Composite Template Charts
      • Infographics text bubble
      • Chart and Modal Button
      • Chart and Indicators
    • Data Sets
      • Data Set Filters
    • Create your own charts
      • Free Echarts
      • Bento box
    • Features & Navigation
      • Tabs
      • History navigation & Breadcrumb
  • 🔍Advanced usage
    • CLI
    • Workflow Triggers
    • Code Generation
  • 🌍Cloud & Community
    • Shimoku Cloud
    • Shared links
    • Handling Workspaces & Users
      • User authentication
      • Inviting users
      • Creating users
      • Users with multi-workspace access
  • 🌐Releases
    • 2024
      • v.2.6
      • v.2.5
      • v.2.4
      • v.2.3
        • v.2.3.1
      • v.2.2
        • v.2.2.3
        • v.2.2.2
        • v.2.2.1
      • v.2.1
        • v.2.1.2
        • v.2.1.1
      • v.2.0
        • v.2.0.(1..4)
      • v.1.6
        • v.1.6.1
      • v.1.5
    • 2023
      • v.1.4
        • v.1.4.1
        • v.1.4.2
      • v.1.3
      • v.1.2
        • v.1.2.1
      • v.1.1
        • v.1.1.1
      • v.1.0
        • v.1.0.2
        • v.1.0.1
      • v.0.20
      • v.0.19
      • v.0.18
      • v.0.17
        • v.0.17.1
      • v.0.16
        • v.0.16.3
        • v.0.16.2
        • v.0.16.1
      • v.0.15
      • v.0.14
    • 2022
      • v.0.13
        • v.0.13.3
      • v.0.12
      • v.0.11
      • v.0.10
        • v.0.10.4
        • v.0.10.3
        • v.0.10.1
      • v.0.9
      • v.0.8
      • v.0.7
        • v.0.7.1
      • v.0.6
      • v.0.5
      • v.0.4
      • v.0.3
        • v0.3.2
        • v0.3.1
      • v.0.2
Powered by GitBook
On this page
  • 1) Visit
  • 2) Play
  • 3) Copy
  • 4) É Voila!

Was this helpful?

  1. Elements
  2. Create your own charts

Free Echarts

PreviousCreate your own chartsNextBento box

Last updated 1 year ago

Was this helpful?

Free eCharts a cornerstone feature. The catalog of Shimoku has now all the power of personalization of eCharts! The proposed usage is:

1) Visit

and pick a chart you want to plot, for instance

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()

# https://echarts.apache.org/examples/en/editor.html?c=line-style
raw_options: str = """
    {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'line',
      symbol: 'triangle',
      symbolSize: 20,
      lineStyle: {
        color: '#5470C6',
        width: 4,
        type: 'dashed'
      },
      itemStyle: {
        borderWidth: 3,
        borderColor: '#EE6666',
        color: 'yellow'
      }
    }
  ]
};
"""

s.plt.free_echarts(
    raw_options=raw_options,
    menu_path='test/raw-free-echarts',
    order=2, rows_size=2, cols_size=12,
)

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.

xAxis: {
    data: data.map(function (item) {
      return item[0];
    })
  },

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()

data = [
    {'product': 'Matcha Latte', '2015': 43.3, '2016': 85.8, '2017': 93.7},
    {'product': 'Milk Tea', '2015': 83.1, '2016': 73.4, '2017': 55.1},
    {'product': 'Cheese Cocoa', '2015': 86.4, '2016': 65.2, '2017': 82.5},
    {'product': 'Walnut Brownie', '2015': 72.4, '2016': 53.9, '2017': 39.1}
]
options = {
    'legend': {},
    'tooltip': {},
    'xAxis': {'type': 'category', 'data': '#set_data#'},
    'yAxis': {},
    'series': [{'type': 'bar', 'data': '#set_data#'},
               {'type': 'bar', 'data': '#set_data#'},
               {'type': 'bar', 'data': '#set_data#'}]
}
s.plt.free_echarts(
    data=data,
    options=options, fields=['product', '2015', '2016', '2017'],
    order=0, rows_size=2, cols_size=12,
)

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:

    'col1' -> [val1, val3]

  • Tuple: When passing a tuple it will unpack the values as a list of lists of the values in the df:

    ['col1', 'col2'] -> [[val1, val2], [val3, val4]]

  • 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:

    {'name1': 'col1', 'name2': ['col2']} -> 
        [{'name1': val1, 'name2': [val2]}, {'name1': val3, 'name2': [val4]}] 

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

Note You cannot add eCharts functions such as from you must get rid of those for it to work!

Use eCharts console to prepare your chart and when you have what you want you can just copy paste it to the Free eCharts with raw input.

💡
https://echarts.apache.org/examples/en/index.html#chart-type-line
https://echarts.apache.org/examples/en/editor.html?c=line-style
https://echarts.apache.org/examples/en/editor.html?c=line-aqi
https://echarts.apache.org/examples/en/index.html