Click here to Skip to main content
15,896,479 members

Datavisualization Charting: Formatting axes and show labels without Series In.

edmonson asked:

Open original thread
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.
Tags: .NET, Chart

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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