A seaborn-style boxplot plugin for FINOS Perspective with rich hover tooltips and multi-metric support.
✅ Generic categorical grouping - Works with any column names
✅ Multi-metric support - Compare multiple metrics side-by-side
✅ Rich hover tooltips - Detailed statistics on hover
✅ Proper statistics - Uses individual data points, not aggregated data
✅ Seaborn-style - Familiar boxplot visualization
✅ React compatible - Easy integration with React apps
npm install @nipunx1999/perspective-viewer-boxplotimport React, { useEffect, useRef } from 'react';
import perspective from '@finos/perspective';
import '@finos/perspective-viewer';
import '@finos/perspective-viewer-datagrid';
import '@finos/perspective-viewer-d3fc';
// Import the boxplot plugin
import '@nipunx1999/perspective-viewer-boxplot';
function MyComponent() {
const viewerRef = useRef();
useEffect(() => {
const viewer = viewerRef.current;
// Sample data with any categorical column names
const data = [
{ region: 'North', revenue: 25.5, profit: 18.3 },
{ region: 'South', revenue: 32.1, profit: 24.7 },
{ region: 'East', revenue: 28.9, profit: 21.2 },
// ... more data
];
// Create table and load data
const worker = perspective.worker();
const table = worker.table(data);
viewer.load(table);
// Configure boxplot
viewer.restore({
plugin: 'boxplot',
columns: ['region', 'revenue', 'profit'], // categorical + metrics
// OR with explicit grouping:
// group_by: ['region'],
// columns: ['revenue', 'profit']
});
}, []);
return <perspective-viewer ref={viewerRef} />;
}// Plugin detects 'region' as categorical and uses it for x-axis
columns: ['region', 'revenue', 'profit']group_by: ['category_column'],
columns: ['revenue', 'profit']// Shows side-by-side boxplots for each metric
columns: ['department', 'sales', 'expenses', 'profit']The plugin works with any tabular data:
const data = [
{
category: 'A', // Any categorical column name
sales: 25.5, // Any numeric column name
profit: 18.3,
other_col: 'ignore' // Non-selected columns are ignored
},
// ... more rows
];The plugin uses a smart 4-strategy approach:
group_byconfig - Use Perspective's standard group_by- Single categorical - Auto-detect if only one categorical column
- Multiple categorical - Warning + default to first one
- No categorical - Show metrics side-by-side
Hover over any box to see:
- Count, Min, Q1, Median, Q3, Max, Mean
- Number of outliers
- Group and metric names
- Box highlighting on hover
- Smooth animations
- Color-coded legend for multiple metrics
- Uses individual data points (not aggregated)
- Proper quartile calculations
- Outlier detection (1.5 × IQR rule)
- Modern browsers with ES6 support
- WebGL for optimal Perspective performance
- D3.js is bundled - no need to install separately
git clone https://github.com/nipunx1999/perspective-viewer-boxplot
cd perspective-viewer-boxplot
npm install
npm run build # Production build
npm run dev # Development with watch
npm run start # Development serverApache-2.0
Issues and PRs welcome on GitHub!