c# - ASP chart StackedColumn100 add percent symbol (%) on values -
i have chart (using chart control build-in on .net):
how add percent sign (%) behind of values (for example 44 => 44%, 56 => 56% , on)
edit (after tried jstreet
's sugesstions in comment): stackedcolumn100 chart values percentages.
tried <asp:series label="#val%">
, got this: (notice 0 values showing don't want, used these codes hide 0 values initially):
protected void requestchart_customize(object sender, eventargs e) { //hide label value if 0 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 working me: labelformat="{0}%"
, change {0}
{0.0}
or {0.00}
depend on how want display values.
btw, hide 0 values on chart, add customize event chart:
protected void requestchart_customize(object sender, eventargs e) { //hide label value if 0 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; } } } }
Comments
Post a Comment