I am creating a chart that uses an XML file that holds data in a tabular format (headers and rows) that i covert to a datatable of strings and then try to convert each column/row value to a double to populate an XYDataSeries object. Sometimes the amount of data is very large which can take 10-15 seconds to process, which is not ideal for the application it is used in.
What i would like to do is create placeholder XYDataSeries that have a series name and dynamically create the data and YAxis when the series is selected initially from the legend.
Is this possible? I have tried in the past but have issues with the data being null.
- Alex Whiteley asked 4 years ago
- You must login to post comments
You could … try to create an empty XyDataSeries with series name and assign to your RenderableSeries, then update it later.
For example, some psuedo-code:
// Setup chart with empty dataseries
var xyData = new XyDataSeries<double,double>() { SeriesName = "my Series" };
var renderSeries = new FastLineRenderableSeries() { DataSeries = xyData};
sciChartSurface.RenderableSeries.Add(renderSeries);
Tuple<double[], double[]> xyValues = await GetLongRunningOperation();
xyData.Append(xyValues.Item1, xyValues.Item2);
// ...
public async Tuple<double[], double[]> GetLongRunningOperation()
{
// fetch long running operation in Task
// pack XValues into Tuple.Item1, YValues into Tuple.Item2
// return to caller
}
I am not sure exactly how this will behave but I think it will add a series to the legend before data, then update with data once it is available.
You could also go a little further and preload the XyDataSeries with some dummy data / set opacity or something to 50% to show that it is loading. For example.
// Setup chart with empty dataseries
var xyData = new XyDataSeries<double,double>() { SeriesName = "my Series [LOADING]" };
xyData.Append(dummyXValues, dummyYValues);
var renderSeries = new FastLineRenderableSeries() { DataSeries = xyData, Opacity = 0.5 };
sciChartSurface.RenderableSeries.Add(renderSeries);
Tuple<double[], double[]> xyValues = await GetLongRunningOperation();
xyData.Clear();
xyData.SeriesName = "my Series";
renderSeries.Opacity = 1;
xyData.Append(xyValues.Item1, xyValues.Item2);
Let me know if this helps!
Best regards,
Andrew
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
Please login first to submit.