79614587

Date: 2025-05-09 17:16:08
Score: 0.5
Natty:
Report link

Yes, there is a way to format the labels on the Y-Axis.

First, handle the Chart.FormatNumber event.

var chart = new Chart();
chart.FormatNumber += ChartFormatNumber;

In the event handler, filter the labels for the Y-Axis and format them as needed.

private void ChartFormatNumber(object sender, FormatNumberEventArgs e)
{
    /* Process the elements of type 'AxisLabels'. Additionally, filter by Y-Axis. */
    if (e.ElementType == ChartElementType.AxisLabels && sender is Axis axis && axis.AxisName == AxisName.Y)
    {
        /* Format the seconds as 'hh:mm:ss' */
        e.LocalizedValue = TimeSpan.FromSeconds(e.Value).ToString();
    }
}

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Sergey