5

I am using the ZedGraph control and want to fill one side of the graph function with some color and other side with other color.

 PointPairList list1 = new PointPairList();
 list1.Add(0, 4);
 list1.Add(4, 0);
 LineItem myCurve = myPane.AddCurve("y(n)", list1, Color.Red, SymbolType.Diamond);

 //This filling bottom side.
 myCurve.Line.Fill = new Fill(Color.White, Color.FromArgb(113, 255, 0, 0), 90F);

 //How to fill the top side?
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sergey
  • 933
  • 2
  • 19
  • 48
  • 1
    Can't you just add one fill as the whole chart's background, and then second just as you did, as the fill for your curve? That Should do the trick. Or maybe you have something else on mind? – Gacek Feb 04 '11 at 11:46
  • actually I did like you said, but I need to fill area thats formed with multiple line intersections (some polygon),can I fill some polygon area in Zed graph? – Sergey Feb 10 '11 at 21:04
  • Were you able to solve it? Is the only way to modify source code? – edgarmtze Jul 24 '13 at 19:35
  • Is here where we should modify the code https://github.com/lightweightlabs/zedgraph-lw/blob/master/source/ZedGraph/Fill.cs ? – edgarmtze Jul 25 '13 at 02:59

1 Answers1

7

I'm not very clear on what you're asking - but hopefully the below will help. You said in comments

Can I fill some polygon area in Zedgraph?

So here's how...

var zed = new ZedGraph.ZedGraphControl { Dock = System.Windows.Forms.DockStyle.Fill };

var poly = new ZedGraph.PolyObj
{
    Points = new[]
    {
        new ZedGraph.PointD(0, 0),
        new ZedGraph.PointD(0.5, 1),
        new ZedGraph.PointD(1, 0.5),
        new ZedGraph.PointD(0, 0)
    },
    Fill = new ZedGraph.Fill(Color.Blue),
    ZOrder = ZedGraph.ZOrder.E_BehindCurves
};

var poly1 = new ZedGraph.PolyObj
{
    Points = new[]
    {
        new ZedGraph.PointD(1, 0),
        new ZedGraph.PointD(0.25, 1),
        new ZedGraph.PointD(0.5, 0),
        new ZedGraph.PointD(1, 0)
    },
    Fill = new ZedGraph.Fill(Color.Red),
    ZOrder = ZedGraph.ZOrder.E_BehindCurves
};

zed.GraphPane.AddCurve("Line", new[] { 0.0, 1.0 }, new[] { 0.0, 1.0 }, Color.Green);
zed.GraphPane.GraphObjList.Add(poly1);
zed.GraphPane.GraphObjList.Add(poly);

Results in

enter image description here

Hopefully this will point you in the right direction!

(Code in VB as requested via http://converter.telerik.com/ - no guarentee of the VB code working or even compiling!)

dav_i
  • 27,509
  • 17
  • 104
  • 136
  • Could you please post an analog of the example in vb.net. I think this is really helpful for everybody. – edgarmtze Jul 30 '13 at 16:04
  • Via http://converter.telerik.com/... http://pastebin.com/jsFB1jxP... I haven't used VB in years so I can't guarantee the validity. Question updated. – dav_i Jul 30 '13 at 16:10