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. Visual Basic
  4. MS Chart is adding extra X axis when doing multiple series.

MS Chart is adding extra X axis when doing multiple series.

Scheduled Pinned Locked Moved Visual Basic
databasewpfwcfcomdebugging
1 Posts 1 Posters 1 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.
  • M Offline
    M Offline
    Member_14359260
    wrote on last edited by
    #1

    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
    
    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