How can I programmatic access to the following settings?
Presentation File:
//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;
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
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);
}
}
}