Member Avatar for mrkm1188
mrkm1188

I have a chart that is being populated from a query in the vb code but when the chart is displayed there is an extra x-axis grid tick. How do i get the x-axis grid to only display the number of items being returned?

**VB code: **

Public Function CLGenerateRevenueHistoryChart()

        'call method to populate client infromation/client contact information
        Dim clientCode As String = CLClientCodeTextBox.Text 'client code entered in the text box
        Dim clientRevenue As Double = 0 'the revenue for the client each year
        Dim yearsArray(6) As String 'array of years (2015,2014,2014,....,2010)
        Dim revenueArray(6) As Double 'array of revenue values per year

        Dim i As Integer = 0
        While (i <= 5)
            Dim nextYear As String = Date.Today.AddYears(-i).Year 'determine the year
            yearsArray(i) = nextYear
            i = i + 1
        End While

        Dim token As IntPtr = IntPtr.Zero
        Dim loggedOn As Boolean = False
        If (LogonUserA("******", 9, 0, token) <> 0) Then
            loggedOn = True
        End If
        If (loggedOn) Then
            Dim newIdentity As WindowsIdentity = New WindowsIdentity(token)
            Using impersonatedUser As WindowsImpersonationContext = newIdentity.Impersonate()
                Using conn As New OleDbConnection("Provider=SQLOLEDB;Data Source=SQL1;Initial Catalog=ReptDB;User ID = *******;Integrated Security=SSPI")
                    conn.Open()

                    Dim index As Integer = 0

                    While (index < 6)
                        Dim fiscalYear As String = yearsArray(index)

                        Dim revenueQuery As String = "SELECT prj_bdgt_summary.prj_code, prj_bdgt_summary.fiscal_year, prj_bdgt_summary.rev_cc, prj_bdgt_summary.rev_pc " &
                                                       "FROM prj_bdgt_summary INNER JOIN prj_processing ON prj_bdgt_summary.prj_code = prj_processing.prj_code " &
                                                       "WHERE (prj_processing.prj_status_ind IN('A','I')) AND (prj_bdgt_summary.prj_code LIKE '" & clientCode & "%') AND (prj_bdgt_summary.fiscal_year = '" & fiscalYear & "')"

                        Dim revenueDA As OleDbDataAdapter = New OleDbDataAdapter(revenueQuery, conn)
                        Dim revenueDS As DataSet = New DataSet()
                        revenueDA.Fill(revenueDS)
                        Dim revenueDT As DataTable = revenueDS.Tables(0)

                        Dim currentRow As Integer = 0

                        'calculate the revenue for the year
                        While (currentRow < revenueDT.Rows.Count)
                            clientRevenue = clientRevenue + revenueDT.Rows(currentRow).Item("rev_cc")
                            currentRow = currentRow + 1
                        End While

                        revenueArray(index) = Math.Round(clientRevenue, 2)
                        clientRevenue = 0
                        index = index + 1
                    End While

                    conn.Close()
                End Using
            End Using
        End If

        CLRevenueHistoryChart.Titles.Add("REVENUE HISTORY") 'chart title
        CLRevenueHistoryChart.Titles(0).Font = New System.Drawing.Font("Ariel", 12, Drawing.FontStyle.Bold, CLRevenueHistoryChart.Titles(0).Font.Unit)
        CLRevenueHistoryChart.ChartAreas("ChartArea1").AxisX.Title = "Year" 'x axis label
        CLRevenueHistoryChart.ChartAreas("ChartArea1").AxisY.Title = "Revenue" 'y axis label
        CLRevenueHistoryChart.ChartAreas("ChartArea1").AxisX.MajorGrid.LineWidth = 0 'hides the vertical grid lines
        CLRevenueHistoryChart.ChartAreas("ChartArea1").AxisX.MajorTickMark.Enabled = True
        CLProposalHistoryPieChart.ChartAreas("ChartArea1").AxisX.Interval = 1
        CLRevenueHistoryChart.ChartAreas("ChartArea1").AxisY.LabelStyle.Format = "$###,###,###,###" 'formats the y axis intervals in $100,000 format
        CLRevenueHistoryChart.Series("Series1").Points.DataBindXY(yearsArray, revenueArray) 'binds the data to the cahrt

The graph should display x-axis tick marks 2015, 2014, 2013, 2013, 2011, and 2010 but it is adding a '7' as the alst x-axis tick mark. I want to only display the tick marks up to 2010