Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.Series.Clear()

        'Cursores

        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:
Chart1.Series.Add("Demo")
      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.

Regards.
Posted

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