7

Is it possible to change the background color (white by default) of a zedgraph pane?

I tried changing the background color of the zedgraph element, but it doesn't give any visible result, background is still white:

ZedGraphControl.BackColor = System.Drawing.Color.Black;

And there doesn't seem to exist a Color or BackColor property on ZedGraphControl.GraphPane.

Otiel
  • 18,404
  • 16
  • 78
  • 126

3 Answers3

6
myChart.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black;
SpeziFish
  • 3,262
  • 2
  • 28
  • 27
  • Not exactly what I'm looking for. I would like to change the color of the `GraphPane`, not only the `Chart`. In your case, the background color around the chart (axies, legends) is still white. – Otiel Aug 09 '11 at 14:45
  • 1
    Found what was missing: I have also to set: `myChart.GraphPane.Fill.Color = System.Drawing.Color.Black;` Noted as accepted even if it provides only the half of the answer ;) Thx – Otiel Aug 09 '11 at 14:56
5

myChart.GraphPane.Fill.Color = System.Drawing.Color.Black; will create a gradient fill started with black color. If you don't want to use gradient you should use -

myChart.GraphPane.Chart.Fill.Brush = new System.Drawing.SolidBrush(Color.Black);

Hope this will solve your problem.

s.k.paul
  • 7,099
  • 28
  • 93
  • 168
5

You can use

zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;

to change the background [only] of the chart. If you want to change the background color the zedgraph except the chart, use

zg.GraphPane.Fill.Color = SystemColors.ControlText;

If you want to change the background color of everything in the zedgraph, use both:

zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;
zg.GraphPane.Fill.Color = SystemColors.ControlText;

EDIT: I know that you already solved your problem but I made this so if someone searches it, he can solve his problem quickly :)

Fábio Noga
  • 66
  • 1
  • 4
  • I'll accept your answer because you are right, it will be more helpful for people having the same issue. – Otiel Dec 13 '16 at 10:59