Chart Provider
ChartProvider wraps individual chart components to provide shared state, configuration, and context. It serves as the foundation for building data visualizations using Paste’s charting system powered by Highcharts.Chart Provider is currently in beta. The API may change in future releases.
Installation
Usage
With Highcharts Options
Use native Highcharts configuration:With Paste Chart Options
Use Paste’s simplified chart configuration API:Line Chart Example
Bar Chart Example
Pie Chart Example
Props
Chart components that will use the provider’s configuration and state.
Paste’s simplified chart configuration object. Use this OR
highchartsOptions, not both.Native Highcharts configuration object. Use this OR
options, not both. Provides full control over chart configuration.Overrides the default element name for customization.
Chart Context
ChartProvider creates a context that child components can access to:- Access the Highcharts chart instance
- Read chart configuration
- Subscribe to chart updates
- Interact with the chart programmatically
Best Practices
Do
- Use ChartProvider as the wrapper for all Paste chart components
- Choose either
optionsorhighchartsOptions, not both - Keep chart configurations simple and focused
- Use appropriate chart types for your data
- Provide meaningful titles and axis labels
- Test charts with real data volumes
Don’t
- Don’t provide both
optionsandhighchartsOptionsprops - Don’t create charts without proper labeling
- Don’t use complex chart types when simple ones suffice
- Don’t forget to handle loading and error states
- Don’t display charts without context or description
Choosing Chart Types
- Line charts: Trends over time
- Bar/Column charts: Comparing categories
- Pie charts: Part-to-whole relationships (use sparingly)
- Area charts: Volume over time
- Scatter plots: Correlations between variables
Accessibility
- Provide descriptive chart titles
- Ensure sufficient color contrast between data series
- Don’t rely on color alone to convey information
- Consider providing data tables as alternatives
- Use patterns or textures in addition to colors when needed
- Ensure charts are keyboard navigable
- Provide text descriptions for complex visualizations
Performance
- Limit data points for better performance (consider data aggregation)
- Use appropriate update mechanisms for real-time data
- Consider loading states for async data
- Optimize re-renders by memoizing chart options
Related Components
- Data Grid - Tabular data display
- Chart components - Specific chart implementations