Superset Chart - Pivot Table provides comprehensive pivot table chart plugin for Apache Superset with interactive data visualization and summarization capabilities.
npx @tessl/cli install tessl/npm-superset-ui--plugin-chart-pivot-table@0.18.0The @superset-ui/plugin-chart-pivot-table package provides a comprehensive pivot table chart plugin for Apache Superset that enables interactive data visualization and summarization. It allows users to create pivot tables by grouping data along two axes, supporting multiple statistics aggregation, drill-to-detail functionality, and interactive chart behaviors.
npm install @superset-ui/plugin-chart-pivot-tableimport { PivotTableChartPlugin } from "@superset-ui/plugin-chart-pivot-table";For CommonJS:
const { PivotTableChartPlugin } = require("@superset-ui/plugin-chart-pivot-table");import { PivotTableChartPlugin } from "@superset-ui/plugin-chart-pivot-table";
import { SuperChart } from "@superset-ui/core";
// Register the plugin
new PivotTableChartPlugin().configure({ key: 'pivot-table-v2' }).register();
// Use in SuperChart component
<SuperChart
chartType="pivot-table-v2"
width={600}
height={600}
formData={{
groupbyRows: ['region'],
groupbyColumns: ['category'],
metrics: ['sales'],
aggregateFunction: 'Sum'
}}
queriesData={[{
data: [
{ region: 'North', category: 'A', sales: 100 },
{ region: 'South', category: 'B', sales: 200 }
],
}]}
/>The plugin is built around the Superset chart plugin architecture with these key components:
PivotTableChartPlugin extends the base ChartPlugin with specific metadata and configurationPivotTableChart React component renders the actual pivot table visualizationbuildQuery function constructs database queries for pivot table data requirementstransformProps function processes chart data and configuration into component propsMain plugin class for registering the pivot table chart type with Superset, including chart metadata, behaviors, and configuration options.
export default class PivotTableChartPlugin extends ChartPlugin<
PivotTableQueryFormData,
ChartProps<QueryFormData>
> {
constructor();
}Core React component that renders the pivot table visualization with interactive features, aggregation options, and cross-filtering capabilities.
function PivotTableChart(props: PivotTableProps): JSX.Element;
interface PivotTableProps extends PivotTableStylesProps, PivotTableCustomizeProps {
data: DataRecord[];
}Data query construction for pivot table requirements, handling groupby columns/rows, metrics, and filtering with support for temporal data and custom ordering.
function buildQuery(formData: PivotTableQueryFormData): QueryContext;Data and configuration transformation for converting chart properties into component props, including date formatting and color formatter setup.
function transformProps(chartProps: ChartProps<QueryFormData>): PivotTableProps;Complete type definitions for pivot table configuration, styling, and data structure requirements with support for cross-filtering and interactive behaviors.
export interface PivotTableQueryFormData extends QueryFormData, PivotTableStylesProps, PivotTableCustomizeProps {}
export interface PivotTableStylesProps {
height: number;
width: number | string;
margin: number;
}
export enum MetricsLayoutEnum {
ROWS = 'ROWS',
COLUMNS = 'COLUMNS'
}The plugin utilizes an internal pivot table rendering engine with built-in aggregation functions, sorting capabilities, and table rendering options. These components are internal implementation details and not part of the public API.
Note: The pivot table engine components (PivotTable, sortAs, aggregatorTemplates) are internal to the plugin implementation and should not be imported directly. All functionality is accessible through the PivotTableChartPlugin public API.