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

Message ListMessage List     Post MessagePost Message

  Gantt Chart with table
Posted by Jamie Pocock on Sep-03-2022 05:15
Attachments:
Help, I have been at this for 14 hours now and cannot get it to work.

I have a Gantt chart and trying to align a table with it.

        Dim layer As BoxWhiskerLayer
        Dim lBarHeight As Long
        Dim table As CDMLTable
        Dim table2 As CDMLTable
        Dim TxtBox As ChartDirector.TextBox

        Let lBarHeight = 52
        Set layer = C.addBoxWhiskerLayer2(startdate, enddate, Empty, Empty, Empty, Colors, 0.5, grdSchdlRow)
        Call layer.setBorderColor(cd.SameAsMainColor)
        Call layer.setDataWidth(lBarHeight)
        Call layer.addExtraField(LabelsToolTip)
        Call layer.setDataLabelFormat("{field0}")
        Call layer.addExtraField(grdSchdlRow)

        '-----------------------------------------
        ' Sets labels on left axis
        Set table = C.xAxis().makeLabelTable()
        Call table.getStyle().setMargin2(32, 32, 0, 0)
        For I1 = 0 To iCnt
            Call table.getRowStyle(I1).setFontStyle("arialbd.ttf")
            Call table.getRowStyle(I1).setBackground(Colors(I1), &HC0C0C0, 0)
            Call table.getRowStyle(I1).setFontSize(iFontSize)
        Next I1

        Call C.yAxis().setLabels(labelTime) ' Calling this stops the Gantt bars from showing but you can then see the data in the table as in the top part of the screen capture.

        Set table2 = C.yAxis().makeLabelTable()
        Dim cellStyle As ChartDirector.TextBox
        Set cellStyle = table2.getStyle()
        Call cellStyle.setMargin2(32, 32, 5, 5)
        Call cellStyle.setFontSize(10)

        Dim firstRowStyle As ChartDirector.TextBox
        Set firstRowStyle = table2.getRowStyle(0)
        Call firstRowStyle.setFontStyle("arialbd.ttf")
        Call firstRowStyle.setFontSize(12, 12)
        Call firstRowStyle.setBackground(&HCCCCCC, cd.LineColor)
        Call firstRowStyle.setFontColor(&H44)

        Call table2.appendRow ' Time
        Call table2.appendRow ' Sales
        Call table2.appendRow ' Orders
        Call table2.appendRow ' Delivery
        Call table2.appendRow ' Products
        Call table2.appendRow ' InstoreHours
        Call table2.appendRow ' DriverHours
        Call table2.appendRow ' OptimalHours
        Call table2.appendRow ' Instore
        Call table2.appendRow ' Drivers
        Call table2.appendRow ' Hours
        Call table2.appendRow ' Totals
Capturejp.png

  Re: Gantt Chart with table
Posted by Peter Kwan on Sep-05-2022 18:15
Hi Jamie,

In the chart that shows the bars (the bottom chart), I did not find the line that configures the y-axis scale (eg. a line that calls Axis.setDateScale), but I think the axis is likely to be a date/time axis with the axis range matching the data used for the bars.

When you call Axis.setLabels, it sets the axis to a label based axis. The labels are just names to ChartDirector and have no meaning to ChartDirector. In this case, the y-axis scale will be set to an enumerated scale start from 0. So the first label is at y = 0, the second label is at y = 1 and so on. This scale does not match your bars, so the bars are not visible.

The easiest way to solve the problem is to use another axis for the label table.

' Add another axis to the top for the table
Dim labelAxis As Axis = c.addAxis(Chart.Top, 0)
labelAxis.setLabels(....)
Dim t As CDMLTable = labelTable.makeLabelTable()
t.appendRow()
t.appendRow()
......

' This is the axis actually used to plot the bars. We hide it so that it does not
' overlap with the label axis.
c.yAxis().setColors(Chart.Transparent, Chart.Transparent)


Best Regards
Peter Kwan