|
Obtaining Y axis data in multi-axis application |
Posted by Darryl on May-13-2021 16:35 |
|
Hi,
I have a real time application that has 4 Y axis. The application has a cursor that needs to be assigned to a selected Y axis. My problem is I cannot see a way to extract data for axis 3 and 4. The application structure is based on provided real time examples.
I have a chart drawing routine (snippet below) Y axis 3 and 4 defined Y3 & Y4. Works as expected.
private void drawChart(WPFChartViewer viewer)
{
.
.
XYChart c = new XYChart(840, 500);
.
//Adding 2 Y axis in addition to c.yAxis() and c.yAxis2()
Axis Y3 = c.addAxis(Chart.Right, axis3pos);
Axis Y4 = c.addAxis(Chart.Right, axis4pos);
.
.
//Displaying traces
case AxisId.AXIS3:
Y3.setTitle(trace.DisplayName, "Arial", 12);
layer3.setXData(traceData.Time);
layer3.addDataSet(traceData.Series, trace.DisplayColour,
trace.DisplayName);
break;
case AxisId.AXIS4:
Y4.setTitle(trace.DisplayName, "Arial", 12);
layer4.setXData(traceData.Time);
layer4.addDataSet(traceData.Series, trace.DisplayColour,
trace.DisplayName);
break;
.
.
viewer.Chart = c;
}
Then there's a routine for the cursor display (snippet below).
Obtaining data for c.yAxis() and c.yAxis2 works fine, but I cannot see how to obtain the data for my Y3 and Y4 axis.
private void DrawTrackLine(XYChart c, ................)
{
.
double yValue;
.
//Getting the selected Y axis value
yValue = c.getYValue(line.Yposn, c.yAxis());
//OR
yValue = c.getYValue(line.Yposn, c.yAxis2());
.
.
// How to obtain data for axis Y3 and Y4 ????
}
Thanks for any assistance.
Darryl |
Re: Obtaining Y axis data in multi-axis application |
Posted by Peter Kwan on May-13-2021 22:31 |
|
Hi Darryl,
You can use:
y3Value = c.getYValue(line.Yposn, Y3);
y4Value = c.getYValue(line.Yposn, Y4);
That means you have to declare Y3 and Y4 as member variables of the Window, instead of as local variable inside drawChart.
// declare the axes variables here
private Axis Y3;
private Axis Y4;
private void drawChart(WPFChartViewer viewer)
{
.
.
XYChart c = new XYChart(840, 500);
.
//Adding 2 Y axis in addition to c.yAxis() and c.yAxis2()
Y3 = c.addAxis(Chart.Right, axis3pos);
Y4 = c.addAxis(Chart.Right, axis4pos);
.
}
Regards
Peter Kwan |
|