Specific custom y axis labels
Posted: Tue Jan 28, 2025 12:13 pm
Hey
we are adding few FastLines to the chart, and for every FastLine we create y axis and attach him to it.
every y axis have Min and Max using the 'SetMinMax' method.
i want only 2 labels on every y axis:
1. the minimum value at the bottom
2. the maximum value at the top
this is what i tried:
this works fine most of the time. but in some Minimum and maximum values i cant see the minimum label.
for example, when the minimum of the axis is -500 and the maximum is 500, no minimum label.
any suggestions?
we are adding few FastLines to the chart, and for every FastLine we create y axis and attach him to it.
every y axis have Min and Max using the 'SetMinMax' method.
i want only 2 labels on every y axis:
1. the minimum value at the bottom
2. the maximum value at the top
this is what i tried:
Code: Select all
private Axis CreateCustomYAxis(SignalModel signal, double relativePosition)
{
var color = ChartDataToZData.MColorToDColor(signal.Color);
var yAxis = new Axis
{
Visible = false,
Horizontal = false,
Grid = { Visible = false },
Labels = { Font = { Color = color } },
AxisPen = { Color = color, Visible = true },
Ticks = { Color = color },
RelativePosition = relativePosition
};
yAxis.SetMinMax(signal.MinOrFactor, signal.MaxOrOffset);
yAxis.GetAxisDrawLabel += YAxis_GetAxisDrawLabel;
return yAxis;
}
private void YAxis_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
if (sender is Axis axis) // Cast sender to Axis
{
if (e.LabelValue != axis.Minimum && e.LabelValue != axis.Maximum)
e.Text = ""; // Hide all other labels
}
}
for example, when the minimum of the axis is -500 and the maximum is 500, no minimum label.
any suggestions?