Click here to Skip to main content
11,927,600 members (47,140 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET Chart
I'm developing an application using chart datavisualization namespace on VS2010

I can configure the Axis to work properly on start up application.

I wold like to show labels intervals without no need to add data series (show the chart configuration with empty data).

This is the code:
Imports System.Windows.Forms.DataVisualization
Imports System.Windows.Forms.DataVisualization.Charting
Sub InitGraph()

        Chart1.ChartAreas(0).CursorX.IsUserEnabled = True
        Chart1.ChartAreas(0).CursorX.IsUserSelectionEnabled = True
        Chart1.ChartAreas(0).CursorY.IsUserEnabled = True
        Chart1.ChartAreas(0).CursorY.IsUserSelectionEnabled = True
        'Eje X
        Chart1.ChartAreas(0).AxisX.ScaleView.Zoomable = True
        Chart1.ChartAreas(0).AxisX.ScrollBar.IsPositionedInside = False
        Chart1.ChartAreas(0).AxisX.LineWidth = 1
        Chart1.ChartAreas(0).AxisX.Interval = 120
        Chart1.ChartAreas(0).AxisX.LabelStyle.Angle = 90
        Chart1.ChartAreas(0).AxisX.Maximum = 3600
        Chart1.ChartAreas(0).AxisX.Minimum = 0
        Chart1.ChartAreas(0).AxisX.MajorGrid.LineDashStyle = ChartDashStyle.DashDot
        Chart1.ChartAreas(0).AxisX.Enabled = AxisEnabled.True


        'Eje Y
        Chart1.ChartAreas(0).AxisY.ScaleView.Zoomable = True
        Chart1.ChartAreas(0).AxisY.ScrollBar.IsPositionedInside = False
        Chart1.ChartAreas(0).AxisY.MajorGrid.LineDashStyle = ChartDashStyle.DashDot
        Chart1.ChartAreas(0).AxisY.Maximum = 100
        Chart1.ChartAreas(0).AxisY.Minimum = 0
        Chart1.ChartAreas(0).AxisY2.Maximum = 50
        Chart1.ChartAreas(0).AxisY2.Minimum = 0
        Chart1.ChartAreas(0).AxisY.Enabled = AxisEnabled.True
        Chart1.ChartAreas(0).AxisY2.Enabled = AxisEnabled.True
When the application is Started there are no labels on both axes. I need to add a dummy serie to viewe them.

The serie code is this:
      With Chart1.Series(0)
          .Color = Color.White
          .IsValueShownAsLabel = False
          .IsVisibleInLegend = False
          .ChartType = DataVisualization.Charting.SeriesChartType.Line
          .YAxisType = AxisType.Primary
          For i = 0 To 3600
              .Points.AddXY(i, 0)
              .Points(i).AxisLabel = i
              .Points(i).IsEmpty = True
          Next i
      End With

My question is, how can I show the labels on the axes without to add a dummy serie ?

I'm looking at chart classes, and I can't find anything to force it.

Posted 20-Apr-12 0:59am

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.151126.1 | Last Updated 20 Apr 2012
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