Dear Dess,
Thanks for your feedback and sample project. Appreciated.
A User Control was implemented based on your project a some minors changes.
Three (3) testing scenarios were performed as described below:
- 100 points adding one (1) value/sample with a timer from the Main Form @10ms.
- 1000 points adding one (1) value/sample with a timer from the Main Form @10ms.
- 10000 points adding 100 value/sample with a timer from the Main Form @1ms. I also adjusted the ramp increment/decrement value.
Attached some videos (gif) of the testing as well.
Our goal is to have real time chart that could manage to add from 1 to 100 new points at the same time, and keep in the screen 10.000 points. Considering this request, may you suggest an approach to improve the performance?
Thanks for your attention
Hu
public
partial
class
UserControlRealTimeBarChartView : UserControl
{
Random rnd =
new
Random();
FastLineSeries series =
new
FastLineSeries();
Dictionary<
string
,
double
?> categoryValuePairs =
new
Dictionary<
string
,
double
?>();
public
UserControlRealTimeBarChartView()
{
InitializeComponent();
for
(
int
i = 0; i < 10000; i++)
{
CategoricalDataPoint point =
new
CategoricalDataPoint(0, i);
series.DataPoints.Add(point);
categoryValuePairs.Add(i.ToString(), point.Value);
}
radChartView1.Series.Add(series);
LinearAxis axeY = radChartView1.Axes.Get<LinearAxis>(1);
axeY.Minimum = -50;
axeY.Maximum = 50;
axeY.ClipLabels =
false
;
axeY.ShowLabels =
false
;
axeY.LineWidth = 0;
axeY.TickWidth = 0;
CategoricalAxis axeX = radChartView1.Axes.Get<CategoricalAxis>(0);
axeX.ClipLabels =
false
;
axeX.ShowLabels =
false
;
axeX.LineWidth = 0;
axeX.TickWidth = 0;
radChartView1.View.MinSize =
new
SizeF(0F, 0F);
radChartView1.View.Padding =
new
Padding(0, 0, 0, 0);
radChartView1.View.Margin =
new
Padding(0, 0, 0, 0);
}
int
cnt = 0;
double
ramp = 0;
bool
direction =
false
;
public
void
AddSample()
{
categoryValuePairs[cnt.ToString()] = ramp;
if
(direction)
{
ramp+=0.03;
if
(ramp >= 30)
direction =
false
;
}
else
{
ramp-=0.03;
if
(ramp <= -30)
direction =
true
;
}
cnt++;
if
(cnt >= series.DataPoints.Count)
{
cnt = 0;
}
CategoricalDataPoint point =
null
;
for
(
int
i = 0; i < series.DataPoints.Count; i++)
{
point = (CategoricalDataPoint)series.DataPoints[i];
if
(i >= cnt && i < cnt + 5)
{
point.Value =
null
;
}
else
{
point.Value = categoryValuePairs[point.Category.ToString()];
}
}
}
}