Hello I'm having Trouble here in my ms chart.
6c6bbe39010ff302ee66367ce9439bba

as you can see the chart in the right side the secondary axis i want it to be fixed in the line of the primary axis in the left side

   Public Sub Chart_BU_GP_vs_Target()

        With Chart_EBU_GP_vs_Target

            .Series.Clear()
            .Legends.Clear()

            .ChartAreas("ChartArea1").AxisX.MinorTickMark.Enabled = True
            .ChartAreas("ChartArea1").AxisX.Interval = 1
            .ChartAreas("ChartArea1").AxisX.IsLabelAutoFit = True
            .ChartAreas("ChartArea1").AxisX.LabelAutoFitStyle = DataVisualization.Charting.LabelAutoFitStyles.LabelsAngleStep30

            .Series.Add("Gross Profit")
            .Series("Gross Profit").ChartType = DataVisualization.Charting.SeriesChartType.Column
            .Series("Gross Profit").Points.AddXY("January", Me.BU_JanGP.Text)
            .Series("Gross Profit").Points.AddXY("February", Me.BU_FebGP.Text)
            .Series("Gross Profit").Points.AddXY("March", Me.BU_MarGP.Text)
            .Series("Gross Profit").Points.AddXY("April", Me.BU_AprGP.Text)
            .Series("Gross Profit").Points.AddXY("May", Me.BU_MayGP.Text)
            .Series("Gross Profit").Points.AddXY("June", Me.BU_JunGP.Text)
            .Series("Gross Profit").Points.AddXY("July", Me.BU_JulGP.Text)
            .Series("Gross Profit").Points.AddXY("August", Me.BU_AugGP.Text)
            .Series("Gross Profit").Points.AddXY("September", Me.BU_SepGP.Text)
            .Series("Gross Profit").Points.AddXY("October", Me.BU_OctGP.Text)
            .Series("Gross Profit").Points.AddXY("November", Me.BU_NovGP.Text)
            .Series("Gross Profit").Points.AddXY("December", Me.BU_DecGP.Text)

            .Series.Add("Target")
            .Series("Target").ChartType = DataVisualization.Charting.SeriesChartType.Line
            .Series("Target").BorderWidth = 3
            .Series("Target").YAxisType = DataVisualization.Charting.AxisType.Secondary
            .Series("Target").Points.AddXY("January", Me.BU_JanTGP.Text)
            .Series("Target").Points.AddXY("February", Me.BU_FebTGP.Text)
            .Series("Target").Points.AddXY("March", Me.BU_MarTGP.Text)
            .Series("Target").Points.AddXY("April", Me.BU_AprTGP.Text)
            .Series("Target").Points.AddXY("May", Me.BU_MayTGP.Text)
            .Series("Target").Points.AddXY("June", Me.BU_JunTGP.Text)
            .Series("Target").Points.AddXY("July", Me.BU_JulTGP.Text)
            .Series("Target").Points.AddXY("August", Me.BU_AugTGP.Text)
            .Series("Target").Points.AddXY("September", Me.BU_SepTGP.Text)
            .Series("Target").Points.AddXY("October", Me.BU_OctTGP.Text)
            .Series("Target").Points.AddXY("November", Me.BU_NovTGP.Text)
            .Series("Target").Points.AddXY("December", Me.BU_DecTGP.Text)

            .Legends.Add("Account Manager")
            .Legends("Account Manager").Docking = DataVisualization.Charting.Docking.Bottom

            .Series("Gross Profit").Color = Color.DodgerBlue
            .Series("Target").Color = Color.Red
            .Series("Gross Profit").BorderColor = Color.Black
            .Series("Target").BorderColor = Color.Black

            .ChartAreas("ChartArea1").AxisY.LabelStyle.Format = "##,#"
            .ChartAreas("ChartArea1").AxisY2.LabelStyle.Format = "##,#"
            .ChartAreas("ChartArea1").AxisY.LabelStyle.Font = New System.Drawing.Font("Arial", 8.7F, System.Drawing.FontStyle.Bold)
            .ChartAreas("ChartArea1").AxisY2.LabelStyle.Font = New System.Drawing.Font("Arial", 8.7F, System.Drawing.FontStyle.Bold)

        End With


    End Sub

here is my code

Do you have code that draws the chart, or are you using some kind of office interopt to draw it?

the secondary axis i want it to be fixed in the line of the primary axis in the left side

Assuming that this means that you want both axes to have the same range, then something like this will work.

  With Chart1
     ' Y1 = first Y Point, Y2 = Second Y point, etc.
     Dim ymin As Double = Math.Min(.Series(0).Points.FindMinByValue("Y1").YValues(0), _
                                   .Series(1).Points.FindMinByValue("Y1").YValues(0))

     Dim ymax As Double = Math.Max(.Series(0).Points.FindMinByValue("Y1").YValues(0), _
                                   .Series(1).Points.FindMinByValue("Y1").YValues(0))

     'round values to the nearest "Factor"
     Const Factor As Double = 5

     ymin = Math.Floor(ymin / Factor) * Factor
     ymax = Math.Ceiling(ymax / Factor) * Factor

     .ChartAreas(0).AxisY.Minimum = ymin
     .ChartAreas(0).AxisY.Maximum = ymax
     .ChartAreas(0).AxisY2.Minimum = ymin
     .ChartAreas(0).AxisY2.Maximum = ymax

  End With
commented: I'm confuse. (DERP) +8

Hi TnTinMN i use your code now they are both same in range
639634fa3157aea870766aff49e41932
but as you can see in the picture the GP is 2.4m so its means the GP is column(Blue) is higher than the Line(Red).

