2016-08-05 125 views
0

我已經繪製的MVC圖MVC圖表Y軸定製

MVC Chart

在Y軸我需要顯示與貨幣符號的貨幣值。 Fo我以下使用代碼

  // 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「;」 此代碼用於設置Y軸的貨幣。現在我想根據用戶選擇的輸入自定義貨幣符號。例如,如果用戶選擇美元或英鎊比相應的符號應顯示。請請幫忙。

回答

0

您是否試圖將貨幣作爲字符串並將其作爲字符串發送至y軸,可能會顯示其符號。

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

Then: 

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

你應該看看這個頁面(不是mvc,但也適用於你)。

String format currency

+0

對不起,其實我是新來的Stackoverflow。現在我已經編寫了代碼。請幫助 –

+0

編輯答案。 – TuRQuaS3