ZedGraph填充区域

时间:2011-02-02 20:09:44

标签: c# graphics zedgraph

我正在使用ZedGraph控件,并希望用一些颜色填充图形函数的一面,而另一面填充其他颜色。

 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?

1 个答案:

答案 0 :(得分:5)

我不太清楚你在问什么 - 但希望下面的内容会有所帮助。你在评论中说了

  

我可以在Zedgraph中填充一些多边形区域吗?

所以这就是......

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);

结果

enter image description here

希望这会指出你正确的方向!

Code in VB as requested来自http://converter.telerik.com/ - 无法保证VB代码正常工作甚至编译!)