Ayush Kumar
07/16/2025, 10:50 AMYvonne Changamuka
07/16/2025, 1:53 PMSwapnil Choudhary
07/17/2025, 6:35 AMAyush Kumar
07/17/2025, 8:09 AMAyush Kumar
07/17/2025, 8:10 AMAyush Kumar
07/17/2025, 8:10 AMAyush Kumar
07/17/2025, 8:10 AM"@gooddata/sdk-backend-spi": "^10.24.0",
"@gooddata/sdk-backend-tiger": "^10.24.0",
"@gooddata/sdk-model": "^10.24.0",
"@gooddata/sdk-ui": "^10.24.0",
"@gooddata/sdk-ui-all": "^10.24.0",
"@gooddata/sdk-ui-ext": "^10.24.0",
Radek Novacek
07/18/2025, 1:02 PMAyush Kumar
07/21/2025, 7:50 AMAyush Kumar
07/21/2025, 7:52 AMRadek Novacek
07/21/2025, 7:56 AMAyush Kumar
07/21/2025, 8:03 AMRadek Novacek
07/21/2025, 3:04 PMimport { useState } from "react";
import { InsightView } from "@gooddata/sdk-ui-ext";
import { PivotTable } from "@gooddata/sdk-ui-pivot";
import { IDrillEvent } from "@gooddata/sdk-ui";
import { IAttributeFilter, newPositiveAttributeFilter, IFilter } from "@gooddata/sdk-model";
import { OrderUnitPrice, OrderUnitQuantity, CustomerState, ProductBrand, Insights } from "../md/catalog.ts";
export function SimpleDrillExample() {
const [drillFilter, setDrillFilter] = useState<IFilter | null>(null);
const [selectedValue, setSelectedValue] = useState<string>("");
const handleDrill = (drillEvent: IDrillEvent) => {
// Find the attribute item that was clicked
const intersection = drillEvent.drillContext?.intersection;
if (!intersection || intersection.length === 0) return;
for (const intersectionElement of intersection) {
const { header } = intersectionElement;
// Check if this is an attribute (not a measure)
if (header && "attributeHeaderItem" in header && "attributeHeader" in header) {
const attributeRef = (header as any).attributeHeader.ref;
const attributeValue = (header as any).attributeHeaderItem.name;
console.log(`Drilling on: ${attributeValue}`);
// Create filter for the clicked value
const filter: IAttributeFilter = newPositiveAttributeFilter(attributeRef, [attributeValue]);
setDrillFilter(filter);
setSelectedValue(attributeValue);
break;
}
}
};
const clearDrill = () => {
setDrillFilter(null);
setSelectedValue("");
};
return (
<div>
<h2>Simple Drill-Down Example</h2>
<p>Click on any slice of the pie chart to filter the table below.</p>
{selectedValue && (
<div>
<span>Filtered by: {selectedValue}</span>
<button onClick={clearDrill}>Clear Filter</button>
</div>
)}
<div style={{ display: "flex" }}>
<div style={{ flex: 1, height: "400px" }}>
<h4>Pie Chart</h4>
<InsightView
insight={Insights.Pie}
drillableItems={[() => true]}
onDrill={handleDrill}
/>
</div>
<div style={{ flex: 1, height: "400px" }}>
<h4>Results Table</h4>
<PivotTable
measures={[OrderUnitPrice.Sum, OrderUnitQuantity.Sum]}
rows={[CustomerState]}
columns={[ProductBrand]}
filters={drillFilter ? [drillFilter] : []}
/>
</div>
</div>
</div>
);
}
I successfully tested this with my own environment. Please let me know if there's any errors with this, or questions about what the code does, and I will do my best to clarify as well 🙂Ayush Kumar
07/22/2025, 12:24 PMimport { OrderUnitPrice, OrderUnitQuantity, CustomerState, ProductBrand, Insights } from "../md/catalog.ts";
Ayush Kumar
07/22/2025, 12:25 PMAyush Kumar
07/22/2025, 12:25 PMRadek Novacek
07/22/2025, 12:26 PMAyush Kumar
07/22/2025, 4:20 PMSwapnil Choudhary
07/23/2025, 11:50 AMSwapnil Choudhary
07/23/2025, 11:53 AMPavel Doubek
07/25/2025, 9:44 AM