Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

Fri Oct 03, 2008 2:30 pm

Hello all,
I'm facing a problem.
I would like to see the background of my chart (which actually is Grey) in White.
I just can't find a way to do it ?
Can, please, anybody help me on that topic ?

Thanks by Advance
C.

marfilc
 
Posts: 3
Joined: Fri Oct 03, 2008 2:26 pm

Wed Oct 08, 2008 2:54 am

hello,

Please try to using following code,
Code: Select all
chart.ChartArea.ForeGroundColor = Color.Blue;
User avatar

Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Wed Oct 08, 2008 8:43 am

Hello,
Thanks for your answer. I tried that and that doesn't seem to work either:

Code: Select all
            // CML: Chart management ...
            // ... Add a new  chart worsheet to workbook
            Spire.Xls.Chart chart = xlSheet.Charts.Add();
            chart.ChartType = ExcelChartType.Line;
            chart.DisplayBlanksAs = ChartPlotEmptyType.Zero;

            // ... Set region of chart data
            chart.DataRange = xlSheet.Range["A" + (firstDataRowIndex-1) + ":C" + (rowNumber-1)];
            chart.SeriesDataFromRange = false;

            // ... Set position of chart
            chart.LeftColumn = 1;
            chart.TopRow = rowNumber + 1;
            chart.RightColumn = 5;
            chart.BottomRow = rowNumber + 21;

            // ... Set the background color of the chart
            chart.ChartArea.ForeGroundColor = System.Drawing.Color.White;

            // ... Chart title
            chart.ChartTitle = "Reussite".Equals(lstAnalyse.Items[i].Value) ?
                EXPORT_ANALYSIS_SUCCESS :
                EXPORT_ANALYSIS_FAILURE;
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size = 10;

            // X axis
            chart.PrimaryCategoryAxis.Font.IsBold = false;
            chart.PrimaryCategoryAxis.Font.Size = 6;
            // ... ... Main
            chart.PrimaryCategoryAxis.Title = "Mois / Month";
            chart.PrimaryCategoryAxis.TitleArea.Size = 8;
            chart.PrimaryCategoryAxis.TitleArea.IsBold = true;
            // ... ... Sub
            chart.PrimaryCategoryAxis.TextRotationAngle = 90;

            // Y axis
            chart.PrimaryValueAxis.Font.IsBold = false;
            chart.PrimaryValueAxis.Font.Size = 6;
            chart.PrimaryValueAxis.HasMajorGridLines = true;
            // ... ... Main
            chart.PrimaryValueAxis.Title = "Pourcentage / Percent";
            chart.PrimaryValueAxis.TitleArea.Size = 8;
            chart.PrimaryValueAxis.TitleArea.IsBold = true;
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;

            // CML: Sets line options (weigth and color)
            for (int j = 0; j < chart.Series.Count; j++)
            {
                chart.Series[j].Format.LineProperties.Weight = ChartLineWeightType.Wide;
                chart.Series[j].Format.LineProperties.Color = SpireXlsHelper.CURVES_COLORS_ROTATE[j];
            }
           

            chart.Legend.Position = LegendPositionType.Top;


I still get a graph background in grey.
Is that a normal behaviour ? Neither BackgroundColor nor ForegroundColor seems to change something.

Thanks by advance for your answers

C.

marfilc
 
Posts: 3
Joined: Fri Oct 03, 2008 2:26 pm

Wed Oct 08, 2008 8:46 am

Sorry,
I tried with blue and that did change the global background of the graph. But this is not the one I wanted to change.
I need to change the background of the graph area (where lines are displayed).
Is there another area to change ?

Thanks
C.

marfilc
 
Posts: 3
Joined: Fri Oct 03, 2008 2:26 pm

Wed Sep 09, 2015 9:52 pm

Doesn't look like this question was ever answered. Use PlotArea instead of ChartArea:

Code: Select all
chart.PlotArea.ForeGroundColor = System.Drawing.Color.Aqua;

daveb
 
Posts: 12
Joined: Mon Jul 27, 2015 4:07 pm

Thu Sep 10, 2015 8:19 am

Hello,

Thanks for your sharing. You are absolutely right.
Please feel free to contact us, if you have any questions or needs. We are here for help.

Best Regards,
Sweety
E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Return to Spire.XLS

cron