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.
Tue Apr 26, 2016 8:41 pm
Hi,
I am brand new to Spire. It looks like it is exactly the product I've been searching for.
Using the excellent example code provided, I have successfully figured out how to create a presentation slide with a scatter chart. However, there is a myriad of formatting details associated and I am having trouble finding documentation on how to use these - is there a recommended document or example that would cover how to use the scatter chart.
In particular, I would like to be able to control the axis max/min values, grid lines, titles and so on. At the moment I am resorting to trial and error which gets tedious.
Thanks for any thoughts...
-Mark R.
-
mroyer
-
- Posts: 3
- Joined: Sat Apr 23, 2016 1:09 pm
Wed Apr 27, 2016 9:06 am
Hello Mark,
Thanks for your inquiry.
There are some methods for your reference.
- Code: Select all
Presentation ppt = new Presentation(@"C:\Users\Administrator\Desktop\Test.pptx", FileFormat.Pptx2010);
IChart chart = ppt.Slides[0].Shapes[0] as IChart;
//Set percentage number format for the axis value of chart.
chart.PrimaryValueAxis.NumberFormat = "0#\\%";
// Remove the tick marks for value axis and category axis.
chart.PrimaryValueAxis.MajorTickMark = TickMarkType.TickMarkNone;
chart.PrimaryValueAxis.MinorTickMark = TickMarkType.TickMarkNone;
//Set the axis max/min values
chart.PrimaryValueAxis.MinValue = 1;
chart.PrimaryValueAxis.MaxValue = 10;
//Set grid lines as invisible
chart.GridLine.FillType = FillFormatType.None;
//Set grid lines format
chart.GridLine.Width = 5;
//Set DataPoint value font size
chart.Series[0].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 20;
//Set titles
chart.PrimaryValueAxis.HasTitle = true;
chart.PrimaryValueAxis.Title.TextProperties.Text = "Primary Value";
//save file
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
Sincerely,
Caroline
E-iceblue support team
-
caroline.zhang
-
- Posts: 291
- Joined: Mon Mar 07, 2016 9:22 am
Wed Apr 27, 2016 1:22 pm
Hi Caroline,
Thanks for your very quick response.
I notice that does much of what I want for the horizontal axis (chart.PrimaryValueAxis).
How do I do the same thing for the vertical axis? (chart.PrimaryCategoryAxis is null and throws an exception if I try to use it).
Thanks again,
-Mark R.
-
mroyer
-
- Posts: 3
- Joined: Sat Apr 23, 2016 1:09 pm
Thu Apr 28, 2016 3:35 am
Hello Mark,
Thanks for your feedback.
Please use
chart.SecondaryValueAxis property to set vertical axis. Sample code:
- Code: Select all
Presentation ppt = new Presentation(@"C:\Users\Administrator\Desktop\Test.pptx", FileFormat.Pptx2010);
IChart chart = ppt.Slides[0].Shapes[0] as IChart;
//Set percentage number format for the axis value of chart.
chart.PrimaryValueAxis.NumberFormat = "0#\\%";
chart.SecondaryValueAxis.NumberFormat = "0#\\%";
// Remove the tick marks for value axis and category axis.
chart.PrimaryValueAxis.MajorTickMark = TickMarkType.TickMarkNone;
chart.PrimaryValueAxis.MinorTickMark = TickMarkType.TickMarkNone;
chart.SecondaryValueAxis.MajorTickMark = TickMarkType.TickMarkNone;
chart.SecondaryValueAxis.MinorTickMark = TickMarkType.TickMarkNone;
//Set the axis max/min values
chart.PrimaryValueAxis.MinValue = 1;
chart.PrimaryValueAxis.MaxValue = 10;
chart.SecondaryValueAxis.MinValue = 1;
chart.SecondaryValueAxis.MaxValue = 10;
//Set grid lines as invisible
chart.PrimaryValueAxis.MajorGridTextLines.FillType = FillFormatType.None;
chart.PrimaryValueAxis.MinorGridLines.FillType = FillFormatType.None;
chart.SecondaryValueAxis.MajorGridTextLines.FillType = FillFormatType.None;
chart.SecondaryValueAxis.MinorGridLines.FillType = FillFormatType.None;
//Set grid lines format
chart.PrimaryValueAxis.MajorGridTextLines.Width = 5;
chart.SecondaryValueAxis.MajorGridTextLines.Width = 5;
//Set DataPoint value font size
chart.Series[0].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 5;
//Set titles
chart.PrimaryValueAxis.HasTitle = true;
chart.PrimaryValueAxis.Title.TextProperties.Text = "Primary Value";
chart.PrimaryValueAxis.Title.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 10;
chart.SecondaryValueAxis.HasTitle = true;
chart.SecondaryValueAxis .Title.TextProperties.Text = "Primary Category";
chart.SecondaryValueAxis.Title.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 10;
//save file
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
Best Regards,
Caroline
E-iceblue support team
-
caroline.zhang
-
- Posts: 291
- Joined: Mon Mar 07, 2016 9:22 am
Thu Apr 28, 2016 12:10 pm
Thank you again for your quick help.
-Mark R.
-
mroyer
-
- Posts: 3
- Joined: Sat Apr 23, 2016 1:09 pm
Fri Apr 29, 2016 3:47 am
You're welcome, glad to help you.
If there is any question, welcome get it back to us again.
Sincerely,
Caroline
E-iceblue support team
-
caroline.zhang
-
- Posts: 291
- Joined: Mon Mar 07, 2016 9:22 am