I have this chart (using Chart control build-in on .NET):
How do I add percent sign (%) behind of all values (for example 44 => 44%, 56 => 56% and so on)
Edit (after tried jstreet
's sugesstions in comment): StackedColumn100 chart so values are already percentages.
Tried <asp:Series Label="#VAL%">
, got this: (notice that the 0 values are showing up which I don't want, I used these codes to hide those 0 values initially):
protected void RequestChart_Customize(object sender, EventArgs e)
{
//hide label value if zero
foreach (System.Web.UI.DataVisualization.Charting.Series series in RequestChart.Series)
{
foreach (System.Web.UI.DataVisualization.Charting.DataPoint point in series.Points)
{
if (point.YValues.Length > 0 && (double)point.YValues.GetValue(0) == 0)
{
point.IsValueShownAsLabel = false;
}
}
}
}
Tried <asp:Series LabelFormat="P2">
, got this
This is working for me: LabelFormat="{0}%"
, change {0}
to {0.0}
or {0.00}
depend on how do you want to display those values.
BTW, to hide 0 values on the chart, add this Customize event to your chart:
protected void RequestChart_Customize(object sender, EventArgs e)
{
//hide label value if zero
foreach (System.Web.UI.DataVisualization.Charting.Series series in RequestChart.Series)
{
foreach (System.Web.UI.DataVisualization.Charting.DataPoint point in series.Points)
{
if (point.YValues.Length > 0 && (double)point.YValues.GetValue(0) == 0)
{
point.IsValueShownAsLabel = false;
}
}
}
}