Esempio n. 1
0
 def build(self):
     base_code = build_code_export(
         self.data_id,
         imports="{}\n\n".format("\n".join([
             "import numpy as np",
             "import pandas as pd",
             "import plotly.graph_objs as go",
         ])),
     )
     return_data, code = self.analysis.build(self)
     return dict(code=build_final_chart_code(base_code + code),
                 query=self.query,
                 cols=global_state.get_dtypes(self.data_id),
                 dtype=self.dtype,
                 chart_type=self.analysis_type,
                 **return_data)
Esempio n. 2
0
 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,
         build_final_chart_code(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,
     )