Click here to Skip to main content
11,923,517 members (68,111 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB VB.NET Chart
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 18-May-13 6:14am
Edited 19-May-13 18:53pm
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?
Sergey Alexandrovich Kryukov 18-May-13 22:19pm
Please pay attention how OP cheats with fake "answers":,

muneebalikiyani 24-Jun-13 0:05am
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"?
muneebalikiyani 19-May-13 23:47pm
yes u are right, i guess i have used wrong terminology..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
      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_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#)
      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
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151125.3 | Last Updated 21 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100