@John.He
Thank you, but it’s not working. I’m getting the same output as before. Please provide the correct solution.
I used John’s solution to get the file you expected, here is the code snippet and the output file
chart.NSeries[0].DataLabels.ShowValue = true;
string filePath = path + "Output.xlsx";
workbook.Save(filePath);
//string pdfPath = @"D:\3DTreemapChart.pdf";
//workbook.Save(pdfPath, SaveFormat.Pdf);
string imagePath = path + "Output.png";
chart.ToImage(imagePath, ImageType.Png);
Console.WriteLine("Treemap chart generated successfully!");
I used your code completely, only added a line of code provided by John, and the output file is as follows.
Output.zip (10.3 KB)
Please open this xlsx file to check, excluding the different display caused by different Excel versions. Also, please confirm the version of Aspose.Cells you using. I am using Aspose.Cells version 25.2. Thank you.
Hi @leoluo,
The chart works correctly in the Excel sheet, but when I convert it to an image, a few data labels are not displayed properly.
@sanjeevkumar.v
By testing with sample code on the latest version v25.2, we can reproduce the issue. Data labels are not displayed properly when converting chart to image.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-57834
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@sanjeevkumar.v
Please allow us some time to evaluate and analyze it in detail. In normal support here, we deal with issues on a first come, first served basis. We believe this is the fairest and most appropriate way to meet the needs of our customers. If it is not complex, we should be able to fix it soon, and the fix may be included in our upcoming release (Aspose.Cells v25.3 - planned for publication in the second week of March next month). If the issue is complex, it may take a few more weeks or even a month to resolve.
Additionally, if you purchase paid support, we will prioritize your issue so that it can be resolved earlier.
@sanjeevkumar.v
Thank you for your feedback. We will notify you promptly once there are any updates.
Hi @sanjeevkumar.v
We fixed the layout issue in TreeMap, the result is shown in the following figure. It will take effect in 25.3.
250309.png (8.6 KB)
The issues you have found earlier (filed as CELLSNET-57834) have been fixed in this update. This message was posted using Bugs notification tool by leoluo
“Hi,
I am using Aspose.PDF version 25.7.0 , but I still have the label issue — the percentage value is being hidden. Why is this happening?”
image.png (19.1 KB)
I have attached the Image for your reference
I tested the following sample code using Aspose.Cells for .NET v25.7 and it works fine. The labels are shown properly with percentage values in the output image and Excel spreadsheet.
e.g
Sample code:
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells["A1"].Value = "Category";
sheet.Cells["B1"].Value = "Percentage";
string[] categories = { "Mentor", "Guardian", "Principal", "Dominion", "Angel", "Binder", "Visualizer", "Charmer", "Harmonizer" };
double[] percentages = { 81.91, 76.6, 75.62, 55.69, 52, 50.49, 50.49, 47.24, 38.14 };
for (int i = 0; i < categories.Length; i++)
{
sheet.Cells[$"A{i + 2}"].Value = categories[i];
sheet.Cells[$"B{i + 2}"].Value = percentages[i];
}
int chartIndex = sheet.Charts.Add(ChartType.Treemap, 5, 0, 25, 8);
Chart chart = sheet.Charts[chartIndex];
chart.Title.Text = "3D View of Purpose, Passion & Potential";
chart.Title.Font.IsBold = true;
chart.Title.Font.Color = System.Drawing.Color.White;
chart.Title.Font.Size = 14;
chart.NSeries.Add("B2:B10", true);
chart.NSeries.CategoryData = "A2:A10";
Series series = chart.NSeries[0];
for (int i = 0; i < series.Points.Count; i++)
{
DataLabels labels = series.Points[i].DataLabels;
labels.ShowCategoryName = true;
labels.ShowValue = true;
labels.Text = $"{categories[i]}, {percentages[i]}%";
labels.Position = LabelPositionType.Center;
labels.Font.Color = System.Drawing.Color.White;
labels.Font.IsBold = true;
}
chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.White;
chart.PlotArea.Area.FillFormat.FillType = Aspose.Cells.Drawing.FillType.Solid;
chart.ShowLegend = false;
chart.Title.IsVisible = false;
chart.ChartArea.Border.IsVisible = false;
chart.PlotArea.Border.IsVisible = false;
chart.ChartArea.Area.FillFormat.FillType = Aspose.Cells.Drawing.FillType.None;
chart.PlotArea.Area.FillFormat.FillType = Aspose.Cells.Drawing.FillType.None;
//Show value labels
chart.NSeries[0].DataLabels.ShowValue = true;
string imagePath = @"e:\\test2\\out_net1.png";
chart.ToImage(imagePath, ImageType.Png);
workbook.Save("e:\\test2\\" + "out_net1.xlsx");
Please find attached the output image and Excel file for your reference.
files1.zip (19.3 KB)
Could you please share a sample (runnable) code same as above to reproduce the issue on our end, we will check your issue soon.
I tried the code you provided, but it’s not working for some specific arrays.
Please try applying the following values to your code — it will reproduce the issue:
Values.docx (11.2 KB)
@sanjeevkumar.v
If the chart (area) is not wide, the data labels should be wrapped.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-58799
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi @Suriya08
For this issue, we have optimized, the regenerated image is as follows, it will take effect in version 25.8.
250808.png (5.0 KB)
The issues you have found earlier (filed as CELLSNET-58799) have been fixed in this update. This message was posted using Bugs notification tool by leoluo