How do I format values with custom string formats?

2

I'm developing a chart and would like to put the Y-axis values as shown below:

Ihavefoundthatyoucandothisthrough custom strings formats in this way ChartArea.AxisY.LabelStyle.Format = "formato customizado" , but I could not create a format for output that I need, does anyone have any idea what format to use to get the expected output?

Search Items : Formatting chart axis labels
Format value with Brazilian currency mask

    
asked by anonymous 01.04.2015 / 19:44

1 answer

2

The question has been changed and I will try to save the answer as far as I can.

Use this:

private void chart1_FormatNumber(object sender, System.Windows.Forms.DataVisualization.Charting.FormatNumberEventArgs e) {
    if(e.ElementType == System.Windows.Forms.DataVisualization.Charting.ChartElementType.AxisLabels) {
        switch(e.Format) {
            case "formato customizado":
                e.LocalizedValue = string.Format(CultureInfo.CreateSpecificCulture("pt-BR"), "{0:F1}", e.Value / 1000);
                break;
            default:
                break;
        }
    }
}

See the formatting result only in dotNetFiddle

Based on this answer in the SO .

    
01.04.2015 / 19:53