onDrill
Handle drill events with the onDrill callback when users click drillable items in InsightView and the chart components.
The onDrill callback runs when the user clicks a drillable item in a visualization. InsightView, the chart components, and the pivot table accept it. Use it to respond to the click in your app, for example to open a detail view filtered by the clicked value.
Structure
onDrill?: (event: IDrillEvent) => void | boolean;
The IDrillEvent holds:
dataView: the data the visualization was rendered from.drillContext: what the user clicked, including the type of the clicked element and theintersectionof measures and attribute values at that point.
Example
import { HeaderPredicates, type IDrillEvent } from "@gooddata/sdk-ui";
import { InsightView } from "@gooddata/sdk-ui-ext";
function handleDrill(event: IDrillEvent) {
console.log(event.drillContext.intersection);
}
export function DrillableVisualization() {
return (
<InsightView
insight="<visualization-id>"
drillableItems={[HeaderPredicates.identifierMatch("<measure-or-attribute-id>")]}
onDrill={handleDrill}
/>
);
}
Notes
- After
onDrillruns, the visualization also dispatches adrillDOM event that bubbles up from the visualization’s element, with the sameIDrillEventas itsdetail. ReturnfalsefromonDrillto stop that DOM event; any other return value lets it through. - Only items that match
drillableItemsare drillable. WithoutdrillableItems,onDrillnever runs. See Make visualizations drillable.
Related
Configure drillableItems with header predicates to make visualization measures or attributes interactive and receive drill event context.
Match visualization headers for drilling with custom predicate functions or the HeaderPredicates helpers.
Choose which layer of a dashboard widget to replace (the widget, the visualization, or its body) and how drills flow through custom renderers.
Render any saved GoodData visualization by reference with the InsightView component.