Free Support Forum - aspose.com

Aspose.Slides cannot format value axis of a chart

I need to show the value axis of a chart in percentages. There is no current way that I have seen that this can be done. In Aspose.Cells you can do this with the TickLabel of the ValueAxis object. Here is how to do it in Cells:


Workbook wb = new Workbook();

Worksheet ws = wb.Worksheets[0];

ChartType cType = ChartType.Line;

int chartIndex = ws.Charts.Add(ctype, 0, 2, 0,20, 22);

Chart chart = ws.Charts[chartIndex];

chart.ValueAxis.TickLabels.NumberFormat = “0%”;

//then add data to the chart

I have tried mutltiple things in Aspose.Slides but I have had no luck. If you can help me that would be great.

//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx();

//Access first slide
SlideEx sld = pres.Slides[0];

// Add chart with default data
ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 0, 0, 500, 500);

//Setting chart Title
chart.ChartTitle.Text.Text = “Sample Title”;
chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;

//Set first series to Show Values
chart.ChartData.Series[0].Labels.ShowValue = true;

//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

//Delete default generated series and categories
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
int s = chart.ChartData.Series.Count;
s = chart.ChartData.Categories.Count;

//Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.Type);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, “Series 2”), chart.Type);

//Adding new categories
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, “Caetegoty 1”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, “Caetegoty 2”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, “Caetegoty 3”));

//Take first chart series
ChartSeriesEx series = chart.ChartData.Series[0];

//Now populating series data
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, .20));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, .50));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, .30));

//Take second chart series
series = chart.ChartData.Series[1];

//Now populating series data
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 2, .30));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 2, .10));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 2, .60));

chart.ValueAxis.TickLabel.NumberFormat = “0%”;

There are no properties of ValueAxis that have the availability to do something like this that I have seen. I am using the latest Aspose.Slides and Visual Studios 2008 Pro. A quick response would be helpful because this is a project for my work.

Thank you,

Dustin Thomas

Hi Dustin,


Please visit this thread link and use the code snippet shared. Hopefully, it will prove helpful to you.

Many Thanks,
Hello Mudassir,

Sorry this is not what I need. This to show a percent label for each data point in a series. I need the left value axis to be formatted as a percent. Right now only I can specify it as a decimal. Here is an attached picture of the code that was implemented from the link you sent me and showing the area that needs to be formatted. The underline section is the label that was created by the code referenced by you and the square is the area that is what is needed to be formatted. I hope you understand what is needed now.

Thank you,

Dustin Thomas

Hi Dustin,


I have observed the requirements shared by you and like to share that the feature that you are looking for is currently unavailable in Aspose.Slides. An issue with ID SLIDESNET-33122 has been created in our issue tracking system as new feature request to provide this feature. This thread has been linked with the issue so that you may be automatically notified once the issue is resolved. At the moment, only setting DiplayUntit property is available for setting axis values.

chart.ValueAxis.DisplayUnit=DisplayUnitType.None;


We are sorry for your inconvenience,

Is there a time frame for when it will be completed?

Hi Dustin,


I like to share that the specified issue has just been added and has not been scheduled yet. Our development team will schedule the issue and on the basis of that we will be able to share the ETA. I will share the further information with you as soon as the information will be shared by our development team.

Many Thanks,

Is there an update on this issue?
Unfortunately the moment a chart data is being touched the formatting on value axis is set to general (not preserving the format set in the template), and not being able to modify it later (via code) does not produce a final presentation.
Quick response will be appreciated.
Thanks

Hi Dustin,


Please accept my apology to share that there are no further updates over the status of the issue. Our development team actually schedule the issues added in Aspose.Slides forum on turn by turn basis. Regretfully, presently there are other pending issue that are already waiting in line. However, I have requested our development team to kindly schedule the issue. I also like to add that currently charts rendering support is internally dependent on Aspose.Cells and we are in phase of totally implementing the chart support from scratch by removing dependency on Aspose.Cells. Presently, all the charts related issues are delayed owing to this development.

Many Thanks,

Hello Mudassir,


It has been almost a month since your last post. I am wondering if there is any updates on this issue being completed?

Hi Dustin,


I have verified from our issue tracking system and like to share that the issue specified has not yet been resolved. Actually, Aspose.Slides internally depends upon Aspose.Cells for chart rendering. We are currently working over completely isolating Aspose.Slides from Aspose.Cells by implementing the said support with in Aspose.Slides and removing Aspose.Cells dependency. This task is expected to be completed by 20 March, 2012. By then we will be able to share some definite ETA with you regarding the issue status. I hope I have clearly shared every thing here.

We are sorry for your inconvenience.

Hello Mudassir,


I just am following up on this issue. Has a ETA been set for this to be in a up coming release?

Thank you,

Dustin

Hi Dustin,


I like to share that we have been able to isolate Aspose.Cells from Aspose.Slides for .NET which was blocking this issue to get resolved. I have requested our development team to share the ETA and will share that with you accordingly as soon as it will be shared with me. I will really appreciate your cooperation in this regard.

Many Thanks,

It has almost been another month is there any update on this issue yet?

Hi Dustin,


I have verified from our issue tracking system and like to share that issue has been fixed and the fix will be available in upcoming release of Aspose.Slides for .NET 6.2.0. The release is scheduled by end of April 2012 and we will share the further information with you as soon as it will be available.

Many Thanks,

Hi Dustin,


I like to share that the feature of setting the number format for value axis has been resolved in Aspose.Slides for .NET 6.2.0. You may need to use the following code snippet to set the number format. I will share the notification of product release with you as soon as I will upload it.

chart.ValueAxis.DisplayUnit = Aspose.Slides .Pptx .Charts.DisplayUnitType.None;
chart.ValueAxis.NumberFormat = “0.0%”;
chart.ValueAxis.SourceLinked = false;

Many Thanks,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hello.


I use your demo code:

chart.ValueAxis.DisplayUnit = Aspose.Slides .Pptx .Charts.DisplayUnitType.Hundreds;
chart.ValueAxis.NumberFormat = “0%”;
chart.ValueAxis.SourceLinked = false;

…but I have a problem because the axis gets displayed correctly as a percentage but the values on top of the bars of my chart are not percentages (I get 0.3 instead of 30%). I’ve tried this but it didn’t help :

	lSeries.Labels.ShowValue = true;
lSeries.Labels.NumberFormat = “0%”;
lSeries.Labels.ShowPercentage = true;
lSeries.Labels.LinkedSource = false;
There is no DisplayUnit in there to modify.
If I change the 1st line of the code to :
	chart.ValueAxis.DisplayUnit = Aspose.Slides .Pptx .Charts.DisplayUnitType.None;
The values of the bars are correct and the axis values are wrong…
Any ideas on what I can do?

Hi,


I have worked over your requirement and there is issue in code sample used. Please try using following sample code by commenting the line as I have done so in following code.

series.Labels.LinkedSource = false;
series.Labels.ShowValue = true;
series.Labels.NumberFormat = “0.0%”;
// series.Labels.ShowPercentage = true;


Please share, if I may help you further in this regard.

Many Thanks,

OK. I have solved this problem using your fix.
Isn’t this line supposed to show/hide the percentage sign on the value of the label that is placed on top of the bars of a bar chart?


Anyway, it works now! :slight_smile:
Thanks.

Hi,


You are always welcome. Please share, if I may help you further in this regard.

Many Thanks,