PivotViewer - Configuration
Required Props
Section titled “Required Props”data: Array of items to displaydimensions: Array of dimension configurations for groupingcardRenderer: Function to render card view for an item
Optional Props
Section titled “Optional Props”filters: Array of filter configurationsdetailRenderer: Function to render detail view for an itemgetItemId: Function to extract unique ID from an itemdefaultDimensionKey: Initial dimension to group bysearchFields: Array of accessor functions returning the values to include in text searchclassName: CSS class for the containeremptyContent: React node to show when no data matches filtersisLoading: Show loading statecolors: Custom color scheme configuration
Example Configuration
Section titled “Example Configuration”<PivotViewer data={items} dimensions={dimensions} filters={filters} defaultDimensionKey="status" cardRenderer={renderCard} detailRenderer={renderDetails} getItemId={(item) => item.id} searchFields={[item => item.title, item => item.description, item => item.assignee]} className="my-pivot-viewer" emptyContent={<div>No items match your filters</div>} isLoading={isLoadingData} colors={{ primaryColor: '#4CAF50', surfaceGround: '#1a1a1a', surfaceCard: '#2d2d2d' }}/>Color Customization
Section titled “Color Customization”Customize the color scheme:
const customColors = { primaryColor: '#0066cc', // Primary accent color surfaceGround: '#ffffff', // Main background surfaceCard: '#f5f5f5', // Card backgrounds textColor: '#333333', // Text color surfaceBorder: '#e0e0e0' // Border color};
<PivotViewer colors={customColors} // ... other props/>Loading State
Section titled “Loading State”Show a loading indicator while data is being fetched:
const [data, setData] = useState([]);const [loading, setLoading] = useState(true);
useEffect(() => { fetchData().then(result => { setData(result); setLoading(false); });}, []);
<PivotViewer data={data} isLoading={loading} // ... other props/>Empty State
Section titled “Empty State”Customize the message when filters return no results:
<PivotViewer emptyContent={ <div className="empty-state"> <i className="pi pi-inbox" style={{ fontSize: '3rem' }} /> <h3>No results found</h3> <p>Try adjusting your filters</p> </div> } // ... other props/>Search Configuration
Section titled “Search Configuration”Specify which fields should be searchable by passing accessor functions:
<PivotViewer searchFields={[item => item.title, item => item.description, item => item.tags, item => item.author]} // ... other props/>The global search will look for matches in all specified fields.