# Chart filtering

**URL:** <https://community.weweb.io/t/chart-filtering/14273>\
**Category:** Ask us anything\
**Tags:** design, xano, chart\
**Created:** [October 31, 2024, 8:54am UTC](https://community.weweb.io/t/chart-filtering/14273 "2024-10-31T08:54:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenoitG](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@BenoitG](https://community.weweb.io/u/BenoitG)\
**Post date:** [October 31, 2024, 8:54am UTC](https://community.weweb.io/t/chart-filtering/14273/1 "2024-10-31T08:54:57Z")

</div>

Hi,

I have a dashboard I need to filter.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0ca94bba9119ef17ed9abfd1f65cc83621ea9bc2.png)

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 :

```auto
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’

---

<div class="post-metadata">

**Author:** ![BenoitG](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@BenoitG](https://community.weweb.io/u/BenoitG)\
**Post date:** [October 31, 2024, 11:35am UTC](https://community.weweb.io/t/chart-filtering/14273/2 "2024-10-31T11:35:53Z")

</div>

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 :

```auto
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
