(Edited to add code blocks)
I am trying to draw 4 series simultaneously on a chart. I have 2 Scatter plot series, a FastLineRenderableSeries (Which I’ll call the trendline) and I have a FastErrorBarsRenderableSeries which I’ll call the uncertainty. The scatter plots always draw.
When I draw the scatter plots and the trendline, everything looks right. As soon as I add any points to the HlcDataSeries in the uncertainty, though, the trendline disappears, and the error bars won’t draw. It’s very strange.
Below is my xaml and code (edited for clarity).
void SetData(int channels, MyDataSet incomingData){
var n = incomingData.Count;
var unc = new List<Point>(n); //Point has x y coords and uncertainty
double[] xValues = new double[n], yValues = new double[n];
for (int i = 0; i < n; i++)
{
var x = incomingData[i].X.Value; //Incoming data has x y coords
//with uncertainties in each direction
var y = incomingData[i].Y.Value;
xValues[i] = x;
yValues[i] = y;
var yVal = incomingData[i].Y;
if (yVal is not { Uncertainty: not null and not 0 }) continue;
unc.Add(incomingData[i]);
}
if (xValues.Any())
PointData = new XyDataSeries<double>(xValues, yValues);
var xList = new double[channels];
var yList = new double[channels];
if (incomingData.CalibrationCoefficients == null)
{
incomingData.Fit(); //Generate coefficients
}
for (var i = 0; i < channels; i++)
{
xList[i] = i;
yList[i] = incomingData.GetY(i); //Apply Coefficients
}
LineData = new XyDataSeries<double>(xList, yList);
unc.Add(new Point(1, 0, 100, 50)); //x, x uncertainty, y, y uncertainty
unc.Add(new Point(10, 0, 100, 50));//Adding bogus data to ensure uncertainty
unc.Add(new Point(100, 0, 1000, 50));
unc.Add(new Point(1000, 0, 500, 50));
unc.Add(new Point(5000, 0, 250, 50));
if (unc.Any())
{
UncertaintyData = new HlcDataSeries<double, double>();
var hlc = (HlcDataSeries<double, double>)UncertaintyData;
foreach (var t in unc)
{
var uncertainty = Math.Abs(t.Y.Uncertainty);
var y = t.Y.Value;
hlc.Append(t.X.Value, y,
y- uncertainty,
y+ uncertainty);
}
}
}
And my Xaml:
<s:SciChartSurface MinWidth="200" MinHeight="200"
Name="ChartSurface" Padding="0"
Style="{Binding CurrentChartStyle}" >
<s:SciChartSurface.RenderableSeries>
<!-- Scatter plots omitted for brevity -->
<s:FastErrorBarsRenderableSeries DataSeries="{Binding UncertaintyData}"
ErrorDirection="YAxis"
Stroke="Blue"
StrokeThickness="2"
LastErrorBarWidth="7"
DataPointWidthMode="Absolute"
/>
<s:FastLineRenderableSeries x:Name="LineSeries" AntiAliasing="True" Stroke="Gray"
DataSeries="{Binding LineData}" StrokeThickness="2"/>
</s:SciChartSurface.RenderableSeries>
<!-- Axes omitted for brevity -->
</s:SciChartSurface>
- Isaac Sherman asked 2 months ago
- last edited 2 months ago
- Any errors in the Visual Studio output console? There’s a fairly good debug logger built into SciChart which can be enabled by setting SciChartSurface.DebugWhyDoesntSciChartRender = true. Error reasons are listed here https://www.scichart.com/documentation/win/current/webframe.html#SciChart_2D_Troubleshooting.html
- Thank you for the tip! I am seeing something… SciChartSurface didn’t render, because an exception was thrown: Message: Y must be a value between High and Low (Parameter ‘YValues’) It reoccurs quite a bit. I don’t see it on the list provided, but I’ll look into it.
- That got me to the right place. Thank you- the problem was I had High and Low backwards in the Append method, so High was Y-Uncertainty and Low was reversed. Thanks again!
- Strange that should cause an error and chart to crash, but also great than the warning helped you solve the problem! Have a good day
- You must login to post comments
Please login first to submit.