ChartEx
is a WinForms Chart
wrapper which optimizes rendering of huge portions of data.
ChartEx
optimizes displaying of huge portions of data on a single Chart
Control from .NET WinForms Framework.
While simple Chart
doesn't allow threading it will take some time for Chart
to render huge portions of data, ChartEx
wraps the Chart
and efficiently solves the problem.
See it in action. Rendering of 6 series with 10,000 points in each. Update-rate 100 ms.
![Image](https://raw.githubusercontent.com/adya/ChartEx/master/wiki/ce.gif)See it in action. Scaling of 6 series with 10,000 points in each. Update-rate 100 ms.
![Image](https://raw.githubusercontent.com/adya/ChartEx/master/wiki/ce2.gif)ChartEx
utilized all data management and provides a way to specify one of the predefined or custom data approximation algorithms.
The key for this problem was to reduce amount of points to be rendered (since points were lose too each other and most of them were rendered on the top of each other which is redundant).
These algorithms determines major and minor data array peeks and renders on the Chart
only major points.
Furthermore, it behaves in the same way when scaling the Chart
: if there are still lots of points ChartEx
will apply approximation to the scaled area.
Chart chart = new Chart();
ChartEx chartEx = new ChartEx(chart);
Approximation algorithm is provided by IChartExSelector
interface.
chartEx.SelectionMethod = new MyApproximationSelector();
You can set either predefined selector or create your own.
a) ChartEx
comes with predefined IChartExSelector
's:
ChartExSimpleSelector
- Evenly selects points; (default selector)ChartExPeekSelector
- Selects stationary points;ChartExDeltaPeekSelector
- Selects stationary points which have delta between two consecutive points greater than specified threshold value;ChartExSavitzkyGolaySelector
- Selects points using Savitzky–Golay filter;
b) To create custom selector you have to implement IChartExSelector
.
Example:
class ChartExSimpleSelector : IChartExSelector
{
private int GetStep(int amountOfPoints, int maxRenderedPoints)
{
return (int)Math.Ceiling((double)amountOfPoints / maxRenderedPoints);
}
public List<PointF> Select(List<PointF> candidatePoints, int maxPoints)
{
List<PointF> resultPoints = new List<PointF>();
int step = GetStep(candidatePoints.Count, maxPoints);
for (int i = 0; i < candidatePoints.Count; i += step)
resultPoints.Add(candidatePoints[i]);
return resultPoints;
}
}
- You can create
SeriesEx
as you usually do with regularSeries
SeriesEx seriesEx = new SeriesEx("Name"); // SeriesEx wraps regular Series.
- Or wrap an existing series
Series series = new Series("Regular");
SeriesEx seriesEx = new SeriesEx(series);
- Add created seriesEx
chartEx.Series.Add(seriesEx);
Points added through
Add
method of the regular series will not be observable and thereforeChartEx
won't refresh approximation.
Since ChartEx
and SeriesEx
were designed as wrappers you are able to access their wrapped objects by WrappedChart
and WrappedSeries
respectivelyю
For example, change series ChartType
to line:
seriesEx.WrappedSeries.ChartType = SeriesChartType.Line;
Or set range of chart's X-axis:
chartEx.WrappedChart.ChartAreas[0].AxisX.Minimum = 0;
chartEx.WrappedChart.ChartAreas[0].AxisX.Maximum = 100;