v.0.12

On 2022.12.13

This version has been deprecated. If used with the current API version it can produce unexpected behaviour or errors.

The package shimoku-api-python is no longer maintained

pip install --upgrade shimoku-api-python

This version is a small update that includes three new plots and upgrades to the indicator report.

Improvements

  • Now a background image can be provided to the indicators, and variants can be specified also! The possible variants are:

    'default' 'outlined' 'contained' 'topColor'

    So now this indicators are possible:

    The new features have been added as parameters of the function s.plt.indicator. To get the result shown above the following code has been executed:

    data_ = [{
        "color": "success",
        "variant": "contained",
        "description": "This indicator has a Link",
        "targetPath": "/indicators/indicator/1",
        "title": "Target Indicator",
        "align": "left",
        "value": "500€"
    }, {
        "color": "warning",
        "backgroundImage": "https://images.unsplash.com/photo-1535957998253-26ae1ef29506?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=736&q=80",
        "variant": "outlined",
        "description": "This has a background",
        "title": "Super cool indicator",
        "align": "left",
        "value": "Value"
    }, {
        "color": "error",
        "variant": "outlined",
        "description": "This hasn't got any icons",
        "title": "Error indicator",
        "align": "left",
        "value": "Value",
    }, {
        "color": "caution",
        "variant": "contained",
        "description": "Aligned to right and full of icons",
        "title": "Multiple cases",
        "align": "right",
        "value": "Value",
    }
    ]
    s.plt.indicator(
        data=data_,
        menu_path=menu_path,
        order=2, rows_size=2, cols_size=12,
        value='value',
        header='title',
        footer='description',
        align='align',
        color='color',
        variant='variant',
        target_path='targetPath',
        background_image='backgroundImage',
    )

  • A stacked bar chart has been added! So now you can visualize the sum of various categories in an intuitive way. Using the following .csv dataset:

    Segment, Price, Client category, Age, Geo, Acquisitive power, Family size, Policie tenure, Labour contract
    Hogar, 21, 5, 12, 17, 3, 14, 3, 6
    Móvil, 23, 16, 16, 14, 4, 2, 19, 12
    Dental, 26, 21, 14, 17, 1, 2, 6, 3
    Viajes, 24, 22, 15, 17, 8, 5, 15, 4
    Accidentes, 22, 12, 18, 17, 5, 6, 1, 5
    Seguro de vida, 22, 21, 19, 12, 7, 3, 2, 9
    Jurídico, 25, 21, 13, 12, 10, 6, 13, 6
    Dental Plus, 24, 4, 17, 17, 7, 9, 2, 3
    Jubilación, 20, 4, 19, 17, 2, 2, 10, 8
    Salud, 27, 24, 17, 17, 12, 1, 4, 1

    and executing the following code:

    data = pd.read_csv('file.csv')
    
    s.plt.stacked_barchart(
        data=data,
        menu_path=menu_path,
        x="Segment",
        x_axis_name='Distribution and weight of the Drivers',
        order=0,
        rows_size=3, cols_size=12,
    )

    the result is:

    The function has the option to hide or show each level by using the parameter show_values where the columns of the dataset that will show it's values have to be specified, by default it will show all the values. Also this type of plot is very useful to visualize percentages of the fields for each category, to do it, the parameter calculate_percentages has to be set to True, when activated it will calculate for each value of each category the percentage from the total.

    When executing the following code:

    data = pd.read_csv('file.csv')
    
    s.plt.stacked_barchart(
        data=data_,
        menu_path=menu_path,
        x="Segment",
        x_axis_name='Distribution and weight of the Drivers',
        order=0,
        rows_size=3, cols_size=12,
        show_values=['Price'],
        calculate_percentages=True,
    )

    the resulting plot is:

  • We also added a new type of gauge charts with the Shimoku flavour, they are called the Shimoku gauges. They are minimalist and useful for a quick view on various metrics. The function to use them is s.plt.shimoku_gauge.

    The method accepts various types of colors as the parameter color. There are a group of default colors that can be used passing an integer from 1 to 10, also it can accept some keywords that will activate dashboard specific colors, the list is:

    'success', 'error', 'warning', 'success-light', 'error-light', 'warning-light', 'status-error'

    By default they show the percentage symbol but it can be deactivated by setting the parameter is_percentage to False.

    An example on how to use them is:

    s.plt.shimoku_gauge(
        value=-48, menu_path=menu_path, order=0,
        rows_size=1, cols_size=3, name="Shimoku",
        color=1)
        
    s.plt.shimoku_gauge(
        value=3.56, menu_path=menu_path, order=1,
        rows_size=1, cols_size=3,
        color="status-error")
        
    s.plt.shimoku_gauge(
        value=-90, menu_path=menu_path, order=2,
        rows_size=1, cols_size=3, name="gauges",
        color='#00F0FF')

    Which results in:

  • The last plot added is the Shimoku gauges group, it makes use of the Shimoku gauge and the Bento box feature. It takes as data a list of dictionaries (or dataframe) where the necessary information for each gauge must be provided.

    This component can calculate the percentages of the group of gauges provided, like the stacked bar chart component, this can be activated by setting the parameter calculate_percentages to True.

    In the next example the previously mentioned .csv will be used to make a group of gauges:

    menu_path: str = 'test/shimoku-gauges'
    df = pd.read_csv('file.csv')
    gauges_data = pd.DataFrame(columns=["name", "value", "color"])
    df_transposed = df.transpose().reset_index().drop(0)
    value_columns = [col for col in df_transposed.columns if col != "index"]
    gauges_data["value"] = df_transposed[value_columns].apply(lambda row: sum(row), axis=1)
    gauges_data["name"] = df_transposed['index']
    gauges_data["color"] = range(1, len(df_transposed) + 1)
    
    order = s.plt.shimoku_gauges_group(
        gauges_data=gauges_data,
        order=0, menu_path=menu_path,
        cols_size=12, rows_size=3,
        calculate_percentages=True,
    )

    That results in:

Last updated