如何在Windows窗体中使用数组绘制图形 [英] how to draw graphs using arrays in windows form

查看:88
本文介绍了如何在Windows窗体中使用数组绘制图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Visual Basic 2010中使用数组在Windows窗体中绘制图形,但值得注意的是读取了值.所以plz帮助我如何编写绘制图形的代码.plzzz

am trying to draw graph in visual basic 2010 in windows form using arrays am notable to read values.so plz help me how do i write code to draw graph.plzzz

推荐答案

您将需要第三方工具来允许您为您做图.
假设您正在使用C#,则可以在中查看此库.用于图形绘制的简单C#库 [ ^ ].
You would need a third party tool that would allow you to do the plot for you.
Assuming you are using C#, you can take a look at this library available at A simple C# library for graph plotting[^].


CodeProject 文章Zedgraph 库. com/Articles/5431/A-flexible-charting-library-for-NET>适用于.NET的灵活图表库 [
The Zedgraph library given in this CodeProject article A flexible charting library for .NET[^] By JChampion is a very good charting library which has options to draw graphs.

A Test graph is explained in the article.

A VB Sample project is also included in the article.

Download this sample project and to test with arrays replace the CreateGraph method in this project with the following code.
Private Sub CreateGraph(ByVal zgc As ZedGraphControl)
    Dim myPane As GraphPane = zgc.GraphPane

    ' Set the titles and axis labels
    myPane.Title.Text = "My Test Date Graph"
    myPane.XAxis.Title.Text = "X Value"
    myPane.YAxis.Title.Text = "My Y Axis"

    ' Make up some data points with arrays
    ' or populate the arrays from a DataSource
    Dim x As Double() = New Double() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    Dim y As Double() = New Double() {10, 20, 30, 50, 30, 20, 100, 60, 40, 20}

    ' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
    Dim myCurve As LineItem = myPane.AddCurve("My Curve", x, y, Color.Blue, SymbolType.Circle)
    ' Make the symbols opaque by filling them with white
    myCurve.Symbol.Fill = New Fill(Color.White)
    ' Fill the axis background with a color gradient
    myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
    ' Fill the pane background with a color gradient
    myPane.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
    ' Calculate the Axis Scale Ranges
    zgc.AxisChange()
End Sub


并运行该应用程序以测试使用数组绘制的图形.


and run the application to test the graph drawn with arrays.


这篇关于如何在Windows窗体中使用数组绘制图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