Hi,
How I can improve the radChart performance when I do a (Window) resizing or zooming ?
I need to show several lineseries with several thousand of points. I'm okay of loading the data to series (it takes around 2-3sec) but after that if I wan't to do windows resizing or zooming, it's lock the UI and takes more than 10sec (if I have 5 series or more loaded to screen) to refresh the screen !!??
I really need to show the actual data so I cannot use the SamplingThreshold - feature
Can I disable redraw or something during the zooming/resizing?
Here's the full code of my demo project.
How I can improve the radChart performance when I do a (Window) resizing or zooming ?
I need to show several lineseries with several thousand of points. I'm okay of loading the data to series (it takes around 2-3sec) but after that if I wan't to do windows resizing or zooming, it's lock the UI and takes more than 10sec (if I have 5 series or more loaded to screen) to refresh the screen !!??
I really need to show the actual data so I cannot use the SamplingThreshold - feature
Can I disable redraw or something during the zooming/resizing?
Here's the full code of my demo project.
public partial class MainWindow : Window
{
private DataTable dt = null;
public MainWindow()
{
InitializeComponent();
radChart1.DefaultView.ChartArea.EnableAnimations = false;
radChart1.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
//radChart1.SamplingSettings.SamplingFunction = ChartSamplingFunction.Average;
radChart1.SamplingSettings.SamplingThreshold = 0;
radChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "HH:mm:ss";
radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
radChart1.DefaultView.ChartArea.AxisX.AutoRange = false;
radChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;
radChart1.DefaultView.ChartArea.AxisX.MinValue = DateTime.Now.ToOADate();
radChart1.DefaultView.ChartArea.AxisX.MaxValue = DateTime.Now.AddMinutes(5000).ToOADate();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
dt = CreateDataTable("SERIES_" + radChart1.SeriesMappings.Count.ToString());
MessageBox.Show("Data generated for series: " + "SERIES_" + radChart1.SeriesMappings.Count.ToString());
AddNewSeries("SERIES_" + radChart1.SeriesMappings.Count.ToString());
}
private void AddNewSeries(String tag)
{
AxisY axisY = new AxisY();
axisY.AxisName = tag;
axisY.Title = tag;
axisY.DefaultLabelFormat = "#VAL{#,##0.00}";
axisY.AutoRange = false;
axisY.MinValue = 0;
axisY.MaxValue = 200;
axisY.Step = 10;
Style customAxisYStyle = this.Resources["CustomAxis"] as Style;
axisY.AxisStyles.AxisLineStyle = customAxisYStyle;
axisY.AxisStyles.TickLineStyle = this.Resources["AxisYTickStyle"] as Style;
axisY.AxisStyles.MinorTickLineStyle = this.Resources["AxisYMinorTickStyle"] as Style;
axisY.AxisStyles.ItemLabelStyle = this.Resources["ItemLabelStyle"] as Style;
axisY.AxisStyles.TitleStyle = this.Resources["AxisTitleStyle"] as Style;
if (radChart1.DefaultView.ChartArea.AxisY.AxisName == "")
{
radChart1.DefaultView.ChartArea.AxisY = axisY;
}
else
{
radChart1.DefaultView.ChartArea.AdditionalYAxes.Add(axisY);
axisY.Visibility = System.Windows.Visibility.Collapsed;
}
LineSeriesDefinition seriesDef = new LineSeriesDefinition();
seriesDef.ShowItemLabels = false;
seriesDef.ShowPointMarks = false;
seriesDef.ShowItemToolTips = false;
seriesDef.SeriesName = tag;
SeriesMapping m1 = new SeriesMapping();
m1.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = tag, FieldType = typeof(double) });
m1.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XValue, FieldName = tag + "_TS", FieldType = typeof(DateTime) });
m1.SeriesDefinition = seriesDef;
m1.LegendLabel = tag;
m1.SeriesDefinition.AxisName = axisY.AxisName;
m1.ItemsSource = dt;
radChart1.SeriesMappings.Add(m1);
}
DataTable CreateDataTable(String tagName)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn(tagName, typeof(Double)));
dt.Columns.Add(new DataColumn(tagName + "_TS", typeof(DateTime)));
Random r = new Random(Environment.TickCount);
for (int i = 0; i < 5000; i++)
{
DataRow dr = dt.NewRow();
if (radChart1.DefaultView.ChartArea.HasItems)
dr[tagName] = r.Next(1, 100);
else
dr[tagName] = r.Next(1, 100);
dr[tagName + "_TS"] = DateTime.Now.AddMinutes(i);
dt.Rows.Add(dr);
}
return dt;
}
}