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.

Fri Jul 18, 2014 4:30 pm

Hello,

I am drawing a stacked bar chart. I want to change the size and font of the legend and title, and the size of the plot area so I can customize how each section is laid out on the slide. However, using

chart.ChartLegend.Width = someNumber;

doesn't seem to change anything. If I try to log chart.ChartLegend.Width without changing it, the result is NaN. If I change it first and log it, the result will be someNumber, but this isn't reflected visually in the actual chart. Same with chart.PlotArea.Width/Height and chart.Title.Width/Height.

As for the font and font size of the legend and title, I would imagine this is somewhere in chart.Title/ChartLegend.TextProperties, but I can't seem to figure it out.

Our company is looking to buy this package, so we're eager to know if these features are possible.

jeffc
 
Posts: 3
Joined: Tue Jul 15, 2014 8:59 pm

Mon Jul 21, 2014 8:03 am

Hello,

Sorry for the delay response for the weekends here. Thanks for your inquiry.
Sorry for the inconvenience caused by the issues. I have posted the issues to our dev team. My dev colleague is doing an investigation to resolve them. We will inform you immediately once they are resolved.

Weclome to write to us again for further problems.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Jul 24, 2014 3:46 am

Hello,

Thanks for your waiting.
The issues have been resolved. We will release a new version soon. Once the version is released, we wil inform you immediately.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Jul 24, 2014 8:38 am

Hello,

The new version has been released. Welcome to download and test Spire.Presentation Pack Hotfix Version:2.0.18.
Downloading link:http://www.e-iceblue.com/Download/download-presentation-for-net-now.html

Share sample code:
Code: Select all
IChart chart = presentation.Slides[0].Shapes.AppendChart(Spire.Presentation.Charts.ChartType.BarStacked, rect);

            //add chart Title
            chart.ChartTitle.TextProperties.Text = "Report";
            chart.ChartTitle.TextProperties.IsCentered = true;
            chart.HasTitle = true;

            chart.Top = 10;
            chart.Left = 50;

            //Set the font of ChartLegend
            chart.ChartLegend.EntryTextProperties[0].Fill.FillType = FillFormatType.Solid;
            chart.ChartLegend.EntryTextProperties[0].Fill.SolidColor.KnownColor = KnownColors.Green;
            chart.ChartLegend.EntryTextProperties[0].FontHeight = 20;
            chart.ChartLegend.EntryTextProperties[0].LatinFont = new TextFont("Arial Unicode MS");

            //Set width and height of ChartLegend and PlotArea
            chart.ChartLegend.Width = 300;
            chart.ChartLegend.Height = 300;
            chart.PlotArea.Width = 200;
            chart.PlotArea.Height = 200;
     
            //Set the font of ChartTitle
            chart.ChartTitle.TextProperties.TextRange.Fill.FillType = FillFormatType.Solid;
            chart.ChartTitle.TextProperties.TextRange.Fill.SolidColor.KnownColor = KnownColors.Gray;
            chart.ChartTitle.TextProperties.TextRange.FontHeight = 30;
            chart.ChartTitle.TextProperties.TextRange.LatinFont = new TextFont("Arial Unicode MS");


Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Jul 24, 2014 5:02 pm

Code: Select all

            //Set the font of ChartLegend
            chart.ChartLegend.EntryTextProperties[0].Fill.FillType = FillFormatType.Solid;
            chart.ChartLegend.EntryTextProperties[0].Fill.SolidColor.KnownColor = KnownColors.Green;
            chart.ChartLegend.EntryTextProperties[0].FontHeight = 20;
            chart.ChartLegend.EntryTextProperties[0].LatinFont = new TextFont("Arial Unicode MS");



These four lines all throw null reference exceptions. The EntryTextProperties collection seems to be empty no matter where I put it in the code. Is there some sort of initialization for EntryTextProperties that needs to be done first? This is on the .NET 3.5 version. The other features you have added seem to be working so far, thanks for the support.

jeffc
 
Posts: 3
Joined: Tue Jul 15, 2014 8:59 pm

Fri Jul 25, 2014 3:05 am

Hello,

Thanks for your feedback.
But in my test project, the EntryTextProperties collection worked well. I provide you my test project as a reference.
Please get it from the link:http://www.e-iceblue.com/downloads/attachment/demo.zip.

If the issue still persists, please send your test project to amy.zhao@e-iceblue.com or support@e-iceblue.com to help us do an investigation. Thanks.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Jul 25, 2014 4:45 pm

Thanks for the demo, it works on my computer. It must be an issue with my code.

Update: You are using the default data in your chart by setting init to true. Some of my charts have less categories and series than the default data, so I need to be able to set init to false and then append categories and series as needed. When I set init to true in my code, the entrytextproperties work, but not when I set it to false. If I set it to false, I need to set the series capacity to however many series I have, then append each series, and then set each series.value to get my chart to work, but then the entrytextproperties don't work correctly. I imagine this difference in our code is where the issue is. Here are the lines of my code that I am referring to:

Code: Select all
IChart chart = pres.Slides[0].Shapes.AppendChart(Spire.Presentation.Charts.ChartType.BarClustered, rect, false);

chart.Categories.Capacity = filters.Length;
chart.Series.Capacity = answers.Length;

for (int i = answers.Length; i > 0; i--)
{
   chart.ChartData[0, i].Text = answers[i-1];
   chart.Series.Append(answers[i-1]);
}

for (int i = 0; i < answers.Length; i++)
{
   chart.Series[i].Values = chart.ChartData[(char)(i+66) + "2", (char)(i+66) + (chart.Categories.Capacity + 1).ToString()];
}


That's the method I'm using to populate my chart with data. When I do that, entrytextproperties doesn't work. I'll try to tune it more to your code style to see if I can get it working, but it seems like changing init to false makes things difficult. If I can't get it working over the weekend, I'll see about sending you the full project next week. Thanks for all the help so far.

jeffc
 
Posts: 3
Joined: Tue Jul 15, 2014 8:59 pm

Mon Jul 28, 2014 2:53 am

Hello,

Thanks for your feedback.
If the issue still persists, please send your project to amy.zhao@e-iceblue.com or support@e-iceblue.com.

Thanks.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Presentation