Free Support Forum - aspose.com

Result of category axis for dynamic charts is wrong

Dear Aspose Support,


I would like to ask for help regarding to the category axis of dynamic charts (using name manager)

ENVIRONMENT:
Aspose 8.9.0.5
Excel 2013
C#

PROBLEM:
The two charts on two different worksheets (Output0 and Output1) are different even with the same style.

I have checked the style for both charts in my program and them are the same, using style number 2.
Both charts are created by my program,
the only difference is that I have re-assigned the style of chart in worksheet “Output1” to the style number 2 again after opening in Excel2013 ( The 9th style or simply 1st style of second row).

The Category axis and Nseries seemed to be the same (pointing correctly to their destination) and range looks fine to me too.

QUESTIONS:
Would you please guide me on how to change the chart in Output0 to look like Output1 ?
And how to change the chart title of both charts to point to Output0_ChartData_B!$A$1 and Output1_ChartData_B!$A$1 respectively?

Regards,
Jonathan Lau

Hi Jonathan,

Thank you for contacting Aspose support.

I have checked both charts from your sample spreadsheet, and I believe there are two main visual differences as detailed below.

  1. The chart in Output1 adds the category name to the DataLabel’s value.
  2. The chart in Output1 has the DataLabel text in same color as of corresponding slice color.

I am able to achieve 1) but for some reason, I am getting black color for all slices of chart in Output0 whereas the chart in Output1 does not show such problem. Could you please share the complete code to create the chart in Output0 and/or provide the spreadsheet without editing it manually in Excel?

Please check the piece of code provided at the bottom of this post, which tries the following,

  1. Sets the chart title’s LinkedSource property; this way, you can pick the chart title from any cell in the worksheet.
  2. Adds the category name to DataLabel’s text with space between them.
  3. Changes the color of DataLabel’s text to the color of corresponding slice. This case is failing on my side because series.Points[i].Area.ForegroundColor returns black for almost all slices.

C#

var book = new Workbook(dir + “packingList.xlsx”);
var sheet_output0 = book.Worksheets[“Output0”];
sheet_output0.Cells[“a1”].Value = “My Chart Title”;
var chart_output0 = sheet_output0.Charts[0];
chart_output0.Calculate();
chart_output0.Title.LinkedSource = “Output0ChartData_B!A1”; //“A1”;
foreach (Series series in chart_output0.NSeries)
{
for(int i = 0; i<series.Points.Count;i++)
{
series.Points[i].DataLabels.Separator = DataLablesSeparatorType.Space;
series.Points[i].DataLabels.ShowCategoryName = true;
Console.WriteLine(series.Points[i].Area.ForegroundColor);
series.Points[i].DataLabels.Font.Color = series.Points[i].Area.ForegroundColor;
}
}
chart_output0.Calculate();
book.Save(dir + “output.xlsx”);

Dear Aspose,


* I have changed my (class) program to mostly hard coded for easier reading *
(Might not be work but the logic is the same)
Attached as "PieChart source.txt"
And the excel template "PieChart Source only.xlsx"

LOGIC:
1. Copy the chart to a new sheet (“Output0”)
2. Copy worksheet (“ChartData_B”) to a new sheet (“Output0ChartData_B”) and fill in with data
2. Get the name variable from the original chart’s NSeries
3. Create a name variable with same name but scope = “Output0ChartData_B”
and its formula reference to sheet (“Output0ChartData_B”)
4. Change data source of chart in “Output0” to use new name variable (now points to “Output0ChartData_B” containing data)

Please tell me if more information is required :slight_smile:
Thank you very much for the help.

Regards,
Jonathan Lau

Hi Jonathan,

Thank you for sharing the code.

Please note, I have raised this incident with the product team under the ticket CELLSNET-44715. Please spare us little time to properly analyze the case and revert back with updates in this regard.

Dear Babar,


Just checking on the progress,
as I am about to make a release version before the end of this week
and would like to know the limit of my release.
Would the support team be able to solve the issue in time?
Many thanks.

Regards,
Jonathan Lau

Hi Jonathan,


I am afraid, the ticket logged earlier as CELLSNET-44715 is currently unresolved. I have requested the concerned member of the product team to share the insight of the problem, and an estimated release schedule for the fix. As soon as we get any information in this regard, we will post here for your kind reference.

Thank you for your patience with us.
Hi,

Thanks for using Aspose.Cells.

This is to inform you that we have fixed your issue CELLSNET-44715 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v9.0.6.0 (.NET 4.0) or Aspose.Cells for .NET v9.0.6.0 (.NET 2.0) and let us know your feedback.

Please try the new fix with following code.

C#

var book = new Workbook(dir + “packingList.xlsx”);
var sheet_output0 = book.Worksheets[“Output0”];
sheet_output0.Cells[“a1”].Value = “My Chart Title”;
var chart_output0 = sheet_output0.Charts[0];
chart_output0.Calculate();
chart_output0.Title.LinkedSource = “Output0ChartData_B!A1”; //“A1”;
foreach (Series series in chart_output0.NSeries)
{
for(int i = 0; i<series.Points.Count;i++)
{
series.Points[i].DataLabels.Separator = DataLablesSeparatorType.Space;
series.Points[i].DataLabels.ShowCategoryName = true;
Console.WriteLine(series.Points[i].Area.ForegroundColor);
series.Points[i].DataLabels.Font.Color = series.Points[i].Area.ForegroundColor;
}
}

book.Save(dir + “output.xlsx”);

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.