Text Overlapping in stack chart labels

23-06.PNG (14.4 KB)

We have implemented stacked column chart. in which we are facing issue related to readability in stack column label. described in above image “Outsourced services” in green bar is not readable at all because of less space available in region, similar issue in “Programs” and “System Tools” as well. My requirement is to display labels should be visible properly in any case, in any of the column green or blue. if space is not enough then label should be hidden else it should show labels.
We have check with latest version 20.8 and check with
series.DataPoints[0].Label.TextFormat.TextBlockFormat.AutofitType = TextAutofitType.Normal;
series.DataPoints[0].Label.DataLabelFormat.Position = LegendDataLabelPosition.BestFit;

but still issue has occur.
is it possible to display label text outside the box with same position?

we have attached working demo with 20.8 version of aspose.slide. also attached image for more clarification.
ConsoleAspose.zip (931.5 KB)

@siriussynoptek

You may use a similar logic as under on your end to serve the purpose:

  /// Use before saving presentation.
        /// </summary>
        /// <param name="chart"></param>
        public static void HideOverlappingLabels(IChart chart)
        {
            chart.ValidateChartLayout();

            float overlapFactor = 0.8f;

            foreach (var series in chart.ChartData.Series)
                foreach (var dataPoint in series.DataPoints)
                {
                    if (dataPoint.ActualHeight < dataPoint.Label.ActualHeight * overlapFactor)
                        dataPoint.Label.Hide();
                }
        }

You may please try something like as under on your end.

/// <summary>
        /// Collects all labels in desired position
        /// </summary>
        /// <param name="chart">target chart</param>
        /// <param name="x">Desired X position</param>
        /// <param name="y">Desired Y position</param>
        public static void LayoutLabels(IChart chart, float x, float y)
        {
            chart.ValidateChartLayout();

            foreach (var series in chart.ChartData.Series)
                foreach (var dataPoint in series.DataPoints)
                {
                    dataPoint.Label.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;
                    dataPoint.Label.TextFormat.PortionFormat.FillFormat.FillType = FillType.Solid;

                    float labelX = dataPoint.Label.ActualX;
                    float labelY = dataPoint.Label.ActualY;

                    float desiredXPosition = x;
                    float desiredYPosition = y;

                    float shiftXValue = desiredXPosition - labelX;
                    float shiftYValue = desiredYPosition - labelY;

                    (dataPoint.Label.AsILayoutable).X = shiftXValue / chart.Width;
                    (dataPoint.Label.AsILayoutable).Y = shiftYValue / chart.Height;
                }
        }