none
Axis X and Y on chart behave differently RRS feed

  • Question

  • These simple lines should put labels on x and y axis of a chart:

      Me.Chart1.Series(0).Points.AddXY(0, 0)
    
      Me.Chart1.ChartAreas(0).AxisX.Enabled = AxisEnabled.True
      Me.Chart1.ChartAreas(0).AxisX.Title = "X"
      Me.Chart1.ChartAreas(0).AxisY.Enabled = AxisEnabled.True
      Me.Chart1.ChartAreas(0).AxisY.Title = "Y"
         
      Me.Chart1.ChartAreas(0).AxisX.Minimum = 0
      Me.Chart1.ChartAreas(0).AxisX.Maximum = 1
      Me.Chart1.ChartAreas(0).AxisX.MinorTickMark.Enabled = True
            
      Me.Chart1.ChartAreas(0).AxisY.Minimum = 0
      Me.Chart1.ChartAreas(0).AxisY.Maximum = 1

    Why i have to add a point to make visible labels?

    Why labels on y axis are correct but on x axis appears only a "1"?

    Friday, March 6, 2020 9:47 PM

Answers

  • Hy Leshay and thanks for your reply.

    Acoording to your advice i have written this:

     Me.Chart1.ChartAreas(0).AxisX.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX.Title = "X"
            Me.Chart1.ChartAreas(0).AxisY.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisY.Title = "Y"
            Me.Chart1.ChartAreas(0).AxisY.IsReversed = True
    
            Creates Labels axis X 
            Me.Chart1.ChartAreas(0).AxisX.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX.Maximum = 2      
            Me.Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX.Interval = 0.5
    
            Creates Labels axis Y
            Me.Chart1.ChartAreas(0).AxisY.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisY.Maximum = 1
            Me.Chart1.ChartAreas(0).AxisY.MajorGrid.Enabled = False
            
            Axis X2
            Me.Chart1.ChartAreas(0).AxisX2.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX2.Title = "Secondary Axis"
            Me.Chart1.ChartAreas(0).AxisX2.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX2.LineWidth = 5
            Me.Chart1.ChartAreas(0).AxisX2.LineColor = Color.SaddleBrown
            Me.Chart1.ChartAreas(0).AxisX2.Maximum = 10
            Me.Chart1.ChartAreas(0).AxisX2.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX2.Interval = 0.5
    
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.FastLine
           
            Me.Chart1.Series(0).Color = Color.Black
    
            For n = 0 To 200
                Me.Chart1.Series(0).Points.AddXY(0.01 * n, 0.005 * n)
            Next

    that gives:

    Why secondary axis does not continue with labels?

    Please mark this post as the answer not your own. That is how it is done. This post is the answer. If you post the answer then ok mark that post. You can mark multiple answers.

    PS Please ask mostly one topic question per thread when practical.

    Les answered your first question. You can mark multiple answers. I marked Les's post as proposed now you should mark it as "the answer" from original poster (OP - that is you).  Then mark this post as the answer for your second question.

    Comprende???

    That makes the future member searching more logical and gives the credit where due.

    :)

     

      Chart1.Series(0).XAxisType = AxisType.Secondary






    Saturday, March 7, 2020 2:49 PM

All replies

  • Hi

    Add some values and you should see some intermediate labels.


    Regards Les, Livingston, Scotland

    • Proposed as answer by tommytwotrain Saturday, March 7, 2020 3:24 PM
    Friday, March 6, 2020 10:44 PM
  • Hy Leshay and thanks for your reply.

    Acoording to your advice i have written this:

     Me.Chart1.ChartAreas(0).AxisX.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX.Title = "X"
            Me.Chart1.ChartAreas(0).AxisY.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisY.Title = "Y"
            Me.Chart1.ChartAreas(0).AxisY.IsReversed = True
    
            Creates Labels axis X 
            Me.Chart1.ChartAreas(0).AxisX.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX.Maximum = 2      
            Me.Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX.Interval = 0.5
    
            Creates Labels axis Y
            Me.Chart1.ChartAreas(0).AxisY.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisY.Maximum = 1
            Me.Chart1.ChartAreas(0).AxisY.MajorGrid.Enabled = False
            
            Axis X2
            Me.Chart1.ChartAreas(0).AxisX2.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX2.Title = "Secondary Axis"
            Me.Chart1.ChartAreas(0).AxisX2.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX2.LineWidth = 5
            Me.Chart1.ChartAreas(0).AxisX2.LineColor = Color.SaddleBrown
            Me.Chart1.ChartAreas(0).AxisX2.Maximum = 10
            Me.Chart1.ChartAreas(0).AxisX2.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX2.Interval = 0.5
    
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.FastLine
           
            Me.Chart1.Series(0).Color = Color.Black
    
            For n = 0 To 200
                Me.Chart1.Series(0).Points.AddXY(0.01 * n, 0.005 * n)
            Next

    that gives:

    Why secondary axis does not continue with labels?

    Saturday, March 7, 2020 1:04 PM
  • Hy Leshay, i have found.

    Main x axis was limited to the value of 2, while secondary axis had 10 as maximum.

    But if I want that the scale of secondary axis remains different ?

    The bottom axis (secondary) should continue with labels till 10.

    Regards, Enzo


    Saturday, March 7, 2020 1:06 PM
  • Hy Leshay and thanks for your reply.

    Acoording to your advice i have written this:

     Me.Chart1.ChartAreas(0).AxisX.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX.Title = "X"
            Me.Chart1.ChartAreas(0).AxisY.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisY.Title = "Y"
            Me.Chart1.ChartAreas(0).AxisY.IsReversed = True
    
            Creates Labels axis X 
            Me.Chart1.ChartAreas(0).AxisX.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX.Maximum = 2      
            Me.Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX.Interval = 0.5
    
            Creates Labels axis Y
            Me.Chart1.ChartAreas(0).AxisY.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisY.Maximum = 1
            Me.Chart1.ChartAreas(0).AxisY.MajorGrid.Enabled = False
            
            Axis X2
            Me.Chart1.ChartAreas(0).AxisX2.Enabled = AxisEnabled.True
            Me.Chart1.ChartAreas(0).AxisX2.Title = "Secondary Axis"
            Me.Chart1.ChartAreas(0).AxisX2.MajorGrid.Enabled = False
            Me.Chart1.ChartAreas(0).AxisX2.LineWidth = 5
            Me.Chart1.ChartAreas(0).AxisX2.LineColor = Color.SaddleBrown
            Me.Chart1.ChartAreas(0).AxisX2.Maximum = 10
            Me.Chart1.ChartAreas(0).AxisX2.Minimum = 0
            Me.Chart1.ChartAreas(0).AxisX2.Interval = 0.5
    
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.FastLine
           
            Me.Chart1.Series(0).Color = Color.Black
    
            For n = 0 To 200
                Me.Chart1.Series(0).Points.AddXY(0.01 * n, 0.005 * n)
            Next

    that gives:

    Why secondary axis does not continue with labels?

    Please mark this post as the answer not your own. That is how it is done. This post is the answer. If you post the answer then ok mark that post. You can mark multiple answers.

    PS Please ask mostly one topic question per thread when practical.

    Les answered your first question. You can mark multiple answers. I marked Les's post as proposed now you should mark it as "the answer" from original poster (OP - that is you).  Then mark this post as the answer for your second question.

    Comprende???

    That makes the future member searching more logical and gives the credit where due.

    :)

     

      Chart1.Series(0).XAxisType = AxisType.Secondary






    Saturday, March 7, 2020 2:49 PM