MS Chart is adding extra X axis when doing multiple series.
-
Ms Chart is a pain in the behind, first I had an issue where when binding or manually adding dates to my X axis it would force add every single date in between even though that data didn't exist, my SQL code is setup with a date dimension table which makes it so I only return exactly the number of rows I want (4 weeks 4 values, 5 months, 5 values) "Fixed" that by instead adding generic counter for X axis and then setting the label to the date, or so I thought... [Now that I've added code to do multiple series the damn thing is adding extra items to the X axis again] [The dates in each series are exactly the same.] My counter gets reset to 0 before every series and when I loop through the code to see the data points in debug the labels and data are set properly for every series. but ms chart still decides it needs 12 billion extra lines on the X axis for no goddamn explainable reason.
Private Sub LoadChart()
Dim oDT As New DataTable Dim sqlCmd As New SqlCommand Dim sSQLDateCTE As String = "WITH Date\_CTE as ( " & \_ "SELECT {0} DDim.\[Date\] as SaleDate " & \_ "FROM \[DateDimension\] as DDim {1} " Dim sWHEREDateCTE As String = "WHERE \[Date\] BETWEEN DATEADD({0},-{1},GETDATE()) AND GETDATE() {2} " Dim sSQLSUM As String = "), SUM\_CTE as ( " & \_ "SELECT {0}" & \_ "FROM {1} " & \_ "WHERE F1034 = 3 AND F64 <> 0 AND F01 = @UPCCode " & \_ "AND F254 IN (SELECT saledate FROM Date\_CTE) " & \_ "GROUP BY {2}) " Dim sSQLFinalPart = "SELECT {0} DC.SaleDate ,ISNULL(SC.UnitsSold,0) as UnitsSold " & \_ "FROM Date\_CTE as DC " & \_ "LEFT OUTER JOIN SUM\_CTE as SC " & \_ "ON SC.SaleDate = DC.SaleDate {1}" & \_ "ORDER BY DC.SaleDate ASC " Dim sFieldList As String = "" Dim sGroupBy As String = "" Dim sStorelist As String = "" Dim sWhereIN As String = "" Dim sWhereINDateCTE As String = "" Dim sSQL As String = "" Try If oAppEnv.sSource = "H" Then For Each CheckedItem In clbStores.CheckedItems If sStorelist <> "" Then sStorelist = sStorelist & ", " End If