def input_toggles(_ts, inputs): """ dash callback controlling showing/hiding of chart-specific inputs (for example z-axis) as well as chart formatting inputs (sorting for bars in bar chart, bar chart style (stacked) or y-axis ranges. """ [chart_type, agg] = [inputs.get(p) for p in ['chart_type', 'agg']] show_input = show_input_handler(chart_type) y_multi_style = { 'display': 'block' if show_input('y', 'multi') else 'none' } y_single_style = {'display': 'block' if show_input('y') else 'none'} z_style = {'display': 'block' if show_input('z') else 'none'} group_style = {'display': 'block' if show_input('group') else 'none'} rolling_style = {'display': 'inherit' if agg == 'rolling' else 'none'} cpg_style = { 'display': 'block' if show_chart_per_group(**inputs) else 'none' } bar_style = bar_input_style(**inputs) yaxis_style = { 'display': 'block' if show_yaxis_ranges(**inputs) else 'none' } return (y_multi_style, y_single_style, z_style, group_style, rolling_style, cpg_style, bar_style, bar_style, yaxis_style)
def input_toggles(_ts, inputs, pathname): """ dash callback controlling showing/hiding of chart-specific inputs (for example z-axis) as well as chart formatting inputs (sorting for bars in bar chart, bar chart style (stacked) or y-axis ranges. """ [chart_type, agg] = [inputs.get(p) for p in ["chart_type", "agg"]] show_input = show_input_handler(chart_type) y_multi_style = {"display": "block" if show_input("y", "multi") else "none"} y_single_style = {"display": "block" if show_input("y") else "none"} z_style = {"display": "block" if show_input("z") else "none"} group_style = {"display": "block" if show_input("group") else "none"} rolling_style = {"display": "inherit" if agg == "rolling" else "none"} cpg_style = {"display": "block" if show_chart_per_group(**inputs) else "none"} bar_style, barsort_style = bar_input_style(**inputs) yaxis_style = {"display": "block" if show_yaxis_ranges(**inputs) else "none"} data_id = get_data_id(pathname) df = global_state.get_data(data_id) animate_style, animate_by_style, animate_opts = animate_styles(df, **inputs) return ( y_multi_style, y_single_style, z_style, group_style, rolling_style, cpg_style, bar_style, barsort_style, yaxis_style, animate_style, animate_by_style, animate_opts, )
def group_values(chart_type, group_cols, map_group_cols, pathname, inputs, prev_group_vals): group_cols = make_list(group_cols) if show_input_handler(chart_type or 'line')('group') and not len(group_cols): return [], None elif chart_type == 'maps': # all maps have a group input group_cols = make_list(map_group_cols) if not len(group_cols): return [], None data_id = get_data_id(pathname) group_vals = run_query(global_state.get_data(data_id), inputs.get('query'), global_state.get_context_variables(data_id)) group_vals = build_group_val_options(group_vals, group_cols) selections = [] available_vals = [gv['value'] for gv in group_vals] if prev_group_vals is not None: selections = [ pgv for pgv in prev_group_vals if pgv in available_vals ] if not len(selections) and len(group_vals) <= MAX_GROUPS: selections = available_vals return group_vals, selections
def group_values(group_cols, pathname, inputs, prev_group_vals): group_cols = make_list(group_cols) if not show_input_handler(inputs.get( 'chart_type', 'line'))('group') or not len(group_cols): return [], None print('loading group vals...') data_id = get_data_id(pathname) group_vals = run_query(global_state.get_data(data_id), inputs.get('query'), global_state.get_context_variables(data_id)) group_vals = build_group_val_options(group_vals, group_cols) selections = [] available_vals = [gv['value'] for gv in group_vals] if prev_group_vals is not None: selections = [ pgv for pgv in prev_group_vals if pgv in available_vals ] if not len(selections) and len(group_vals) <= MAX_GROUPS: selections = available_vals return group_vals, selections