Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在VB.NET2005或C#.NET2005中还有其他方法可以创建图表吗_C#_Vb.net - Fatal编程技术网

在VB.NET2005或C#.NET2005中还有其他方法可以创建图表吗

在VB.NET2005或C#.NET2005中还有其他方法可以创建图表吗,c#,vb.net,C#,Vb.net,我正在用VB.NET2005做Windows应用程序。我想在我的项目中使用图表。我已经在这个网站上问过这个问题了。但观众表示,解决方案是使用“MSChartControl”(但这是针对VisualStudio2008的)。有没有其他方法可以在我们自己的代码中创建图表(不使用他人的第三方dll)。需要善意的帮助。提前谢谢 Sivakumar.p您可以使用System.Drawing.Graphics对象的方法自己绘制一个。这可以直接在表单的OnPaint覆盖/事件中完成,也可以封装在单独的组件/控

我正在用VB.NET2005做Windows应用程序。我想在我的项目中使用图表。我已经在这个网站上问过这个问题了。但观众表示,解决方案是使用“MSChartControl”(但这是针对VisualStudio2008的)。有没有其他方法可以在我们自己的代码中创建图表(不使用他人的第三方dll)。需要善意的帮助。提前谢谢


Sivakumar.p

您可以使用System.Drawing.Graphics对象的方法自己绘制一个。这可以直接在表单的OnPaint覆盖/事件中完成,也可以封装在单独的组件/控件中

Public Class Form1
Protected Overrides Sub OnCreateControl()
  MyBase.OnCreateControl()
  SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  MyBase.OnPaint(e)

  With e.Graphics
     .DrawLines(SystemPens.WindowText, New Point() { _
                New Point(60, 0), _
                New Point(60, ClientRectangle.Bottom - 60), _
                New Point(ClientRectangle.Right, ClientRectangle.Bottom - 60)})
     For y = 0 To 100 Step 15
        Dim wid = e.Graphics.MeasureString(y.ToString, Font).Width
        .DrawString(y.ToString, Font, SystemBrushes.WindowText, 60 - wid, CSng(ClientRectangle.Bottom - 60 - (y * (ClientRectangle.Size.Height - 60) / 100)))
     Next

     Dim sf As New System.Drawing.StringFormat(System.Drawing.StringFormatFlags.DirectionVertical)
     For x = 0 To 5
        Dim dateStr = DateTime.Today.AddDays(x).ToShortDateString()
        Dim xCoord As Integer = CInt(60 + (ClientSize.Width - 60) * (x + 0.5) / 6)
        Dim yBottom As Integer = ClientRectangle.Bottom - 60
        .DrawString(dateStr, Font, SystemBrushes.WindowText, xCoord, yBottom, sf)
        Dim yTop As Integer = CInt(yBottom - (CInt(Date.Today.AddDays(x).DayOfWeek) + 2) * (ClientSize.Height - 60) / 10)
        Dim bar As Rectangle = New Rectangle(xCoord, yTop, 18, yBottom - yTop)
        .FillRectangle(Brushes.LightBlue, bar)
        .DrawRectangle(SystemPens.WindowText, System.Drawing.Rectangle.Round(bar))
     Next
  End With
End Sub
End Class

你最好的选择是使用javascript,而不是自己开发。

javascript图表怎么样


MSDN杂志上有一篇关于这个话题的老文章。

您还可以查看CodePlex中是否有任何开源的.NET图表组件。

有趣的格式选择!相同用户的重复。请给出一些示例。好的,我添加了一些非常简单的示例代码,可以直接在表单上绘制图表。当然,您希望有更多的变量和过程使其更灵活,但这演示了如何绘制看起来像图表的图形。