4

我在计量实验室工作,我需要用 c# 开发一个用于圆度计设备的软件,我已经开始并且发现了一个问题,我需要该软件来显示来自测量的实时图形正在制作中,因为我需要使用像 Mscharts 或 Zedgraph 这样的库,它刷新信息的速度非常快,并且支持像 Polar 或雷达这样的圆形图,尤其是极坐标图。我在大多数库中看到的问题是它们都缺乏对圆形图的支持并且速度相对较慢。有人推荐我可以使用的图书馆吗?

感谢您的帮助。PS:软件应显示如下图形: 在此处输入图像描述

在此处输入图像描述 最终的软件应该是这样的

4

4 回答 4

1

不确定这是否有帮助。 Xceed Charts在其高级部分中谈到了制作极坐标图。不幸的是,他们没有提供任何图像,因此您应该与他们的销售人员交谈,看看您是否可以获得评估副本进行评估。

于 2012-07-18T18:31:56.250 回答
1

我会用 GDI(+) 渲染它们(在 winforms 应用程序中)。

是的,这是基本的线条图,但对于您提供的示例来说,它已经足够强大了。你需要更新你的高中数学,但它会让你对输出有很多控制,而且速度很快。

于 2012-07-18T18:32:32.057 回答
1

考虑使用 roguewave IMSL Numerical .NET 库

IMSL 数值 .NET 库的主页

图表示例,类似于您在上面发布的内容

尤其是极地情节似乎是您在这里所需要的。

于 2012-07-18T18:57:39.087 回答
1

我很惊讶 ZedGraph 不支持开箱即用的极坐标图,并且在线示例很少。使用这个 guildline,我用 C# 中的 ZedGraph 创建了我自己的极坐标图。我希望 WillKraemer 已经解决了他的问题(4 年过去了),并且其他人发现我的实现很有用。

首先是 ZedGraphControl 初始化:

        myZg = new ZedGraphControl();
        GraphPane myPane = myZg.GraphPane;

        // Init lists
        RadarPointList dseries1 = new RadarPointList();
        RadarPointList dseries2 = new RadarPointList();

        // Maximize available space in pane
        myPane.Legend.Position = LegendPos.InsideTopLeft;
        myPane.Title.IsVisible = false;
        myPane.XAxis.IsVisible = false;
        myPane.YAxis.IsVisible = false;
        myPane.Border.IsVisible = false;
        myPane.Chart.Border.IsVisible = false;
        myPane.Margin.All = 0;

        // Create concentric grid with 30 degrees spacing & add corresponding labels
        for (double i = 0; i < 36; i+=3.0)
        {
            TextObj gridlbs = new TextObj((i * 10.0).ToString("0°"), (radius + 10.0) * Math.Cos((i * 10.0 * Math.PI) / 180.0), (radius + 10.0) * Math.Sin((i * 10.0 * Math.PI) / 180.0));
            gridlbs.FontSpec.Border.IsVisible = false;
            LineObj gridlns = new LineObj(0, 0, radius * Math.Cos((i * 10.0 * Math.PI) / 180.0), radius * Math.Sin((i * 10.0 * Math.PI) / 180.0));

            myPane.GraphObjList.Add(gridlbs);
            myPane.GraphObjList.Add(gridlns);
        }

        // Draw circular grid, 5 should look okay
        for (double i = (radius / 5.0); i <= radius; i += (radius / 5.0))
        {
            EllipseObj gridcrl = new EllipseObj(-i, i, 2.0 * i, 2.0 * i);
            gridcrl.ZOrder = ZOrder.E_BehindCurves;
            myPane.GraphObjList.Add(gridcrl);
        }

        // Make sure the pane is big enough to fit the labels around the polar plot
        myPane.XAxis.Scale.Min = -(radius + 20.0);
        myPane.XAxis.Scale.Max = (radius + 20.0);
        myPane.YAxis.Scale.Min = -(radius + 20.0);
        myPane.YAxis.Scale.Max = (radius + 20.0);

        _selectedRadius = radius;
        // Keep X & Y axis in the correct ratio to avoid distorting polar circle 
        myZg_Resize((object)"Startup", EventArgs.Empty);
        myZg.Resize += new EventHandler(myZg_Resize);
        myZg.ZoomEvent  += new ZedGraphControl.ZoomEventHandler(myZg_ZoomEvent2);

        // Draw snailly curves (example)
        for (int i = 0; i < 360; i++)
        {
            double r = (double)i/360.0 * radius;
            PointPair pt = new PointPair(PointPair.Missing, r, null);
            dseries1.Add(pt);
            PointPair pt2 = new PointPair(PointPair.Missing, radius - r, null);
            dseries2.Add(pt2);
        }

        // Curves are somple LineItem
        FirstCurve = myPane.AddCurve("Snail", dseries1, Color.Blue, SymbolType.None);
        SecondCurve = myPane.AddCurve("antiSnail", dseries2, Color.Red, SymbolType.None);

        // Rotate the lists to aling with labels
        dseries1.Rotation = 0;
        dseries2.Rotation = 0;

我必须确保在窗体/控件调整大小时图表不会失真,所以我在调整大小事件中添加了这个:

    protected void myZg_Resize(object sender, EventArgs e)
    {
        GraphPane pane = myZg.GraphPane;
        myZg.AxisChange();
        bool IsXMin = ( pane.Rect.Width < pane.Rect.Height ) ? true : false;
        if (IsXMin)
        {   
            // Scale based on X (width)
            pane.XAxis.Scale.Max = (radius + 20.0); pane.XAxis.Scale.Min = -(radius + 20.0);
            double xPixPerUnit = (double)pane.Chart.Rect.Width / (pane.XAxis.Scale.Max - pane.XAxis.Scale.Min);
            pane.YAxis.Scale.Max = (double)pane.Chart.Rect.Height / xPixPerUnit / 2.0;
            pane.YAxis.Scale.Min = -pane.YAxis.Scale.Max;
            myZg.AxisChange();
        }
        else
        {
            // Scale based on Y (height)
            pane.YAxis.Scale.Max = (radius + 20.0); pane.YAxis.Scale.Min = -(radius + 20.0);
            double yPixPerUnit = (double)pane.Chart.Rect.Height / (pane.YAxis.Scale.Max - pane.YAxis.Scale.Min);
            pane.XAxis.Scale.Max = (double)pane.Chart.Rect.Width / yPixPerUnit / 2.0;
            pane.XAxis.Scale.Min = -pane.XAxis.Scale.Max;
            myZg.AxisChange();
        }
    }

此外,我决定阻止用户进行任何缩放操作:

    protected void myZg_ZoomEvent2(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
    {
        myZg_Resize("zoomevent", EventArgs.Empty);
    }

输出如下图所示:

在此处输入图像描述

建议随时欢迎!

于 2016-10-19T14:57:03.747 回答