Get 'selected data' in a parallel coordinates chart to update table - Resolved

Hello,

I want to update a table based on the constraint range filter in a parallel coordinates chart. There are two questions pertaining for this use case.

  1. How to obtain the selected data?
  2. How to fire a callback when constraint range is changed to update the table?
1 Like

I found about restyleData for the parallel coordinate chart and I am able to obtain the constraint range for the last changed constraint.

Hi, will you be able to share how to generate the callbacks between parallel coordinates and table ? I want to do the same and struggle a little bit. Thanks, Matthieu

Sure. Here is what I’m doing.

I use restyleData as input to the callback function. Something like this

@app.callback(Output('parallel-coord-graph', 'figure'),
              [Input('par-coord-dropdown', 'value'),
               Input('parallel-coord-graph', 'restyleData')],
              [State('parallel-coord-graph', 'figure'),
               State('metric-range', 'children')])
def update_par_coord_graph(dropdown_input, restyledata, par_coord_data,
                           metric_info):

    par_coord_data = par_coord_data['data'][0]
    curr_dims = par_coord_data.get('dimensions', None)

# Relevant restyleData Code

        # Update the constraint ranges for the new restyled dimension
        # Format of resytledata: [{'dimension[0].constraintrange': [0,1]}]
        if restyledata:
            for key, val in restyledata[0].items():
                dim = int(re.split(r'\[|\]', key)[1])
                updated_constraints[dropdown_input[dim]] = val[0]

Note the format of restyledata which is a dict.

To update the table, I use figure attribute to extract the state of the parallel coordinate chart. Something like this -

@app.callback(Output('table', 'children'),
              [Input('parallel-coord-graph', 'figure')])
def test_me(par_coord_data):

    par_coord_data = par_coord_data['data'][0]
    curr_dims = par_coord_data.get('dimensions', None)

Hope this helps!
Lakshay

3 Likes

Hi, I tried but unfortunately by selecting on a parcoord axis, the callback is not activated. Is there a way for you to share with me an example ? Regards, Matthieu

1 Like

Is it possible to use restyleData when we unselect the filter from parcoords axis?
I’ve tried any graph properties including restyleData, but it doesn’t trigger new output. The output still showing the last {dimension,constraintrange} we selected.