def on_data( _ts1, _ts2, _ts3, _ts4, _ts5, _ts6, load, inputs, chart_inputs, yaxis_data, map_data, cs_data, treemap_data, last_chart_inputs, auto_load, prev_load_clicks, ): """ dash callback controlling the building of dash charts """ all_inputs = dict_merge( inputs, chart_inputs, dict(yaxis=yaxis_data or {}), map_data, cs_data, treemap_data, ) if not auto_load and load == prev_load_clicks: raise PreventUpdate if all_inputs == last_chart_inputs: raise PreventUpdate if is_app_root_defined(dash_app.server.config.get("APPLICATION_ROOT")): all_inputs["app_root"] = dash_app.server.config["APPLICATION_ROOT"] charts, range_data, code = build_chart(**all_inputs) return ( charts, all_inputs, range_data, "\n".join(make_list(code) + [CHART_EXPORT_CODE]), get_yaxis_type_tabs(make_list(inputs.get("y") or [])), load, dict(display="block" if valid_chart(**all_inputs) else "none"), )
def save_chart(*args): args = list(args) save_clicks = args.pop(0) current_deletes = [args.pop(0) or 0 for _ in range(MAX_SAVED_CHARTS)] inputs = args.pop(0) chart_inputs = args.pop(0) yaxis_data = args.pop(0) map_data = args.pop(0) cs_data = args.pop(0) treemap_data = args.pop(0) prev_save_clicks = args.pop(0) updated_configs = [args.pop(0) for _ in range(MAX_SAVED_CHARTS)] prev_deletes = [args.pop(0) or 0 for _ in range(MAX_SAVED_CHARTS)] delete_idx = None for i, (curr_delete, prev_delete) in enumerate(zip(current_deletes, prev_deletes)): if curr_delete > prev_delete: delete_idx = i if delete_idx is None: if save_clicks == prev_save_clicks: raise PreventUpdate config = dict_merge( inputs, chart_inputs, dict(yaxis=yaxis_data or {}), map_data, cs_data, treemap_data, ) if not valid_chart(**config): raise PreventUpdate for index, saved_config in enumerate(updated_configs): if saved_config is None: updated_configs[index] = config break else: updated_configs[delete_idx] = None return tuple([save_clicks] + updated_configs + current_deletes)
def on_data( _ts1, _ts2, _ts3, _ts4, _ts5, _ts6, _ts7, _ts8, load_clicks, inputs, chart_inputs, yaxis_data, map_data, cs_data, treemap_data, funnel_data, last_chart_inputs, auto_load, prev_load_clicks, ext_aggs, ): """ dash callback controlling the building of dash charts """ all_inputs = dict_merge( inputs, chart_inputs, dict(yaxis=yaxis_data or {}), map_data, cs_data, treemap_data, funnel_data, dict(extended_aggregation=ext_aggs or []) if inputs.get("chart_type") not in NON_EXT_AGGREGATION else {}, ) if not auto_load and load_clicks == prev_load_clicks: raise PreventUpdate if all_inputs == last_chart_inputs: raise PreventUpdate if is_app_root_defined(dash_app.server.config.get("APPLICATION_ROOT")): all_inputs["app_root"] = dash_app.server.config["APPLICATION_ROOT"] charts, range_data, code = build_chart(**all_inputs) agg_disabled = len(ext_aggs) > 0 ext_agg_tt = text("ext_agg_desc") ext_agg_warning = show_style(agg_disabled) if agg_disabled: ext_agg_tt = html.Div([ html.Span(text("ext_agg_desc")), html.Br(), html.Ul([ html.Li( extended_aggregations.build_extended_agg_desc(ext_agg), className="mb-0", ) for ext_agg in ext_aggs ]), ]) final_cols = build_final_cols( make_list(inputs.get("y")), inputs.get("z"), inputs.get("agg"), ext_aggs if inputs.get("chart_type") not in NON_EXT_AGGREGATION else [], ) return ( charts, all_inputs, range_data, "\n".join(make_list(code) + [CHART_EXPORT_CODE]), get_yaxis_type_tabs(final_cols), load_clicks, dict(display="block" if valid_chart(**all_inputs) else "none"), agg_disabled, ext_agg_tt, ext_agg_warning, )