ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Getting labels from db columns
Posted by Steve Sackman on Aug-22-2012 00:26
For some reason, I am unable to show the labels in the chart when getting them directly from db column.  Here is my code snippet:

Dim sql As String = "Select JobName,StartDate,EndDate From [dbo].[Job_tblRunTimes] Order By StartDate"

            ' Read the data into the DBTable object
            Dim sqlCmd As SqlCommand = sqlConn.CreateCommand()
            sqlCmd.CommandText = Sql

            Dim table As DBTable = New DBTable(sqlCmd.ExecuteReader())

            ' Get the data as arrays
            Dim labels() As String = table.getColAsString(0)
            Dim startDate() As DateTime = table.getColAsDateTime(1)
            Dim endDate() As DateTime = table.getColAsDateTime(2)

            ...

            ' Set the labels on the x axis
            c.xAxis().setLabels(labels)


The code is charting the startDate and endDate correctly, but I am not seeing the label values in the chart itself.  There is plenty of room to display the labels because when I manually create the label array ({"Job1","Job2", etc.})  they do show up in the chart correctly.  They don't appear when taking from db column.  Any suggestions?

I am using the "Simple Gantt Chart" VB.NET example in the help file as reference.

Thanks,
Steve

  Re: Getting labels from db columns
Posted by Peter Kwan on Aug-22-2012 01:39
Hi Steve,

One possibility is that your labels are very very long and contain a lot of empty space. For example, if your label is "Job1_____________________________________" (note: the underscore _ refers to the space character), the the labels may not appear on the chart, as they may be insufficient room in the chart to display the very very long label.

If the above is the cause of the problem, you may use SELECT RTRIM(JobName) ... instead of SELECT JobName to solve the problem.

Hope this can help.

Regards
Peter Kwan

  Re: Getting labels from db columns
Posted by Steve Sackman on Aug-22-2012 01:47
Hi Peter,

Excellent.  That worked.   Thanks for the tip, and thanks for the quick response.


Steve