In my app, I create a custom Y-axis like this:
Code: Select all
public static Axis CreateCustomYAxis(SignalVectorPair svPair)
{
var color = ChartDataToZData.MColorToDColor(svPair.VectorM.Color);
var yAxis = new Axis
{
Visible = false,
Horizontal = false,
Grid = { Visible = false },
Labels = { Font = { Color = color } },
AxisPen = { Color = color, Visible = true, Width = 2 },
Ticks = { Color = color, Visible = true },
PositionUnits = PositionUnits.Pixels
};
if (!string.IsNullOrEmpty(svPair.VectorM.Units))
{
yAxis.Title.Text = $"[{svPair.VectorM.Units}]";
yAxis.Title.Angle = 90;
yAxis.Title.Font.Color = color;
yAxis.Title.Font.Size = yAxis.Labels.Font.Size;
}
yAxis.SetMinMax(svPair.SignalM.MinOrFactor, svPair.SignalM.MaxOrOffset);
return yAxis;
}
Up until now, I handled zooming using the middle mouse scroll. But now I've added support for your default zoom tool (click-and-drag rectangle).
I'm using the Zoomed and UndoneZoom events to re-apply the Y-axis labels, and the events do fire correctly. However, after zooming, the labels appear corrupted — even though debugging confirms they are being set as expected.
I've attached two images:
Before zoom: Y-axis shows 11 labels (as intended).
After zoom: Even though I reset the labels to 11, the axis doesn't render them correctly.
Any idea what could be causing this?
Thanks!