0

I have drawn a MVC chart

MVC Chart

In the Y-axis I need to show the Currency value with currency symbol. Fo that I have used below code

         // Set the Custom Labebls
        CustomLabel onPremXLabel = new CustomLabel(-0.5, 0.5, "On   Premises", 0, LabelMarkStyle.None);
        CustomLabel azureXLabel = new CustomLabel(0.75, 1.25, "Azure", 0, LabelMarkStyle.None);
        chartArea.AxisX.CustomLabels.Add(onPremXLabel);
        chartArea.AxisX.CustomLabels.Add(azureXLabel);
        chartArea.AxisY.LabelStyle.Format = "C";
        new Font("Verdana,Arial,Helvetica,sans-serif",
                 8F, FontStyle.Regular);
        chartArea.AxisY.LabelStyle.Font =
           new Font("Verdana,Arial,Helvetica,sans-serif",
                    8F, FontStyle.Regular);
        chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
        chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
        chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
        chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);

        chart.ChartAreas.Add(chartArea);

"chartArea.AxisY.LabelStyle.Format = "C";" This code is for setting the currency in the y-Axis. Now I wanted to customize the Currency symbol according to the Inputs selected by the User. For example If user select US dollar or Pound than the respective Symbol should be displayed. Please Please help.

Avinash Roy
  • 25
  • 1
  • 9

1 Answers1

0

Did you tried to get currency as string and send it to y-axis as string it's probably gonna show the sign of it.

public static class Cultures
{
    public static readonly CultureInfo UnitedKingdom = 
        CultureInfo.GetCultureInfo("en-GB");
}

Then:

@price.ToString("C", Cultures.UnitedKingdom)

You should check out this page (not mvc but works for you too probably).

String format currency

Community
  • 1
  • 1
Turquase
  • 83
  • 1
  • 12