Pie chart Hover value display

Hi
I have created a pie chart with different formats for values.
A- “EUR” is applied in format
B -doesn’t have any formats applied
C- “$” is applied in format

Now, if I hover on C series in pie chart it displays the format being applied for A. I have attached the screenshot for reference.
Is it possible to display exact formats for values on different series while hover?
image.png (51.7 KB)

Thanks

@manavjaiswal

To ensure that each series in your pie chart displays its specific format when hovered over, you need to customize the tooltip settings for each series. The issue you are experiencing may arise because the tooltip is defaulting to the format of the first series.

Cause: The default tooltip behavior may not reflect the individual formats set for each series, leading to inconsistent display.

Solution: Follow these steps to customize the tooltips for each series:

  1. Set Individual Formats: Ensure that each series has its own format explicitly defined. This includes setting the number format for each series.

  2. Customize Tooltips: Modify the tooltip for each series to display the correctly formatted value. This can typically be done by adjusting the DataLabels or ToolTip property for each series.

  3. Example Code: Below is a C# example demonstrating how to implement this:

// Create a workbook and access the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Add sample data for the pie chart
sheet.Cells["A1"].PutValue("Category");
sheet.Cells["B1"].PutValue("Value");
sheet.Cells["A2"].PutValue("EUR");
sheet.Cells["B2"].PutValue(1000);
sheet.Cells["A3"].PutValue("No Format");
sheet.Cells["B3"].PutValue(2000);
sheet.Cells["A4"].PutValue("USD");
sheet.Cells["B4"].PutValue(1500);

// Add a pie chart
int chartIndex = sheet.Charts.Add(ChartType.Pie, 5, 0, 20, 6);
Chart chart = sheet.Charts[chartIndex];

// Add series data
chart.NSeries.Add("B2:B4", true);
chart.NSeries[0].XValues = "A2:A4";

// Set individual formats for tooltips
chart.NSeries[0].DataLabels.IsValueShown = true;
chart.NSeries[0].DataLabels.NumberFormat = "€ #,##0.00"; // For EUR
chart.NSeries[1].DataLabels.IsValueShown = true;
chart.NSeries[1].DataLabels.NumberFormat = "#,##0"; // No format
chart.NSeries[2].DataLabels.IsValueShown = true;
chart.NSeries[2].DataLabels.NumberFormat = "$ #,##0.00"; // For USD

// Save the workbook
workbook.Save("PieChartWithTooltips.xlsx");

This code sets up a pie chart with distinct formats for each series, ensuring that the tooltips accurately reflect those formats.

Next Steps: If you continue to experience issues, verify the version of Aspose.Cells you are using. There may be updates or bug fixes related to chart tooltips in newer versions.

Please let me know if you need further assistance!

@manavjaiswal
Could you share your sample codes and template file? We will check it soon.

I’ve created it manually, wanted to know the feasibility of it.
As I’m not able to attach the excel, sharing details as images.
format for A
image.png (15.5 KB)

format for B- none
image.png (20.6 KB)

format for C
image.png (23.9 KB)

DATA:
image.png (27.6 KB)

Please let me know if this is feasible.

@manavjaiswal,

It seems you are referring to the tooltip text that appears when hovering the mouse pointer over different sections or slices of a pie chart. I manually tested this scenario in Microsoft Excel by creating a pie chart based on your specified (formatted) data range. From my observations, it appears to be the default behavior of Excel to use the currency format of the first value for all tooltip values. Unfortunately, this behavior is inherent to Excel, and Aspose.Cells cannot override or alter it.

To confirm this, I recommend testing your case manually in Excel as well. If you believe Excel can display tooltips with different currency signs when hovering over various pie slices, please share a sample Excel file (ensure the file is zipped before attaching it). We will review the file and check how this functionality might be implemented using Aspose.Cells APIs.

I guess, for your needs, atleast to get original values in tool tip text (without currency symbol), you should not format source data (cells) with different currency symbols, just insert data as number or general. Now set custom numbers formatting via DataLabels.NumberFormat() attribute for all (three) data points.

@amjad.sahi
Is it possible to disable this tooltip option via aspose?
So, nothing would display on hover-over.

I found that I can do that manually in excel by file->options->advanced
image.png (33.5 KB)

Please let me know if this is possible via aspose.

@manavjaiswal,

Thank you for sharing the screenshot.

This appears to be an MS Excel application setting rather than file format (e.g., XLSX) setting. I’m not certain whether MS Excel stores any information related to enabling or disabling hover (mouse) tips for chart elements within XLS/XLSX file formats. Nevertheless, we will investigate this further. If my assumption is correct, this functionality may not be achievable using Aspose.Cells APIs. Anyways, we will update you soon.

@manavjaiswal,

We assessed it thoroughly and can confirm that this is a behavior specific to MS Excel and its application settings. This cannot be achieved through APIs.

@amjad.sahi
Thanks for the update.

@manavjaiswal,

You are welcome. Should you have any additional questions or comments, please do not hesitate to reach out to us.