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.
To get the new version
🎉
pip install --upgrade shimoku-api-python
This version is a small update that includes three new plots and upgrades to the indicator report.
- 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 functions.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 contractHogar, 21, 5, 12, 17, 3, 14, 3, 6Móvil, 23, 16, 16, 14, 4, 2, 19, 12Dental, 26, 21, 14, 17, 1, 2, 6, 3Viajes, 24, 22, 15, 17, 8, 5, 15, 4Accidentes, 22, 12, 18, 17, 5, 6, 1, 5Seguro de vida, 22, 21, 19, 12, 7, 3, 2, 9Jurídico, 25, 21, 13, 12, 10, 6, 13, 6Dental Plus, 24, 4, 17, 17, 7, 9, 2, 3Jubilación, 20, 4, 19, 17, 2, 2, 10, 8Salud, 27, 24, 17, 17, 12, 1, 4, 1and 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:Default resultThe 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 parametercalculate_percentages
has to be set toTrue
, 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:Result calculating percentages per category and showing only the first level of values. - 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 parameteris_percentage
toFalse
.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:Shimoku gauges - 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
toTrue
.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:Shimoku gauges group with percentages calculated
Last modified 5mo ago