i used this code

    Public Sub Chart_BU_GP_vs_Target()

        With Chart_EBU_GP_vs_Target

            .Series.Clear()
            .Legends.Clear()

            .ChartAreas("ChartArea1").AxisX.MinorTickMark.Enabled = True
            .ChartAreas("ChartArea1").AxisX.Interval = 1
            .ChartAreas("ChartArea1").AxisX.IsLabelAutoFit = True
            .ChartAreas("ChartArea1").AxisX.LabelAutoFitStyle = DataVisualization.Charting.LabelAutoFitStyles.LabelsAngleStep30


            .Series.Add("Gross Profit")
            .Series("Gross Profit").ChartType = DataVisualization.Charting.SeriesChartType.Column
            .Series("Gross Profit").Points.AddXY("January", Me.BU_JanGP.Text)
            .Series("Gross Profit").Points.AddXY("February", Me.BU_FebGP.Text)
            .Series("Gross Profit").Points.AddXY("March", Me.BU_MarGP.Text)
            .Series("Gross Profit").Points.AddXY("April", Me.BU_AprGP.Text)
            .Series("Gross Profit").Points.AddXY("May", Me.BU_MayGP.Text)
            .Series("Gross Profit").Points.AddXY("June", Me.BU_JunGP.Text)
            .Series("Gross Profit").Points.AddXY("July", Me.BU_JulGP.Text)
            .Series("Gross Profit").Points.AddXY("August", Me.BU_AugGP.Text)
            .Series("Gross Profit").Points.AddXY("September", Me.BU_SepGP.Text)
            .Series("Gross Profit").Points.AddXY("October", Me.BU_OctGP.Text)
            .Series("Gross Profit").Points.AddXY("November", Me.BU_NovGP.Text)
            .Series("Gross Profit").Points.AddXY("December", Me.BU_DecGP.Text)

            .Series.Add("Target")
            .Series("Target").ChartType = DataVisualization.Charting.SeriesChartType.Line
            .Series("Target").BorderWidth = 3
            .Series("Target").YAxisType = DataVisualization.Charting.AxisType.Secondary
            .Series("Target").Points.AddXY("January", Me.BU_JanTGP.Text)
            .Series("Target").Points.AddXY("February", Me.BU_FebTGP.Text)
            .Series("Target").Points.AddXY("March", Me.BU_MarTGP.Text)
            .Series("Target").Points.AddXY("April", Me.BU_AprTGP.Text)
            .Series("Target").Points.AddXY("May", Me.BU_MayTGP.Text)
            .Series("Target").Points.AddXY("June", Me.BU_JunTGP.Text)
            .Series("Target").Points.AddXY("July", Me.BU_JulTGP.Text)
            .Series("Target").Points.AddXY("August", Me.BU_AugTGP.Text)
            .Series("Target").Points.AddXY("September", Me.BU_SepTGP.Text)
            .Series("Target").Points.AddXY("October", Me.BU_OctTGP.Text)
            .Series("Target").Points.AddXY("November", Me.BU_NovTGP.Text)
            .Series("Target").Points.AddXY("December", Me.BU_DecTGP.Text)

            .Legends.Add("Account Manager")
            .Legends("Account Manager").Docking = DataVisualization.Charting.Docking.Bottom

            .Series("Gross Profit").Color = Color.DodgerBlue
            .Series("Target").Color = Color.Red
            .Series("Gross Profit").BorderColor = Color.Black
            .Series("Target").BorderColor = Color.Black

            .ChartAreas("ChartArea1").AxisY.LabelStyle.Format = "##,#"
            .ChartAreas("ChartArea1").AxisY2.LabelStyle.Format = "##,#"
            .ChartAreas("ChartArea1").AxisY.LabelStyle.Font = New System.Drawing.Font("Arial", 8.7F, System.Drawing.FontStyle.Bold)
            .ChartAreas("ChartArea1").AxisY2.LabelStyle.Font = New System.Drawing.Font("Arial", 8.7F, System.Drawing.FontStyle.Bold)

            'Y1 = first Y Point, Y2 = Second Y point, etc.
            Dim ymin As Double = Math.Min(.Series("Gross Profit").Points.FindMinByValue("Y1").YValues(0), .Series("Target").Points.FindMinByValue("Y1").YValues(0))
            Dim ymax As Double = Math.Max(.Series("Gross Profit").Points.FindMinByValue("Y1").YValues(0), .Series("Target").Points.FindMinByValue("Y1").YValues(0))

            'round values to the nearest "Factor"
            Const Factor As Double = 5
            ymin = Math.Floor(ymin / Factor) * Factor
            ymax = Math.Ceiling(ymax / Factor) * Factor
            .ChartAreas("ChartArea1").AxisY.Minimum = ymin
            .ChartAreas("ChartArea1").AxisY.Maximum = ymax
            .ChartAreas("ChartArea1").AxisY2.Minimum = ymin
            .ChartAreas("ChartArea1").AxisY2.Maximum = ymax


        End With

Probably due to me giving an example that I did not check properly. :(

ymax should be using FindMaxByMalue not FindMinByValue.

 Dim ymax As Double = Math.Max(.Series(0).Points.FindMaxByValue("Y1").YValues(0), _
                               .Series(1).Points.FindMaxByValue("Y1").YValues(0))

Yes it is working now. :)
but one more question how can i make it something like 30,000,000 not like 29,482,410?
7b8d5766238f470d8ed52cfcde5cda50

but one more question how can i make it something like 30,000,000 not like 29,482,410?

Change the rounding factor: Const Factor As Double = 5
If you want to round to the nearest 10,000,000, use that as the factor.

Also if your range always starts at zero, just set the Y axis minimum to zero as there is no need to compute a minimum value.

Please take the time to try and understand how to code works instead of just inserting it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.