Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. vb.net chart axis.X only every 5th Label should be shown.

vb.net chart axis.X only every 5th Label should be shown.

Scheduled Pinned Locked Moved Windows Forms
csharphelp
3 Posts 3 Posters 29 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JTrum
    wrote on last edited by
    #1

    The following problem: Chart x-axis represents calendar weeks from 2021/35 to 2022/36 (current week 2022/19). I don't want to represent every week as a label, but only every 5th week. Up to the current week it looks relatively good, but after that every week is displayed as label.

    newchart(chart1)'erzeugt ein neues leeres chart
    Dim chartArea1 As New ChartArea("Default")
    chart1.AntiAliasing = AntiAliasingStyles.None
    chart1.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
    chart1.ChartAreas.Add(chartArea1)
    chart1.ChartAreas("Default").CursorX.IsUserEnabled = False
    chart1.ChartAreas("Default").CursorX.IsUserSelectionEnabled = False
    chart1.ChartAreas("Default").BackGradientStyle = GradientStyle.None
    'chart1.ChartAreas("Default").Position.Auto = True

    chart1.ChartAreas("Default").Position.Auto = False
    chart1.ChartAreas("Default").Position.X = 0
    chart1.ChartAreas("Default").Position.Y = 10
    chart1.ChartAreas("Default").Position.Width = ChartAreasWidth
    chart1.ChartAreas("Default").Position.Height = ChartAreasHeight - 4

    chart1.ChartAreas("Default").AxisX.ScaleView.Zoomable = True
    chart1.ChartAreas("Default").AxisX.ScrollBar.IsPositionedInside = True
    chart1.ChartAreas("Default").AxisX.MajorGrid.Enabled = False
    chart1.ChartAreas("Default").AxisX.MajorGrid.LineWidth = 1

    chart1.ChartAreas("Default").AxisX.IntervalType = DateTimeIntervalType.Weeks
    chart1.ChartAreas("Default").AxisX.Interval = 1
    chart1.ChartAreas("Default").AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
    chart1.ChartAreas("Default").AxisX.LabelAutoFitMinFontSize = 7
    chart1.ChartAreas("Default").AxisX.LabelStyle.Font = My.Settings.fontbold8
    chart1.ChartAreas("Default").AxisX.LabelStyle.Angle = 90
    chart1.ChartAreas("Default").AxisX.MajorTickMark.Enabled = True
    chart1.ChartAreas("Default").AxisX.MinorTickMark.Enabled = False
    chart1.ChartAreas("Default").AxisX.Minimum = von_X.ToOADate()
    chart1.ChartAreas("Default").AxisX.Maximum = bis_X.ToOADate()
    chart1.ChartAreas("Default").AxisX.IsMarginVisible = False

    chart1.ChartAreas("Default").AxisY.MinorTickMark.Enabled = True
    chart1.ChartAreas("Default").AxisY.MinorTickMark.TickMarkStyle = TickMarkStyle.InsideArea
    chart1.ChartAreas("Default").AxisY.MajorGrid.LineWidth = 1
    chart1.ChartAreas("Default").AxisY.MajorGrid.LineColor = Color.Black
    chart1.ChartAreas("Default").AxisY.LabelStyle.Font = My.Settings.fontbold8
    chart1.ChartAreas("Default").AxisY.LabelStyle.Format = "C0"
    chart1.ChartAreas("Default").AxisY.LabelAutoFitStyle = LabelAutoFitStyles.

    D L 2 Replies Last reply
    0
    • J JTrum

      The following problem: Chart x-axis represents calendar weeks from 2021/35 to 2022/36 (current week 2022/19). I don't want to represent every week as a label, but only every 5th week. Up to the current week it looks relatively good, but after that every week is displayed as label.

      newchart(chart1)'erzeugt ein neues leeres chart
      Dim chartArea1 As New ChartArea("Default")
      chart1.AntiAliasing = AntiAliasingStyles.None
      chart1.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
      chart1.ChartAreas.Add(chartArea1)
      chart1.ChartAreas("Default").CursorX.IsUserEnabled = False
      chart1.ChartAreas("Default").CursorX.IsUserSelectionEnabled = False
      chart1.ChartAreas("Default").BackGradientStyle = GradientStyle.None
      'chart1.ChartAreas("Default").Position.Auto = True

      chart1.ChartAreas("Default").Position.Auto = False
      chart1.ChartAreas("Default").Position.X = 0
      chart1.ChartAreas("Default").Position.Y = 10
      chart1.ChartAreas("Default").Position.Width = ChartAreasWidth
      chart1.ChartAreas("Default").Position.Height = ChartAreasHeight - 4

      chart1.ChartAreas("Default").AxisX.ScaleView.Zoomable = True
      chart1.ChartAreas("Default").AxisX.ScrollBar.IsPositionedInside = True
      chart1.ChartAreas("Default").AxisX.MajorGrid.Enabled = False
      chart1.ChartAreas("Default").AxisX.MajorGrid.LineWidth = 1

      chart1.ChartAreas("Default").AxisX.IntervalType = DateTimeIntervalType.Weeks
      chart1.ChartAreas("Default").AxisX.Interval = 1
      chart1.ChartAreas("Default").AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
      chart1.ChartAreas("Default").AxisX.LabelAutoFitMinFontSize = 7
      chart1.ChartAreas("Default").AxisX.LabelStyle.Font = My.Settings.fontbold8
      chart1.ChartAreas("Default").AxisX.LabelStyle.Angle = 90
      chart1.ChartAreas("Default").AxisX.MajorTickMark.Enabled = True
      chart1.ChartAreas("Default").AxisX.MinorTickMark.Enabled = False
      chart1.ChartAreas("Default").AxisX.Minimum = von_X.ToOADate()
      chart1.ChartAreas("Default").AxisX.Maximum = bis_X.ToOADate()
      chart1.ChartAreas("Default").AxisX.IsMarginVisible = False

      chart1.ChartAreas("Default").AxisY.MinorTickMark.Enabled = True
      chart1.ChartAreas("Default").AxisY.MinorTickMark.TickMarkStyle = TickMarkStyle.InsideArea
      chart1.ChartAreas("Default").AxisY.MajorGrid.LineWidth = 1
      chart1.ChartAreas("Default").AxisY.MajorGrid.LineColor = Color.Black
      chart1.ChartAreas("Default").AxisY.LabelStyle.Font = My.Settings.fontbold8
      chart1.ChartAreas("Default").AxisY.LabelStyle.Format = "C0"
      chart1.ChartAreas("Default").AxisY.LabelAutoFitStyle = LabelAutoFitStyles.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There is no option to do this automatically. You would have to go through the Series Points collection and clear the AxisLabel property of every data point you do not want to have a label.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      1 Reply Last reply
      0
      • J JTrum

        The following problem: Chart x-axis represents calendar weeks from 2021/35 to 2022/36 (current week 2022/19). I don't want to represent every week as a label, but only every 5th week. Up to the current week it looks relatively good, but after that every week is displayed as label.

        newchart(chart1)'erzeugt ein neues leeres chart
        Dim chartArea1 As New ChartArea("Default")
        chart1.AntiAliasing = AntiAliasingStyles.None
        chart1.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
        chart1.ChartAreas.Add(chartArea1)
        chart1.ChartAreas("Default").CursorX.IsUserEnabled = False
        chart1.ChartAreas("Default").CursorX.IsUserSelectionEnabled = False
        chart1.ChartAreas("Default").BackGradientStyle = GradientStyle.None
        'chart1.ChartAreas("Default").Position.Auto = True

        chart1.ChartAreas("Default").Position.Auto = False
        chart1.ChartAreas("Default").Position.X = 0
        chart1.ChartAreas("Default").Position.Y = 10
        chart1.ChartAreas("Default").Position.Width = ChartAreasWidth
        chart1.ChartAreas("Default").Position.Height = ChartAreasHeight - 4

        chart1.ChartAreas("Default").AxisX.ScaleView.Zoomable = True
        chart1.ChartAreas("Default").AxisX.ScrollBar.IsPositionedInside = True
        chart1.ChartAreas("Default").AxisX.MajorGrid.Enabled = False
        chart1.ChartAreas("Default").AxisX.MajorGrid.LineWidth = 1

        chart1.ChartAreas("Default").AxisX.IntervalType = DateTimeIntervalType.Weeks
        chart1.ChartAreas("Default").AxisX.Interval = 1
        chart1.ChartAreas("Default").AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
        chart1.ChartAreas("Default").AxisX.LabelAutoFitMinFontSize = 7
        chart1.ChartAreas("Default").AxisX.LabelStyle.Font = My.Settings.fontbold8
        chart1.ChartAreas("Default").AxisX.LabelStyle.Angle = 90
        chart1.ChartAreas("Default").AxisX.MajorTickMark.Enabled = True
        chart1.ChartAreas("Default").AxisX.MinorTickMark.Enabled = False
        chart1.ChartAreas("Default").AxisX.Minimum = von_X.ToOADate()
        chart1.ChartAreas("Default").AxisX.Maximum = bis_X.ToOADate()
        chart1.ChartAreas("Default").AxisX.IsMarginVisible = False

        chart1.ChartAreas("Default").AxisY.MinorTickMark.Enabled = True
        chart1.ChartAreas("Default").AxisY.MinorTickMark.TickMarkStyle = TickMarkStyle.InsideArea
        chart1.ChartAreas("Default").AxisY.MajorGrid.LineWidth = 1
        chart1.ChartAreas("Default").AxisY.MajorGrid.LineColor = Color.Black
        chart1.ChartAreas("Default").AxisY.LabelStyle.Font = My.Settings.fontbold8
        chart1.ChartAreas("Default").AxisY.LabelStyle.Format = "C0"
        chart1.ChartAreas("Default").AxisY.LabelAutoFitStyle = LabelAutoFitStyles.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You should be able to specify which column to use for Labels. Add an extra "label" column to your data and blank out the first 4 in every 5.

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups