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