How to change my chart control background color
15,944
To change the background color of the chart, you will need to change the BackColor
property of the ChartArea
.
chart.ChartAreas["ChartArea1"].BackColor = Color.Black;
chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.LawnGreen;
chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.LawnGreen;
Author by
user3271698
Updated on June 04, 2022Comments
-
user3271698 almost 2 years
This is my control:
seriesTraffic = new Series(); seriesTraffic.Color = Color.Black; seriesTraffic.ChartType = SeriesChartType.Spline; seriesTraffic.BorderWidth = 2; chart1.Series.Add(seriesTraffic); chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.White; chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.White; chart1.ChartAreas[0].AxisX.LabelStyle.Enabled = false; chart1.ChartAreas[0].AxisY.LabelStyle.Enabled = false; chart1.ChartAreas[0].AxisY.Minimum = 10; chart1.ChartAreas[0].AxisX.Maximum = 10; chart1.ChartAreas[0].AxisY.Minimum = 10; chart1.ChartAreas[0].AxisY.Maximum = 10; chart1.ChartAreas[0].AxisY.Interval = 5; chart1.ChartAreas[0].AxisY.Interval = 1; chart1.ChartAreas[0].AxisX.IsStartedFromZero = true; chart1.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Number; var chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); chart1.BackColor = System.Drawing.Color.Black; chartArea1.AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True; chartArea1.AxisY.MinorGrid.Enabled = true; chartArea1.AxisX.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True; chartArea1.AxisX2.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True; chartArea1.AxisX2.MinorGrid.Enabled = true; chartArea1.AxisX.LineColor = System.Drawing.Color.Green; chartArea1.AxisX2.LineColor = System.Drawing.Color.Green; chartArea1.AxisX2.LineWidth = 1; chartArea1.AxisX2.MinorGrid.Interval = 0.25D; chartArea1.AxisX2.MinorGrid.IntervalOffset = -0.01D; chartArea1.AxisX2.MinorGrid.LineColor = System.Drawing.Color.Green; chartArea1.AxisY.LineColor = System.Drawing.Color.Green; chartArea1.AxisY.LineWidth = 1; chartArea1.AxisY.Maximum = 2D; chartArea1.AxisY.MaximumAutoSize = 100F; chartArea1.AxisY.Minimum = -2D; chartArea1.AxisY.MinorGrid.Interval = 0.25D; chartArea1.AxisY.MinorGrid.IntervalOffset = -0.01D; chartArea1.AxisY.MinorGrid.LineColor = System.Drawing.Color.Green; chart1.ChartAreas.Add(chartArea1);
i want to change my control style to similar to this:
i try to change
BackSecondaryColor
,BorderColor
but it has no effect. i try to changeBackSecondaryColor
,BorderColor
but it has no effect. i try to changeBackSecondaryColor
,BorderColor
but it has no effect. i try to changeBackSecondaryColor
,BorderColor
but it has no effect. -
user3271698 about 10 yearsSee my update, i have added your code to mined and still same result