ZedGraph 中的曲线项是否可以使用不同的颜色填充?

发布于 2024-10-25 04:48:08 字数 68 浏览 1 评论 0原文

我有一条带有圆点的曲线。是否可以将 CurveItemPoints 设置为不同的填充颜色?我会将显着的点设置为不同的颜色。

I have a single curve with circle points. Is it possible to set CurveItemPoints to a different fill color? I would set significantly points to different colors.

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

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

发布评论

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

评论(1

挽袖吟 2024-11-01 04:48:09

简短的回答:不。

为了执行类似的操作,我创建了额外的 SymbolObj 类,并将该类的对象添加到窗格中以标记一些重要点。

这是一些代码:

internal class SymbolObj : ZedGraph.GraphObj
{
    private ZedGraph.Symbol symbol;

    public SymbolObj(ZedGraph.SymbolType type, Color color, PointF position, float size)
    {
        this.symbol = new ZedGraph.Symbol(type, color);
        this.symbol.Size = size;
        if((type== SymbolType.Plus || type == SymbolType.Star || type== SymbolType.HDash || type == SymbolType.XCross || type == SymbolType.VDash) && size >= 4)
            this.symbol.Border.Width = 3f;
        this.symbol.Fill.IsVisible = true;
        this.symbol.Fill.Color = color;
        this.Location.X = position.X;
        this.Location.Y = position.Y;
    }

    public SymbolObj(SymbolObj rhs)
        : base(rhs)
    {
        this.symbol = new Symbol(rhs.symbol);
    }

    public override void Draw(Graphics g, ZedGraph.PaneBase pane, float scaleFactor)
    {
        if (((GraphPane)pane).XAxis.Type == AxisType.Text)
        {
            if (Location.X > 0)
            {
                var xx = new double[(int)Location.X];
                var yy = new double[(int)Location.X];

                for (int i = 0; i < Location.X; i++)
                {
                    xx[i] = i;
                    yy[i] = double.NegativeInfinity;

                }
                yy[yy.Count() - 1] = Location.Y;
                LineItem line = new LineItem("Symbol", xx, yy, symbol.Fill.Color, SymbolType.None);
                symbol.Draw(g, (GraphPane)pane, line, scaleFactor, false);
            }
        }
        else
        {
            LineItem line = new LineItem("Symbol", new double[] { Location.X }, new double[] { Location.Y }, symbol.Fill.Color, SymbolType.None);
            symbol.Draw(g, (GraphPane)pane, line, scaleFactor, false);
        }
    }

    public override void GetCoords(ZedGraph.PaneBase pane, Graphics g, float scaleFactor, out string shape, out string coords)
    {
        shape = "point";
        coords = this.Location.X.ToString() + ", " + this.Location.Y.ToString();
    }
 }

Short answer: no.

To do similar stuff I created additional SymbolObj class and added objects of that class to the pane to mark some significant points.

Here's some code for that:

internal class SymbolObj : ZedGraph.GraphObj
{
    private ZedGraph.Symbol symbol;

    public SymbolObj(ZedGraph.SymbolType type, Color color, PointF position, float size)
    {
        this.symbol = new ZedGraph.Symbol(type, color);
        this.symbol.Size = size;
        if((type== SymbolType.Plus || type == SymbolType.Star || type== SymbolType.HDash || type == SymbolType.XCross || type == SymbolType.VDash) && size >= 4)
            this.symbol.Border.Width = 3f;
        this.symbol.Fill.IsVisible = true;
        this.symbol.Fill.Color = color;
        this.Location.X = position.X;
        this.Location.Y = position.Y;
    }

    public SymbolObj(SymbolObj rhs)
        : base(rhs)
    {
        this.symbol = new Symbol(rhs.symbol);
    }

    public override void Draw(Graphics g, ZedGraph.PaneBase pane, float scaleFactor)
    {
        if (((GraphPane)pane).XAxis.Type == AxisType.Text)
        {
            if (Location.X > 0)
            {
                var xx = new double[(int)Location.X];
                var yy = new double[(int)Location.X];

                for (int i = 0; i < Location.X; i++)
                {
                    xx[i] = i;
                    yy[i] = double.NegativeInfinity;

                }
                yy[yy.Count() - 1] = Location.Y;
                LineItem line = new LineItem("Symbol", xx, yy, symbol.Fill.Color, SymbolType.None);
                symbol.Draw(g, (GraphPane)pane, line, scaleFactor, false);
            }
        }
        else
        {
            LineItem line = new LineItem("Symbol", new double[] { Location.X }, new double[] { Location.Y }, symbol.Fill.Color, SymbolType.None);
            symbol.Draw(g, (GraphPane)pane, line, scaleFactor, false);
        }
    }

    public override void GetCoords(ZedGraph.PaneBase pane, Graphics g, float scaleFactor, out string shape, out string coords)
    {
        shape = "point";
        coords = this.Location.X.ToString() + ", " + this.Location.Y.ToString();
    }
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文