在.net中的笛卡尔图表中显示所有四个象限 [英] show all four quadrants in a Cartesian chart in .net

查看:134
本文介绍了在.net中的笛卡尔图表中显示所有四个象限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在笛卡尔图表中显示四个象限。请指导我如何使用标准图表控件制作笛卡尔图表。

我的输入值类似{(5,10) ,(15, - 4),( - 20, - 9),( - 10,14)},

I am trying to show four quadrants in a Cartesian chart .Please guide how can i use the standard chart control to make a Cartesian chart.
my input values are like { (5,10 ) , ( 15, - 4 ) , ( -20, - 9 ), ( -10,14) } ,

推荐答案

重要的设置是交叉属性在X轴和Y轴上。它需要设置为零。这是一个简单的例子:



The important setting is the "Crossing" property on both the X-axis and Y-axis. It needs to be set to zero. Here is a simple example:

Imports System.Windows.Forms.DataVisualization

Public Class Form1

   Private WithEvents Chart1 As New Charting.Chart

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   Dim series_1 As New Charting.Series
   Dim chartarea_1 As New Charting.ChartArea

   With Chart1
      .Parent = Me
      .Dock = DockStyle.Fill
      .ChartAreas.Clear()
      chartarea_1 = .ChartAreas.Add("area1")
      With chartarea_1
         With .AxisX
            .Crossing = 0 ' this is the important setting
            .Minimum = -20
            .Maximum = 20
            .MajorGrid.Enabled = True
            .LineWidth = 2
            .Interval = 5
            .MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot
         End With

         With .AxisY
            .Crossing = 0 ' this is the important setting
            .Minimum = -20
            .Maximum = 20
            .LineWidth = 2
            .Interval = 5
            .MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot
         End With

      End With

      ' make some data to chart
      .Series.Clear()
      series_1 = .Series.Add("series1")
      With series_1

         .ChartType = Charting.SeriesChartType.Spline
         .IsVisibleInLegend = False
         .ChartArea = chartarea_1.Name
         Dim rnd As New Random

         For x As Double = -20 To 20
            .Points.AddXY(x, (rnd.NextDouble() * 40.0#) - 20.0#)
         Next
      End With
   End With

End Sub

   Private Sub Chart1_FormatNumber(ByVal sender As Object, ByVal e As System.Windows.Forms.DataVisualization.Charting.FormatNumberEventArgs) Handles Chart1.FormatNumber
      If e.ElementType = Charting.ChartElementType.AxisLabels AndAlso e.Value = 0 Then
         ' do not print out zero on the axis
         e.LocalizedValue = ""
      End If
   End Sub

End Class


这篇关于在.net中的笛卡尔图表中显示所有四个象限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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