Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Jul 14, 2022 11:11 am

How can I programmatic access to the following settings?

scatter-chart-label-options.png


Presentation File:
template-scatter-chart.zip

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Mon Jul 18, 2022 8:45 am

Hello Omur Ertanis,

Thanks for your message.
Please use the following code snippet to access to these settings. If there is any other issues, just feel free to write back.

Code: Select all
            //Set data point labels value from the cells
            chart.Series[0].DataLabelRanges = chart.ChartData["C2", "C7"];

            //Show data labels
            chart.Series[0].DataLabels.LabelValueVisible = true;
            chart.Series[0].DataLabels.CategoryNameVisible = true;
            chart.Series[0].DataLabels.SeriesNameVisible = true;


Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Jul 21, 2022 1:32 am

Hello Omur Ertanis,

Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Jul 21, 2022 8:01 am

Thank you. I will test it and let you know.

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Fri Jul 22, 2022 5:37 am

Hello Omur Ertanis,

Thanks for your reply.
If there is any problem with the test, please feel free to contact me.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Fri Jul 22, 2022 11:42 am

Hello,
I test it and figure out that

Code: Select all
            chart.Series[0].DataLabels.LabelValueVisible = true; // Sets Y Value
            chart.Series[0].DataLabels.CategoryNameVisible = true; //Sets X Value
            chart.Series[0].DataLabels.SeriesNameVisible = true; // Sets Series Name


But how can I set Value From Cells setting?

Template File:
template.zip


Source Code:

Code: Select all
using Spire.Presentation;
using System.Linq;
using Spire.Presentation.Charts;
using System;

namespace PptxTesterPaidVersion2
{
    class Program
    {
        static void Main(string[] args)
        {
            ScatterChartProperties();
        }
        private static void ScatterChartProperties()
        {
            //Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("template.pptx");

            //Create New Presentation
            Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation();
            presentation.Slides.RemoveAt(0);

            //Get slide from template presentation. index:1
            ISlide cloneSlide = templatePresentation.Slides.ToArray().ElementAtOrDefault(0);

            //---
            //Get Chart                       
            //IChart chart = templateSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Content Placeholder 15") as IChart;
            IChart chart = cloneSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Chart 3") as IChart;

            //Set data point labels value from the cells
            chart.Series[0].DataLabelRanges = chart.ChartData["C2", "C4"];

            //Show data labels
            chart.Series[0].DataLabels.LabelValueVisible = true; // Y Value
            chart.Series[0].DataLabels.CategoryNameVisible = true; //X Value
            chart.Series[0].DataLabels.SeriesNameVisible = true; // Series Name

            presentation.Slides.Append(cloneSlide);

            Random rnd = new Random();
            int num = rnd.Next();
            var filename = $"SetScatterChartProperties_{num}.pptx";


            //Save and launch to view the PPTX document.
            presentation.SaveToFile(filename, Spire.Presentation.FileFormat.Pptx2010);
        }
    }
}

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Mon Jul 25, 2022 6:50 am

Hello Omur Ertanis,

As for the modification of the existing document DataLabelRanges, we found there are some errors when opening the modified PPT file. I have logged this issue into our bug tracking system with the ticket SPIREPPT-2001. Our Dev team will do more investigations to fix it. Once there is any update, I will inform you asap. Sorry for the inconvenience caused.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Aug 11, 2022 1:38 am

Hello Omur Ertanis,

Thanks for your patience!
Glad to inform you that we just released Spire.Presentation Pack Version:7.8 which fixes the issue with SPIREPPT-2001. Please download the new version from the following links to test.
Website download link:https://www.e-iceblue.com/Download/download-presentation-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Presentation/7.8.0

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.Presentation