コード例 #1
0
ファイル: views.py プロジェクト: ebgaspar/dtale
 def input_data(
     _ts,
     chart_type,
     x,
     y_multi,
     y_single,
     z,
     group,
     group_val,
     agg,
     window,
     rolling_comp,
     pathname,
     query,
 ):
     """
     dash callback for maintaining chart input state and column-based dropdown options.  This will guard against
     users selecting the same column for multiple axes.
     """
     y_val = make_list(y_single if chart_type in ZAXIS_CHARTS else y_multi)
     if group_val is not None:
         group_val = [json.loads(gv) for gv in group_val]
     inputs = dict(
         query=query,
         chart_type=chart_type,
         x=x,
         y=y_val,
         z=z,
         group=group,
         group_val=group_val,
         agg=agg,
         window=window,
         rolling_comp=rolling_comp,
     )
     data_id = get_data_id(pathname)
     options = build_input_options(global_state.get_data(data_id), **inputs)
     (
         x_options,
         y_multi_options,
         y_single_options,
         z_options,
         group_options,
         barsort_options,
         yaxis_options,
     ) = options
     show_map = chart_type == "maps"
     map_style = {} if show_map else {"display": "none"}
     non_map_style = {"display": "none"} if show_map else {}
     cscale_style = colorscale_input_style(chart_type=chart_type)
     return (
         inputs,
         x_options,
         y_single_options,
         y_multi_options,
         z_options,
         group_options,
         barsort_options,
         yaxis_options,
         non_map_style,
         map_style,
         cscale_style,
     )
コード例 #2
0
    def input_data(
        _ts,
        _ts2,
        chart_type,
        x,
        y_multi,
        y_single,
        z,
        group,
        group_type,
        group_val,
        bins_val,
        bin_type,
        agg,
        window,
        rolling_comp,
        load,
        load_type,
        cleaners,
        pathname,
        query,
        data_id,
        extended_aggregation,
    ):
        """
        dash callback for maintaining chart input state and column-based dropdown options.  This will guard against
        users selecting the same column for multiple axes.
        """
        y_val = make_list(y_single if chart_type in ZAXIS_CHARTS else y_multi)
        data_id = data_id or get_data_id(pathname)
        if group_val is not None:
            group_val = [json.loads(gv) for gv in group_val]

        inputs = dict(
            data_id=data_id,
            query=query,
            chart_type=chart_type,
            x=x,
            y=y_val,
            z=z,
            group=group,
            group_type=group_type or "groups",
            group_val=group_val if group else None,
            bins_val=bins_val if group else None,
            bin_type=bin_type or "width",
            agg=agg or "raw",
            window=window,
            rolling_comp=rolling_comp,
            load=load,
            load_type=load_type,
            cleaners=make_list(cleaners),
        )
        options = build_input_options(
            global_state.get_data(data_id),
            extended_aggregation=extended_aggregation,
            **inputs)
        (
            x_options,
            y_multi_options,
            y_single_options,
            z_options,
            group_options,
            barsort_options,
            yaxis_options,
        ) = options
        show_map = chart_type == "maps"
        map_style = {} if show_map else {"display": "none"}
        show_cs = chart_type == "candlestick"
        cs_style = {} if show_cs else {"display": "none"}
        show_treemap = chart_type == "treemap"
        treemap_style = {} if show_treemap else {"display": "none"}
        show_funnel = chart_type == "funnel"
        funnel_style = {} if show_funnel else {"display": "none"}
        standard_style = ({
            "display": "none"
        } if show_map or show_cs or show_treemap or show_funnel else {})
        cscale_style = colorscale_input_style(chart_type=chart_type)
        drilldown_toggle_style = show_style((agg or "raw") != "raw")
        return (
            inputs,
            x_options,
            y_single_options,
            y_multi_options,
            z_options,
            group_options,
            barsort_options,
            yaxis_options,
            standard_style,
            map_style,
            cs_style,
            treemap_style,
            funnel_style,
            cscale_style,
            drilldown_toggle_style,
            lock_zoom_style(chart_type),
            show_style(chart_type not in NON_EXT_AGGREGATION and len(y_val)),
            "({} Selected)".format(len(inputs["cleaners"]))
            if len(inputs["cleaners"]) else "",
        )