Bar Graph

Bar Graph

Forum member · Mar 16, 2010
How do I make the labels in a BarSeries graph to be two demicals. If the value is 20. The label on the graph prints "20%". I need it to print "20.0%" Thanks

Re: Bar Graph

Support · Mar 16, 2010
Hello, The XAxis Label can be with two decimals using the following sample code: PercentageXAxis xAxis = new PercentageXAxis(); xAxis.Labels.Add(new PercentageXAxisLabel("0", 0)); xAxis.Labels.Add(new PercentageXAxisLabel("20.00%", 20)); xAxis.Labels.Add(new PercentageXAxisLabel("40.00%", 40)); xAxis.Labels.Add(new PercentageXAxisLabel("60.00%", 60)); xAxis.Labels.Add(new PercentageXAxisLabel("80.00%", 80)); // Create a Indexed 100% Stacked Bar Series Indexed100PercentStackedBarSeries barSeries = new Indexed100PercentStackedBarSeries(xAxis); // Add SeriesElements to the Indexed 100% Stacked Bar Series barSeries.Add(seriesElement1); barSeries.Add(seriesElement2); barSeries.Add(seriesElement3); // Add series to the plot area plotArea.Series.Add(barSeries); Thanks, ceTe Software Support Team

Re: Bar Graph

Forum member · Mar 16, 2010
Here is my code: How do I get the aMeasurement.ColofResults.Item(0).ResultData value to output a decimal value if the value is 20. MyBarSeries1.Values.Add(New Single() {aMeasurement.ColofResults.Item(0).ResultData, aMeasurement.ColofResults.Item(1).ResultData, aMeasurement.ColofResults.Item(2).ResultData}) MyBarSeries1.Color = CmykColor.Black MyBarSeries1.DataLabel = New ValuePositionDataLabel(True, False, False) MyBarSeries1.DataLabel.FontSize = 5.2 MyBarSeries1.DataLabel.Suffix = "%" MyBarSeries1.DataLabel.Font = HelrNarrowFont Thanks

Re: Bar Graph

Support · Mar 16, 2010
Hello, You can use the following code to display the percentage value for the ResultData value: label.ShowPercentage = true; label.ShowValue = false; If you want to display the ResultData as xx.xx% then you will have to do the formatting of the value yourself. Thanks, ceTe Software Support Team

Re: Bar Graph

Forum member · Mar 16, 2010
Thanks, but the label.ShowPercentage = true; Is not option I see.

Re: Bar Graph

Support · Mar 16, 2010
Hello, Following code will allow you to use the ShowPercentage property: Indexed100PercentStackedBarSeriesElement seriesElement1 = new Indexed100PercentStackedBarSeriesElement("Website A"); seriesElement1.Values.Add(new float[] { 5.23f, 7, 9, 6 }); PercentageDataLabel label = new PercentageDataLabel(true); label.ShowPercentage = true; label.Suffix = "%"; seriesElement1.DataLabel = label; Thanks, ceTe Software Support Team

Re: Bar Graph

Forum member · Mar 17, 2010
Thanks, but we are using the IndexedBarSeries. Dim aMeasurement As New Measurement Dim MyBarSeries1 As New IndexedBarSeries("") Dim MyBarSeries2 As New IndexedBarSeries("") Dim MyBarSeries3 As New IndexedBarSeries("", MyXAxis, MyYAxis) For Each aMeasurement In theSubject.ColofMeasurements If StrComp(aMeasurement.MeasurementType, "StateWide", CompareMethod.Text) = 0 Then MyBarSeries3.Color = CmykColor.DarkGray MyBarSeries3.Values.Add(New Single() {aMeasurement.ColofResults.Item(0).ResultData, _ aMeasurement.ColofResults.Item(1).ResultData, _ aMeasurement.ColofResults.Item(2).ResultData}) ' aMeasurement.ColofResults.Item(3).ResultData}) MyBarSeries3.DataLabel = New ValuePositionDataLabel(True, False, False) MyBarSeries3.DataLabel.FontSize = 5.2 MyBarSeries3.DataLabel.Suffix = "%" MyBarSeries3.DataLabel.Font = HelrNarrowFont End If

Re: Bar Graph

Support · Mar 17, 2010
Hello, We will try to do an example using the IndexedBarSeries and we will post it as soon as we have it ready. Thanks, ceTe Software Support Team.

Re: Bar Graph

Support · Mar 18, 2010
Hello, Below is a sample code which will add percentage values. Document document = new Document(); Page page = new Page(); document.Pages.Add(page); Chart chart = new Chart(0, 0, 400, 230); PlotArea plotArea = chart.PrimaryPlotArea; Title title1 = new Title("Website Visitors"); Title title2 = new Title("Year 2007"); chart.HeaderTitles.Add(title1); chart.HeaderTitles.Add(title2); NumericXAxis xAxis = new NumericXAxis(); xAxis.Min = 0; xAxis.Max = 100; xAxis.Interval = 10; IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A", xAxis); barSeries1.Values.Add(new float[] { 50.24F, 40, 90, 20 }); IndexedBarSeries barSeries2 = new IndexedBarSeries("Website B", xAxis); barSeries2.Values.Add(new float[] { 24.76F, 20, 5, 20 }); IndexedBarSeries barSeries3 = new IndexedBarSeries("Website C", xAxis); barSeries3.Values.Add(new float[] { 25, 40, 5, 40 }); BarColumnValuePositionDataLabel label = new BarColumnValuePositionDataLabel(true); label.ShowValue = true; label.Suffix = "%"; barSeries1.DataLabel = label; label = new BarColumnValuePositionDataLabel(true); label.ShowValue = true; label.Suffix = "%"; barSeries2.DataLabel = label; label = new BarColumnValuePositionDataLabel(true); label.ShowValue = true; label.Suffix = "%"; barSeries3.DataLabel = label; plotArea.Series.Add(barSeries1); plotArea.Series.Add(barSeries2); plotArea.Series.Add(barSeries3); Title lTitle = new Title("Visitors %"); barSeries1.XAxis.Titles.Add(lTitle); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q1", 0)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q2", 1)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q3", 2)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q4", 3)); page.Elements.Add(chart); document.Draw(@"C:\Temp\output.pdf"); It is advised to use Indexed100PercentStackedBarSeries instead of the IndexedBarSeries when you want to work with percentages. You can refer to the help documentation which shows different bar series. Thanks, ceTe Software Support Team.