我需要在同一个二维图(LightningChart.ViewXY)上显示电压和电流。为了使值保持可见比例,我使用了 2 个不同的轴。但是我和我的客户想确保零在两个不同的轴之间始终对齐。这可能吗?如果可以,我该怎么做?
问问题
399 次
1 回答
1
Thanks Eric for asking this. The chart and axes have events to aid you with custom handling of cases like this. As far as remember there is no property to several YAxes at same horizontal position, e.g. Zoomed, Panned event handle and modify Axis’ range accordingly. Below is example how to fix reference value of two axes (same segment) to the middle of graph area.
private void ViewXY_Zoomed(object sender, Arction.Wpf.Charting.Views.ViewXY.ZoomedXYEventArgs e)
{
AxisY axis0 = _chart.ViewXY.YAxes[0];
AxisY axis1 = _chart.ViewXY.YAxes[1];
// get segment top & bottom coordinates [PX]
GraphSegmentInfo gsi = _chart.ViewXY.GetGraphSegmentInfo();
float fTop = gsi.SegmentTops[0];
float fBottom = gsi.SegmentBottoms[0];
int iScreenCoordForRefValue = (int)(fTop + fBottom) / 2;
float fAxis0RefValue = 50, fAxis1RefValue = 0;
double dAxis0ValueAtCoord, dAxis1ValueAtCoord;
axis0.CoordToValue(iScreenCoordForRefValue, out dAxis0ValueAtCoord, false);
axis1.CoordToValue(iScreenCoordForRefValue, out dAxis1ValueAtCoord, false);
// pan Axis' RefValue position at RefScreenCoord
double dNewMinAxis0 = axis0.Minimum - (dAxis0ValueAtCoord - fAxis0RefValue);
double dNewMaxAxis0 = axis0.Maximum - (dAxis0ValueAtCoord - fAxis0RefValue);
double dNewMinAxis1 = axis1.Minimum - (dAxis1ValueAtCoord - fAxis1RefValue);
double dNewMaxAxis1 = axis1.Maximum - (dAxis1ValueAtCoord - fAxis1RefValue);
_chart.BeginUpdate();
axis0.SetRange(dNewMinAxis0, dNewMaxAxis0);
axis1.SetRange(dNewMinAxis1, dNewMaxAxis1);
_chart.EndUpdate();
}
于 2018-12-25T08:46:01.977 回答