Click here to Skip to main content
Rate this: bad
good
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.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 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
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 20 Apr 2012
Copyright © CodeProject, 1999-2014
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