Hello,Recently I'm using the syncfusion to develop a product,but I'm in troblem with the using of syncfusion chart control.Could you help me to solve it?Thank you very much.
There is a chart and a start button on the window, the chart will display five lines. When I click the start button, the five lines in the chart will be refreshed automaticlly.
To realize the refreshment of the chart, I set a Timer, it's interval is set to 100ms, when I click the start button, the timer is enabled, so the five lines is refreshed every 100ms.
The data of the five lines are fetched from a data acquisition card, I named it data[10000], among it
the data[0] to data[19999] is the y-axis data of point 1 to point 20000 of line 1,
the data[20000] to data[39999] is the y-axis data of point 1 to point 20000 of line 2,
the data[40000] to data[59999] is the y-axis data of point 1 to point 20000 of line 3,
the data[60000] to data[79999] is the y-axis data of point 1 to point 20000 of line 4,
the data[80000] to data[99999] is the y-axis data of point 1 to point 20000 of line 5,
For the second time, data[100000] refreshed ,so
the data[0] to data[19999] is the y-axis data of point 20001 to point 40000 of line 1,
the data[20000] to data[39999] is the y-axis data of point 20001 to point 40000 of line 2,
the data[40000] to data[59999] is the y-axis data of point 20001 to point 40000 of line 3,
the data[60000] to data[79999] is the y-axis data of point 20001 to point 40000 of line 4,
the data[80000] to data[99999] is the y-axis data of point 20001 to point 40000 of line 5,
and so on.
The original x-axis is 0-19999, when timer started the x-axis is automaticlly changed with the enlargement of datas, is 20000-39999, then 40000-59999, 60000-79999 and so on.
The data[100000] is refreshed every timer span, and the 20000 points of 5 lines is refreshed ,the x-axis is also enlarged.
But when I programming as the above method , the running result is not so ideal, almost serval seconds to refresh the screen, the refresh speed is too low, and this speed I cannot accept at all, but I don't know where the problem is , and I don't know how to improve the program . I have read all the examples, and still don't know .
The following is my program . For making the data easy, I use the random data to take the place of my data acquisition cart data.
Could you help me ? I'm very worry . I hope I can get your answer as soon as possible. Thank you.
[XAML]
window.xaml
<syncfusion:Chart>
<syncfusion:ChartArea Header="Data Acquisition">
<syncfusion:ChartArea.PrimaryAxis>
<syncfusion:ChartAxis Header="Points-X"/>
</syncfusion:ChartArea.PrimaryAxis>
<syncfusion:ChartArea.SecondaryAxis>
<syncfusion:ChartAxis Header="Points-Y"/>
</syncfusion:ChartArea.SecondaryAxis>
<syncfusion:ChartSeries Name="ser1" DataSource="{StaticResource power}" BindingPathX="X" BindingPathsY="Y1"/>
<syncfusion:ChartSeries Name="ser2" DataSource="{StaticResource power}" BindingPathX="X" BindingPathsY="Y2"/>
<syncfusion:ChartSeries Name="ser3" DataSource="{StaticResource power}" BindingPathX="X" BindingPathsY="Y3"/>
<syncfusion:ChartSeries Name="ser4" DataSource="{StaticResource power}" BindingPathX="X" BindingPathsY="Y4"/>
<syncfusion:ChartSeries Name="ser5" DataSource="{StaticResource power}" BindingPathX="X" BindingPathsY="Y5"/>
</syncfusion:ChartArea>
</syncfusion:Chart>
<Button Grid.Row = "1" Name="Start" Click = "Start to refresh"/>
[C#]
window.cs
private Timer timer;
public class PowerCollection : ObservableCollection<Power>
{
public PowerCollection ()
{
X {get;set};
Y1{get;set};
Y2{get;set};
Y3{get;set};
Y4{get;set};
Y5{get;set};
}
}
Start to refresh //When the Start button clicked
{
timer = new Timer();
timer.interval=100;
timer.Tick+=new system.EventHandler(timer_Tick);
timer.enable=true;
}
void timer_Tick()
{
public ObservableCollection<Power> power = new ObservableCollection<Power>;
public rand = new random();
for(int i=0;i<20000;i++)
{
power.Add{X= i,Y1 = rand.Next(0,10), Y2 = rand.Next(10,20), Y3 = rand.Next(20,30), Y4 = rand.Next(30,40), Y5 = rand.Next(40,50)}
}
ser1.DataSource = this.power;
ser2.DataSource = this.power;
ser3.DataSource = this.power;
ser4.DataSource = this.power;
ser5.DataSource = this.power;
}