GSS-Cogs / chart-builder

The Chart Builder is a proof-of-concept app to understand the feasibility of using a CSV file (or SPARQL query) to generate and customise a chart or data visualisation
https://chart-builder-no4vxskx7a-nw.a.run.app
2 stars 0 forks source link

Issue 793/tabular view of data/data download of filtered charts #188

Closed StRhys closed 1 year ago

StRhys commented 1 year ago

This ticket allows for filters that have been applied to charts to feed through into the data tab view and the downloadable csv. Filters can be applied by clicking on the legend of a chart. Legends can also be double clicked to have different effects on filters depending on what filters are already applied.

This could have been me doing something wrong but Plotly has a few issues which tie to clicking on the legend. The first being when a legend click event triggers it will pass an event which contains the data the chart, with also has series visibility on (true, undefined, and 'legendonly'). The issue with this is it will contain the data of the chart pre click, so using it to set the filters on the chart becomes complicated and impossible when a double click triggers, which can turn on/off multiple filters. So this method isn't used.

So I decided to use an array to track which series have been filtered. Event data passes a 'curveNumber' which is the index of the clicked series. The issue that arose was that this click trigger event wouldn't lead to the state of the index array being set, it was only set when switching tabs. The logic behind tracking filtered indexes needs an up to date array and so in the end a normal variable array was used to track the current index array, with another one used to keep state when switching tabs.