PivotTable Component
The PivotTable component allows users to create dynamic pivot tables from a given dataset.
Props
Prop | Type | Default | Description |
---|---|---|---|
initialData | Array<DataItem> | required | Initial dataset for the pivot table |
title | string | "Pivot Table" | Title of the pivot table |
className | string | "" | Additional CSS classes for the pivot table wrapper |
Usage
import { PivotTable } from 'knoxui-react';
const initialData = [
{ category: 'Fruits', item: 'Apple', region: 'North', sales: 100 },
{ category: 'Fruits', item: 'Banana', region: 'South', sales: 150 },
{ category: 'Vegetables', item: 'Carrot', region: 'East', sales: 80 },
{ category: 'Vegetables', item: 'Broccoli', region: 'West', sales: 120 },
{ category: 'Fruits', item: 'Apple', region: 'South', sales: 90 },
{ category: 'Vegetables', item: 'Carrot', region: 'North', sales: 110 },
];
<PivotTable initialData={initialData} title="Sales Data" />
Features
- Drag and drop fields to configure rows, columns, and values
- Aggregation options (SUM, COUNT)
- Sorting and filtering capabilities
- Export to Excel and PDF
- Responsive design
Example
Basic PivotTable
Values
Rows
Columns
Available Fields
category
item
region
sales
Sales Data
Usage Instructions
- Drag fields from the "Available Fields" section to "Values", "Rows", or "Columns".
- Use the "SUM" or "COUNT" options in the "Values" section to change the aggregation type.
- Drag fields within "Rows" or "Columns" to change their order.
- Use the search box above the pivot table to filter data globally.
- Click on column headers to sort the data.
- Use the export buttons to download the data as Excel or PDF.