ZedGraph 填充区域

发布于 2024-10-16 03:24:48 字数 383 浏览 2 评论 0原文

我正在使用 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?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

写给空气的情书 2024-10-23 03:24:48

我不太清楚你在问什么 - 但希望以下内容能有所帮助。你在评论里说

我可以在 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);

结果

在此处输入图像描述

希望这将为您指明正确的方向!

(根据要求使用 VB 编写代码,来自 http://converter.telerik.com/ - 不保证 VB 代码工作甚至编译!)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文