Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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) } ,
Posted
Updated 19-May-13 17:53pm
v2
Comments
Idle_Force 18-May-13 12:02pm    
Show us some relevant code.
Sergey Alexandrovich Kryukov 18-May-13 22:15pm    
There are only two coordinates in 2D. What are you talking about? Maybe you simply misuse the terminology, but how can you expect others to understand you?
—SA
Sergey Alexandrovich Kryukov 18-May-13 22:19pm    
Please pay attention how OP cheats with fake "answers":
http://www.codeproject.com/Answers/564854/ActiveXobjectplusinplusjavascript#answer1,
http://www.codeproject.com/Answers/564847/Howplustopluscallplusaplusdllplusfunctionplusinplu#answer2.

—SA
muneebalikiyani 24-Jun-13 0:05am    
lol...
TnTinMn 19-May-13 2:11am    
Do you mean "show all four quadrants in a Cartesian chart" as opposed to "show all four coordinates ( xy, x-y, -xy, -x-y ) on a point chart"?

1 solution

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
 
Share this answer
 
Comments
muneebalikiyani 20-May-13 1:44am    
Thanks alot it works :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900