Hi team, just a question about filters. Can we app...
# gooddata-ui
p
Hi team, just a question about filters. Can we apply dashboard filter on an InsightView ? I have a custom plugin with a line chart inside. I also want to display an insight above my chart. The problem is : when i filter by city on the dashboard level, the linear chart is well update but not my InsightView
j
Hi Pierre, These are separated components and they do not automatically interact between themselves so this is an expected behaviour. Some possible filter passing would need to be implemented manually as per the below: https://www.gooddata.com/docs/gooddata-ui/latest/learn/visualize_data/filter_visual_components/#FilterVisualComponents-InsightViewcomponentfilter
p
Hi Julius, thx for your answer. I cant find the solution with the doc. Here a piece of my code :
return (
<Card
_className_="flex flex-col items-center text-center">
<CardContent
_className_="flex-1 flex justify-between items-center pb-0">
<div
_style_={{ flex: 0.3, paddingRight: '10px', height: '120px', display: 'flex', alignItems: 'flex-start' }}>
<InsightView
_insight_={Md.Insights.RankV2} _filters_={filters} /> {/* Filters are manually applied, so we don't pass them here */}
</div> <div
_style_={{ ...chartContainerStyle, flex: 0.7 }}>
<ResponsiveContainer
_width_="100%" _height_="100%">
<LineChart
_data_={chartData}
_margin_={{right: 100, left: 100, bottom: 40 }} // Adjusted margins
> <CartesianGrid
_vertical_={false} _horizontal_={false} />
<XAxis
_dataKey_="month"
_tickLine_={false}
_axisLine_={false}
_tickMargin_={8}
_tickFormatter_={(_value_) => {
const date = new Date(value); // Convert the value to a Date object return date.toLocaleDateString('en-US', { month: 'short'}); // Format as "Jan 2024" }} /> <Tooltip
_content_={<CustomTooltip _active_={undefined} _payload_={undefined} _label_={undefined} />} />
<Line
_dataKey_="actual"
_type_="natural"
_stroke_={chartConfig.actual.color}
_strokeWidth_={2}
_dot_={true}
> {/* <LabelList position="top" offset={12} className="fill-foreground" fontSize={12} /> */} </Line> <Line
_dataKey_="previous"
_type_="natural"
_stroke_={chartConfig.previous.color}
_strokeWidth_={2}
_dot_={true}
> {/* <LabelList position="top" offset={12} className="fill-foreground" fontSize={12} /> */} </Line> </LineChart> </ResponsiveContainer> </div> </CardContent> </Card> ); }; Here my line chart is filtered by the global filters in the dashboard level but thoses filters doesnt not apply on the InsightView. There is a way to pass them to the insightview to have something uniform ?
r
Hi there, Radek again 🙂 The issue is that you'd have to pass the filters there - for a way to get the filter state out of the Dashboard, you can take inspiration in Mustafa's post directly below yours, he has demonstrated a nice solution to this!