Reputation: 10108
How do I format the Y axis label so it includes % symbol when using StackedColumn100?
I am using System.Windows.Forms.DataVisualization.Charting.Series charts.
here is my method for defining the chart look and feel (so far)...
private Series SetSeriesStyleStackedColumnPercentage(string sessionname, string color)
{
Series series = new Series(sessionname);
series.ChartType = SeriesChartType.StackedColumn100;
series.Color = Color.FromArgb(byte.Parse(color.Split(',')[0]),
byte.Parse(color.Split(',')[1]),
byte.Parse(color.Split(',')[2]),
byte.Parse(color.Split(',')[3]));
series.BorderWidth = 1;
series.BorderColor = Color.FromArgb(255, 0, 0, 0);
series.IsVisibleInLegend = true;
series.IsValueShownAsLabel = false;
return series;
}
Upvotes: 0
Views: 1519
Reputation: 54453
There is no magic needed, just escape the percent character:
chart1.ChartAreas[yourCharArea].AxisY.LabelStyle.Format = "###0\\%";
or
chart1.ChartAreas[yourCharArea].AxisY.LabelStyle.Format = "###0.0\\%";
or whatever numeric formatting you need..
Upvotes: 2