How can change the format of the tooltip to a percentage(%) if I give a decimal number(0.13 to 13% in tooltip)?
Programming language c#
How can change the format of the tooltip to a percentage(%) if I give a decimal number(0.13 to 13% in tooltip)?
Programming language c#
@s1pandey,
Thank you for the query. Could you share two presentations created in PowerPoint without percentages and with percentages (desired view), please?
in a green circle we can see the percentage formatted value even I have provided a date in decimal and I used number format as % for this.
But on the hover of the Black circle(green marker I am still getting decimal number, not in percentage). I want to get that number as well in a percentage format.
Soc1 - Copy3.png (19.8 KB)
IChart chart = pptSlide.Shapes.AddChart(ChartType.ClusteredColumn, x, y, width, height);
chart.HasTitle = false;
chart.HasLegend = false;
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
//Delete default generated series and categories
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
//Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, 3), chart.Type);
//Take first chart series
IChartSeries series = chart.ChartData.Series[0];
//Now populating series data
series.ParentSeriesGroup.GapWidth = Constants.SocReportPowerPointOptions.GapWidth;
var socVisualization = (SoCHistogramReportData)visualizationData;
var chartData = socVisualization.PlotChart;
var soc = 0;
int index = 0;
foreach (var item in chartData)
{
soc = item.Key == 0 ? 1 : item.Key;
foreach (var value in item.Value)
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, soc, 1, value));
// Bar Color
chart.ChartData.Series[0].DataPoints[soc - 1].Format.Fill.FillType = FillType.Solid;
chart.ChartData.Series[0].DataPoints[soc - 1].Format.Fill.SolidFillColor.Color = ConvertRgbToColor(socVisualization.Legends[index].Color);
soc++;
}
index++;
}
// Set Font Size for X and Y axis label
chart.TextFormat.PortionFormat.FontHeight = Constants.SocReportPowerPointOptions.ChartTextFontSize;
///Addding second type
// Add new series
series = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, 4), ChartType.Line);
series.PlotOnSecondAxis = true;
chart.Axes.SecondaryVerticalAxis.Position = AxisPositionType.Right;
chart.Axes.SecondaryVerticalAxis.IsNumberFormatLinkedToSource = false;
chart.Axes.SecondaryVerticalAxis.DisplayUnit = DisplayUnitType.None;
chart.Axes.SecondaryVerticalAxis.NumberFormat = Constants.SocReportPowerPointOptions.ChartAxisNumberFormat;
var cumulativePercentageId = socVisualization.Header.RowHeaders.FirstOrDefault(item => string.Equals(item.Values[0].Value, Constants.ReportMetric.CumulativePercentage))?.Id;
var cumulativePercentageData = socVisualization.Data.Tables["soCHistogramData"];
soc = 0;
foreach (DataRow dataRow in cumulativePercentageData.Rows)
{
if (dataRow["rowHeader"].ToString() == cumulativePercentageId)
{
foreach (DataColumn dc in cumulativePercentageData.Columns)
{
var colValue = dataRow[dc].ToString();
if (colValue != cumulativePercentageId)
{
soc++;
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, soc, 3, colValue));
}
}
break;
}
}
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.Solid;
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.MajorGridLineColor);
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.MajorGridLineColor);
// Setting Value Axis Text Properties
IChartPortionFormat txtVal = chart.Axes.VerticalAxis.TextFormat.PortionFormat;
txtVal.FillFormat.FillType = FillType.Solid;
txtVal.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.ChartLabelColor);
txtVal = chart.Axes.SecondaryVerticalAxis.TextFormat.PortionFormat;
txtVal.FillFormat.FillType = FillType.Solid;
txtVal.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.ChartLabelColor);
// Setting Category Axis Text Properties
IChartPortionFormat txtCat = chart.Axes.HorizontalAxis.TextFormat.PortionFormat;
txtCat.FillFormat.FillType = FillType.Solid;
txtCat.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.ChartLabelColor);
chart.Axes.SecondaryHorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.SecondaryHorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.SecondaryVerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.SecondaryVerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.HorizontalAxis.IsAutomaticMajorUnit = false;
chart.Axes.HorizontalAxis.IsAutomaticMaxValue = false;
chart.Axes.HorizontalAxis.MaxValue = soc;
chart.Axes.HorizontalAxis.MinValue = 0;
chart.Axes.VerticalAxis.MajorTickMark = TickMarkType.None;
chart.Axes.HorizontalAxis.MajorTickMark = TickMarkType.None;
chart.Axes.SecondaryHorizontalAxis.MajorTickMark = TickMarkType.None;
chart.Axes.SecondaryVerticalAxis.MajorTickMark = TickMarkType.None;
// Setting value axis title
chart.Axes.VerticalAxis.HasTitle = true;
chart.Axes.VerticalAxis.Title.AddTextFrameForOverriding("");
IPortion verticalAxisTitle = chart.Axes.VerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];
chart.Axes.VerticalAxis.Title.Overlay = false;
verticalAxisTitle.Text = managersCount;
verticalAxisTitle.PortionFormat.FillFormat.FillType = FillType.Solid;
verticalAxisTitle.PortionFormat.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.OrgMetricTextColor);
verticalAxisTitle.PortionFormat.FontHeight = Constants.SocReportPowerPointOptions.ValueAxisTitleFontSize;
verticalAxisTitle.PortionFormat.FontBold = NullableBool.False;
// Setting secondary value axis title
chart.Axes.SecondaryVerticalAxis.HasTitle = true;
chart.Axes.SecondaryVerticalAxis.Title.AddTextFrameForOverriding("");
IPortion secondaryVerticalAxisTitle = chart.Axes.SecondaryVerticalAxis.Title.TextFrameForOverriding.Paragraphs[0].Portions[0];
chart.Axes.SecondaryVerticalAxis.Title.Overlay = false;
secondaryVerticalAxisTitle.Text = cumulativePercentageOfManagers;
secondaryVerticalAxisTitle.PortionFormat.FillFormat.FillType = FillType.Solid;
secondaryVerticalAxisTitle.PortionFormat.FillFormat.SolidFillColor.Color = GetColorFromCode(Constants.SocReportPowerPointOptions.OrgMetricTextColor);
secondaryVerticalAxisTitle.PortionFormat.FontHeight = Constants.SocReportPowerPointOptions.ValueAxisTitleFontSize;
secondaryVerticalAxisTitle.PortionFormat.FontBold = NullableBool.False;
// Move Primary and Secondary vertical axis
chart.Axes.SecondaryHorizontalAxis.TickLabelPosition = TickLabelPositionType.High;
chart.Axes.SecondaryHorizontalAxis.CrossType = CrossesType.Maximum;
chart.Axes.SecondaryHorizontalAxis.IsVisible = false;
// hide verticle axis line for secondary chart ie line chart
chart.Axes.SecondaryVerticalAxis.Format.Line.FillFormat.FillType = FillType.NoFill;
chart.Axes.VerticalAxis.Format.Line.FillFormat.FillType = FillType.NoFill;
//Changing the chart series marker
series.Marker.Size = 5;
series.Marker.Symbol = MarkerStyleType.Circle;
//Setting chart line color
var lineChartColor = ColorTranslator.FromHtml(socVisualization.Legends.FirstOrDefault(item => string.Equals(item.SoCRange, Constants.ReportMetric.CumulativePercentLegendName))?.Color);
series.Format.Line.FillFormat.FillType = FillType.Solid;
series.Format.Line.FillFormat.SolidFillColor.Color = lineChartColor;
series.Marker.Format.Fill.FillType = FillType.Solid;
series.Marker.Format.Fill.SolidFillColor.Color = lineChartColor;
series.Marker.Format.Line.FillFormat.FillType = FillType.Solid;
series.Marker.Format.Line.FillFormat.SolidFillColor.Color = lineChartColor;
@s1pandey,
Unfortunately, your code example is containing many unknown symbols. I cannot use it to investigate the issue. Please, prepare an isolated code sample without your application code.
Its Okay…that will take time. but atleast u can understand my problem from requirement and code what i have used. and can give a solution . can we have a call I can show you… We have subscription for this product.
@s1pandey,
I figured out your issue after seeing your presentation “BestFit - Copy.pptx” from another topic. You mean this: tooltip.png (17.1 KB). Aspose.Slides cannot change these tooltips. I don’t see such a feature in PowerPoint as well. If I missed it, please share a screenshot explaining how to do it.
u can check in SOC Histogram (2).zip file attached its working there.that is dummy file.SOC Histogram (2).zip (489.2 KB)
I have no idea … I got this file as requirement
No… I have not.
@s1pandey,
I logged the issue in our tracking system with ID SLIDESNET-42603. Our development team will consider an ability to implement this feature.
What is the expected time it can take. as I have some deadline for this
@s1pandey,
I requested an estimated time to fix this issue from our development team. I will let you know as soon as possible.
@s1pandey,
Our development team investigated the issue. Tooltips are elements of PowerPoint application. They are not formattable. The tooltip shows data in the format of the data stored in the object. In this case, this is the chart series object. The code snippet below provides the desired result:
chart.ChartData.SeriesGroups[groupIndex].Series[seriesIndex].NumberFormatOfValues = "0.00%";
Documents: Chart Data Label, Chart Formatting
API Reference: IChartSeries Interface
Its working thanks for support. appreciate effert.
How can we customize tooltip to a new string value for each marker value