Unable to display percentage and dollar value in box and whisker chart

Hi Aspose Team,

I am using latest version(18.6) of Aspose.Slide for generating Box and Whisker chart. I want to plot box and whisker chart using value of type percentage. For that i have used following code but it’s plot numeric value not percentage value. While same code is working fine for column chart. I have attached sample working application and ChartData excel for generating chart using that data. Sample application contains code for column chart and Box and Whisker chart for your reference. To run sample app, you require to add dll of Aspose.Slide and Aspose.Cells.

series1.NumberFormatOfXValues = “0.0\%”;
series1.NumberFormatOfYValues = “0.0\%”;
series1.NumberFormatOfValues = “0.0\%”;
series1.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false;
series1.Labels.DefaultDataLabelFormat.NumberFormat = “0.0\%”;

ConsoleApp.zip (55.2 KB)

@sdtechsupport.sirius,

I have worked with the sample project shared by you and have been able to observe the issue. An issue with ID SLIDESNET-40260 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi,

Is there any update on the above issue? Has it been resolved?

Please let us know the current status for the same!

Thanks!

@sdtechsupport.sirius.

I suggest you to please try using following sample code on your end to serve the purpose.\

 using (Presentation pres = new Presentation())
            {
                //For BoxAndWhisker chart
                IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.BoxAndWhisker, 50, 50, 500, 400);
                chart.ChartData.ChartDataWorkbook.Clear(0);
                chart.ChartData.Series.Clear();
                chart.ChartData.Categories.Clear();
                
                Workbook worbook = new Workbook(xlsxFileName);

                MemoryStream memStream = new System.IO.MemoryStream();
                worbook.Save(memStream, Aspose.Cells.SaveFormat.Xlsx);

                memStream.Position = 0;
                chart.ChartData.WriteWorkbookStream(memStream);
                chart.ChartData.SetRange("Sheet1!$A$1:$D$19");

                string ValueFormat = "0.0%";

                for (int i = 0; i < chart.ChartData.Series.Count - 1; i++)
                {
                    chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.ShowValue = true;
                    chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false;
                    chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.NumberFormat = ValueFormat;
                }

                pres.Save(pptxFileName, Aspose.Slides.Export.SaveFormat.Pptx);
                
            }

Thanks for giving sample code.

In sample code, value format is only for showing percentage value in data label. I have tried to apply sample code in my application. It is showing different value than actual value. I have attached generated PPT image for your reference.
I also want to show different unit(%,$) value on y-axis and data labels as well, which is not full filling by sample code given by you.
Kindly share other alternative if you have.
DataLabel_BWChart.png (55.9 KB)

@sdtechsupport.sirius,

Can you please share the complete working sample project along with source files. Please also share the generated presentation as well as desired output presentation that you want to generated using Aspose.Slides. We will investigate that further on our end to help you out.

Hi mudassir.fayyaz,

I have already given all the requested information before(Please check very beginning conversation of this ticket) and by investigating it you have generated ID SLIDESNET-40260 in your issue tracking system.
I just want to know when will you provide us resolution in coming release at end of July, 2018.

@sdtechsupport.sirius,

I have observed the issue further on our end and have tried reproducing the stated issue by directly adding a Box and Whisker chart in PowerPoint 2016 and setting the number format for added chart. The PowerPoint too exhibit the same behavior and please visit this snapshot for your convenience where the data label number format is set to percentage and it displays the percentage in similar way Aspose.Slides generated chart does. For your kind reference, I have also attached the a presentation whereby I have added the chart using PowerPoint 2016 to exhibit the same behavior. If you can persist with showing value rather than percentage then it may display values accordingly. If you are able to achieve the required percentage format for same values chart on your end then please share with us and we may investigate that further on our end.

RevisedBox_Whisker.zip (66.7 KB)

Hi,

Thanks for the details. We would like to inform that we have used the code (attached) and the respective formats in Microsoft 2016 PPT - Box & Whiskers as well and it works in there.

we had input the format as visible in attached snaps to the PPT and it works over there.

Also, when we try to implement the same in Aspose for Box & whiskers- it throws error for which we have already provided the sample application. But the same code works for other chart types such as Bar & column etc.

Please see the attached snaps and let us know if it would be possible to incorporate the same in july release of yours as we have dependencies on the same.

Thanks!
$ Format.jpg (158.2 KB)
% format.jpg (157.6 KB)

@sdtechsupport.sirius,

I suggest you to please make following modification in your sample project. I have also attached the generated presentation for your kind reference as well.

            string ValueFormat = @"0.0\%";

            for (int i = 0; i < chart.ChartData.Series.Count - 1; i++)
            {
                chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.ShowValue = true;
                chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false;
                chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.NumberFormat = ValueFormat;
                chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.NumberFormat = ValueFormat;
                //chart.ChartData.Series[i].Labels.DefaultDataLabelFormat.n = ValueFormat;
            }

Revised.zip (39.3 KB)

Hi mudassir,

Thanks for giving code snippet.
Now @“0.0%” format is working fine for data labels. I have applied same format(following code) for displaying % values on vertical value axis(Y-axis) but it’s not working. It’s show numeric values on vertical value axis. I have attached image of generated output. Please suggest.

series.NumberFormatOfYValues = @“0.0%”;
series.NumberFormatOfValues = @“0.0%”;

BWChart.png (5.3 KB)

@sdtechsupport.sirius,

I suggest you to please try using following sample code on your end.

string ValueFormat = @"0.0\%";
chart.Axes.VerticalAxis.IsNumberFormatLinkedToSource = false;
chart.Axes.VerticalAxis.NumberFormat = ValueFormat;

The issues you have found earlier (filed as SLIDESNET-40260) have been fixed in this update.