Chart filtering

Hi,

I have a dashboard I need to filter.

I want to filter all charts when I click on a bar.

When I click on the bar, I can get the Label, this can help me filter on the date for exemple.

But I can not manage to get the actual ‘dataSet’ label. For exemple ‘Profit’ or ‘Loss’.

I tryed with this kind of function :

const index = event?.['points']?.[0]?.['index']
const datasetIndex = event?.['points']?.[0]?.['datasetIndex']
const label = event?.['points']?.[0]?.['label']
const value = event?.['points']?.[0]?.['value']
const datax = event?.['dataX']
const datay = event?.['dataY']
const points = event?.['points']
const shipment_ids = collections['xxx-xxx-xxx-xxx']?.['data']?.[index].shipment_ids
const profit_or_loss = collections['xxx-xxx-xxx-xxx']?.['data']?.[index].profit_or_loss

return "Label : " + label + " / " +
       "Value : " + value + " / " +
       "Index : " + index + " / " +
       "datasetIndex : " + datasetIndex + " / " 

It is sometimes gifing me the good data sometimes not. When I click on a ‘Profit’ point, the profit_or_loss gives me eithr ‘profit’ or ‘loss’

Ok I found one solution.

I transformed the chart to a component.
I used variables to set up my dataset and labels with formulas.
Then I can access my dataset as a variable.
And use this :

return context.component?.variables?.[/* dataset */ 'xxx-xxx-xxx-xxx']?.[variables[/* Profit and loss chart - eventDatasetIndex */ 'xxx-xxx-xxx-xxx']]?.['label']

It is kind of a lot. Would it be possible to access the dataSet information directly through the event ?

@weweb