Documentation
Chart Columns
Visualize array data directly in your table cells with built-in chart columns. Simple Table supports line/area charts and bar charts, making it easy to display trends, comparisons, and time-series data without external visualization libraries.
✨ New in v1.8.1
Chart columns are a powerful new feature that lets you visualize numeric array data inline, with smart copy/paste functionality that works seamlessly with spreadsheet applications.
Basic Usage
To add chart columns to your table, simply set the type property in your column definition to either "lineAreaChart" or "barChart". The cell data should be an array of numbers.
1import { SimpleTable, HeaderObject } from "simple-table-core";23const headers: HeaderObject[] = [4 {5 accessor: "product",6 label: "Product",7 width: 180,8 type: "string",9 },10 {11 accessor: "monthlySales",12 label: "Monthly Sales (12mo)",13 width: 150,14 type: "lineAreaChart",15 tooltip: "Sales trend over the past 12 months",16 align: "center",17 },18 {19 accessor: "quarterlyRevenue",20 label: "Quarterly Revenue",21 width: 140,22 type: "barChart",23 tooltip: "Revenue by quarter",24 align: "center",25 },26];2728const rows = [29 {30 id: 1,31 product: "Laptop Pro",32 monthlySales: [150, 165, 142, 178, 195, 188, 203, 215, 198, 225, 240, 235],33 quarterlyRevenue: [45000, 52000, 48000, 61000],34 },35 {36 id: 2,37 product: "Wireless Mouse",38 monthlySales: [300, 315, 328, 342, 338, 355, 370, 368, 382, 395, 408, 415],39 quarterlyRevenue: [12000, 15000, 18000, 21000],40 },41];4243<SimpleTable44 defaultHeaders={headers}45 rows={rows}46 rowIdAccessor="id"47/>
Chart Types
Line/Area Chart
Line and area charts are perfect for showing trends over time. They work best with continuous data like daily metrics, monthly sales, or historical performance data.
1{2 accessor: "dailyViews",3 label: "Daily Views (30d)",4 width: 150,5 type: "lineAreaChart",6 tooltip: "Daily page views for the past 30 days",7 align: "center",8}910// Data structure11const row = {12 dailyViews: [500, 520, 485, 550, 575, 590, 610, ...], // 30 values13};
Bar Chart
Bar charts excel at comparing discrete values across categories. They're ideal for quarterly data, weekly summaries, or any scenario where you need to compare distinct values.
1{2 accessor: "weeklyOrders",3 label: "Weekly Orders",4 width: 130,5 type: "barChart",6 tooltip: "Orders per week over the past 7 weeks",7 align: "center",8}910// Data structure11const row = {12 weeklyOrders: [23, 28, 31, 25, 29, 35, 38], // 7 values13};
Smart Copy-Paste Functionality
Chart columns include intelligent copy-paste behavior that makes working with array data seamless. Data is automatically formatted for human readability and spreadsheet compatibility.
✅ Copy (Cmd/Ctrl + C)
When copying chart columns, the array data is formatted as comma-separated values:
Input: [10, 15, 12, 18, 25]
Copied as: "10, 15, 12, 18, 25"
This format is human-readable and pastes perfectly into Excel, Google Sheets, or any text editor. Values are tab-separated between columns for standard clipboard compatibility.
✅ Paste (Cmd/Ctrl + V)
When pasting into chart columns, comma-separated values are automatically parsed back into number arrays:
Paste: "10, 15, 12, 18, 25"
Parsed as: [10, 15, 12, 18, 25]
- Non-numeric values are automatically converted to 0
- Works seamlessly when copy/pasting chart data within the table
- Paste data from external sources like Excel or CSV files
✅ Delete (Delete/Backspace)
When deleting chart column cells, they're cleared to an empty array:
After delete: []
The chart component handles empty arrays gracefully by rendering nothing, keeping your table clean and consistent.
Common Use Cases
- E-commerce Analytics: Display monthly sales trends, daily page views, and quarterly revenue comparisons for products.
- Server Monitoring: Visualize CPU usage history, memory trends, and network traffic patterns over time.
- Financial Dashboards: Show stock price movements, portfolio performance, and quarterly earnings trends.
- Marketing Reports: Track campaign performance, conversion rates, and engagement metrics across time periods.
- Operational Metrics: Monitor response times, request volumes, and error rates for microservices and APIs.
Live Updates with Charts
Chart columns work seamlessly with Simple Table's live update functionality. You can update chart data in real-time while maintaining a fixed array length by adding new values and removing old ones.
1// Example: Update CPU history with live data2const updateCPUHistory = (rowIndex: number, newValue: number) => {3 const row = data[rowIndex];4 const currentHistory = row.cpuHistory as number[];56 // Add new value and remove oldest (keep array length constant)7 const updatedHistory = [...currentHistory.slice(1), newValue];89 tableRef.current?.updateData({10 accessor: "cpuHistory",11 rowIndex: rowIndex,12 newValue: updatedHistory,13 });14};1516// Use with setInterval or WebSocket for real-time updates17useEffect(() => {18 const interval = setInterval(() => {19 const newCPU = Math.random() * 100; // Simulate CPU reading20 updateCPUHistory(0, newCPU);21 }, 1000);2223 return () => clearInterval(interval);24}, []);
Check out the Infrastructure Example to see live-updating CPU history charts in action.
Chart Customization
Use the chartOptions property to customize the appearance and behavior of your chart columns. You can control dimensions, colors, scaling, and other visual aspects.
1// Line/area chart with custom options2{3 accessor: "cpuHistory",4 label: "CPU Usage",5 type: "lineAreaChart",6 width: 150,7 chartOptions: {8 min: 0, // Minimum value for scaling9 max: 100, // Maximum value for scaling10 width: 120, // Chart width in pixels11 height: 35, // Chart height in pixels12 color: "#3b82f6", // Line color (overrides theme)13 fillColor: "#93c5fd", // Area fill color14 fillOpacity: 0.3, // Fill opacity (0-1)15 strokeWidth: 2 // Line thickness16 }17}1819// Bar chart with custom options20{21 accessor: "quarterlyRevenue",22 label: "Quarterly",23 type: "barChart",24 width: 140,25 chartOptions: {26 min: 0, // Minimum value for scaling27 max: 100000, // Maximum value for scaling28 width: 120, // Chart width in pixels29 height: 40, // Chart height in pixels30 color: "#10b981", // Bar color (overrides theme)31 gap: 3 // Gap between bars in pixels32 }33}
Available Options
min- Custom minimum value for chart scalingmax- Custom maximum value for chart scalingwidth- Custom chart width in pixels (default: 100)height- Custom chart height in pixels (default: 30)color- Custom chart color (overrides theme color)fillColor- Custom fill color for area charts (overrides theme color)fillOpacity- Fill opacity for area charts (default: 0.2)strokeWidth- Line stroke width (default: 2)gap- Gap between bars in bar charts (default: 2)
💡 Theme Colors
Charts use theme-specific colors by default. You can override them with custom colors in chartOptions. The default theme colors are controlled by --st-chart-color and --st-chart-fill-color CSS variables.
Best Practices
- Keep arrays consistent: Use the same array length across all rows in a chart column for uniform visualization.
- Choose appropriate widths: Set column widths between 120-180px for optimal chart visibility without overwhelming the table.
- Use tooltips: Add descriptive tooltips to help users understand what the chart data represents.
- Center alignment: Charts typically look best with
align: "center". - Line charts for trends: Use lineAreaChart for continuous data where the trend matters more than individual points.
- Bar charts for comparisons: Use barChart for discrete periods or categories where comparing individual values is important.
- Maintain fixed length: When updating chart data in real-time, keep the array length constant by removing old values as you add new ones.