Gantt chart in PowerBuilder http://illudium.com/media/gantt.png
You can create a simple Gantt chart with a line-by-line graph (BarStacked (5) in the artist). The trick is to create a dummy series, to align the panel where you want it, and make the dummy panel the same color as the background of the chart (BackColor). Turns out you also need another dummy series with a small value to sit on the axis. Otherwise, when you change the color of the strip that spans, the centerline is turned off. I found that .04 works well for this value.
Create a DataWindow
(This assumes you are familiar with the DataWindow wizard. For more information about creating graphs in DataWindows, see the PowerBuilder User Guide)
Click the Create New Object wizard icon. Create a Graph DataWindow with an external data source. Create a row of type column (20), a row of type ser (1), and a type number of days. Set the category to the task column and the values ββto the day column. Press the βSeriesβ button and select ser for the series. Do not worry about the name and select the type of graph Stacked Bar. When the artist opens, save the DataWindow. On the General tab in the Artist, change Legend to None (0). On the Axis tab, select the Category axis, then set the sort value to Unsorted (0). Select the Value axis, then set the sort to Unsorted (0). Select the Series axis and sort in ascending order (1). Save the DataWindow window.
Create window
Create a window and place the DataWindow control, dw_1. Set the data object to the DataWindow graph. Put the following in an open event (or pfc_postopen when using PFC).
try dw_1.setRedraw(FALSE) // LOAD DATA HERE dw_1.object.gr_1.title = 'Project PBL Pusher' dw_1.object.gr_1.category.label = 'Phase' dw_1.object.gr_1.values.label = 'Project-Days' catch (runtimeerror re) if isvalid(gnv_app.inv_debug) then gnv_app.inv_debug.of_message(re.text) // could do better finally dw_1.setRedraw(TRUE) end try
You upload the data for your chart, where the comment says // LOAD DATA HERE
Script Event Graphic Event
Add a new event to dw_1. Select pbm_dwngraphcreate for the event id. I like to call these events by removing the pbm_dwn prefix, so I use the graphcreate function. Add the following code to the event.
string ls_series long li_color try li_color=long(dw_1.object.gr_1.backcolor) // note first series is a dummy with a small value (0.04 seems to work) to keep the line from being hidden ls_series = dw_1.seriesName("gr_1", 2) if 0 = len(ls_series) then return // maybe show error message // will return -1 when you set color same as the graph backcolor but it sets the color dw_1.setSeriesStyle("gr_1", ls_series, BackGround!, li_color) // the box dw_1.setSeriesStyle("gr_1", ls_series, ForeGround!, li_color) // the inside catch (runtimeerror re) if isvalid(gnv_app.inv_debug) then gnv_app.inv_debug.of_message(re.text) // could do better end try
Chart Data
Download the category data in the reverse order of what you want. For each task, insert 3 lines and set the series to a, b, and c, respectively. For rows a in each task, set a small value. I used 0.04. You may need to experiment. For series b in each task, set the number of days before starting. For series c, specify the number of days. Below is the data in the DataWindow sample.
Task Ser Days
DataWindow example
Below is the source of the DataWindow selection in export format. You should be able to import into any version> = PB 10. Copy the code and paste it into a file with the .rdd extension, and then import it.
HA$PBExportHeader$d_graph.srd release 10; datawindow(units=0 timer_interval=0 color=1073741824 processing=3 HTMLDW=no print.printername="" print.documentname="" print.orientation = 1 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no ) summary(height=0 color="536870912" ) footer(height=0 color="536870912" ) detail(height=0 color="536870912" ) table(column=(type=char(10) updatewhereclause=yes name=task dbname="task" ) column=(type=char(1) updatewhereclause=yes name=ser dbname="ser" ) column=(type=number updatewhereclause=yes name=days dbname="days" ) ) data("Test","a", 0.04,"Test","b", 24,"Test","c", 10,"Develop","a", 0.04,"Develop","b", 10,"Develop","c", 14,"Design","a", 0.04,"Design","b", 0,"Design","c", 10,) graph(band=background height="1232" width="2798" graphtype="5" perspective="2" rotation="-20" color="0" backcolor="16777215" shadecolor="8355711" range= 0 border="3" overlappercent="0" spacing="100" plotnulldata="0" elevation="20" depth="100"x="0" y="0" height="1232" width="2798" name=gr_1 visible="1" sizetodisplay=1 series="ser" category="task" values="days" title="Title" title.dispattr.backcolor="553648127" title.dispattr.alignment="2" title.dispattr.autosize="1" title.dispattr.font.charset="0" title.dispattr.font.escapement="0" title.dispattr.font.face="Tahoma" title.dispattr.font.family="2" title.dispattr.font.height="0" title.dispattr.font.italic="0" title.dispattr.font.orientation="0" title.dispattr.font.pitch="2" title.dispattr.font.strikethrough="0" title.dispattr.font.underline="0" title.dispattr.font.weight="700" title.dispattr.format="[general]" title.dispattr.textcolor="0" title.dispattr.displayexpression="title" legend="0" legend.dispattr.backcolor="536870912" legend.dispattr.alignment="0" legend.dispattr.autosize="1" legend.dispattr.font.charset="0" legend.dispattr.font.escapement="0" legend.dispattr.font.face="Tahoma" legend.dispattr.font.family="2" legend.dispattr.font.height="0" legend.dispattr.font.italic="0" legend.dispattr.font.orientation="0" legend.dispattr.font.pitch="2" legend.dispattr.font.strikethrough="0" legend.dispattr.font.underline="0" legend.dispattr.font.weight="400" legend.dispattr.format="[general]" legend.dispattr.textcolor="553648127" legend.dispattr.displayexpression="' '" series.autoscale="1" series.displayeverynlabels="0" series.droplines="0" series.frame="1" series.label="(None)" series.majordivisions="0" series.majorgridline="0" series.majortic="3" series.maximumvalue="0" series.minimumvalue="0" series.minordivisions="0" series.minorgridline="0" series.minortic="1" series.originline="1" series.primaryline="1" series.roundto="0" series.roundtounit="0" series.scaletype="1" series.scalevalue="1" series.secondaryline="0" series.shadebackedge="0" series.dispattr.backcolor="536870912" series.dispattr.alignment="0" series.dispattr.autosize="1" series.dispattr.font.charset="0" series.dispattr.font.escapement="0" series.dispattr.font.face="Tahoma" series.dispattr.font.family="2" series.dispattr.font.height="0" series.dispattr.font.italic="0" series.dispattr.font.orientation="0" series.dispattr.font.pitch="2" series.dispattr.font.strikethrough="0" series.dispattr.font.underline="0" series.dispattr.font.weight="400" series.dispattr.format="[general]" series.dispattr.textcolor="0" series.dispattr.displayexpression="series" series.labeldispattr.backcolor="553648127" series.labeldispattr.alignment="2" series.labeldispattr.autosize="1" series.labeldispattr.font.charset="0" series.labeldispattr.font.escapement="0" series.labeldispattr.font.face="Tahoma" series.labeldispattr.font.family="2" series.labeldispattr.font.height="0" series.labeldispattr.font.italic="0" series.labeldispattr.font.orientation="0" series.labeldispattr.font.pitch="2" series.labeldispattr.font.strikethrough="0" series.labeldispattr.font.underline="0" series.labeldispattr.font.weight="400" series.labeldispattr.format="[general]" series.labeldispattr.textcolor="0" series.labeldispattr.displayexpression=" seriesaxislabel" series.sort="1" category.autoscale="1" category.displayeverynlabels="0" category.droplines="0" category.frame="1" category.label="(None)" category.majordivisions="0" category.majorgridline="0" category.majortic="3" category.maximumvalue="0" category.minimumvalue="0" category.minordivisions="0" category.minorgridline="0" category.minortic="1" category.originline="0" category.primaryline="1" category.roundto="0" category.roundtounit="0" category.scaletype="1" category.scalevalue="1" category.secondaryline="0" category.shadebackedge="1" category.dispattr.backcolor="556870912" category.dispattr.alignment="1" category.dispattr.autosize="1" category.dispattr.font.charset="0" category.dispattr.font.escapement="0" category.dispattr.font.face="Tahoma" category.dispattr.font.family="2" category.dispattr.font.height="0" category.dispattr.font.italic="0" category.dispattr.font.orientation="0" category.dispattr.font.pitch="2" category.dispattr.font.strikethrough="0" category.dispattr.font.underline="0" category.dispattr.font.weight="400" category.dispattr.format="[general]" category.dispattr.textcolor="0" category.dispattr.displayexpression="category" category.labeldispattr.backcolor="556870912" category.labeldispattr.alignment="2" category.labeldispattr.autosize="1" category.labeldispattr.font.charset="0" category.labeldispattr.font.escapement="900" category.labeldispattr.font.face="Tahoma" category.labeldispattr.font.family="2" category.labeldispattr.font.height="0" category.labeldispattr.font.italic="0" category.labeldispattr.font.orientation="900" category.labeldispattr.font.pitch="2" category.labeldispattr.font.strikethrough="0" category.labeldispattr.font.underline="0" category.labeldispattr.font.weight="400" category.labeldispattr.format="[general]" category.labeldispattr.textcolor="0" category.labeldispattr.displayexpression="categoryaxislabel" category.sort="0" values.autoscale="1" values.displayeverynlabels="0" values.droplines="0" values.frame="1" values.label="(None)" values.majordivisions="0" values.majorgridline="0" values.majortic="3" values.maximumvalue="1500" values.minimumvalue="0" values.minordivisions="0" values.minorgridline="0" values.minortic="1" values.originline="1" values.primaryline="1" values.roundto="0" values.roundtounit="0" values.scaletype="1" values.scalevalue="1" values.secondaryline="0" values.shadebackedge="0" values.dispattr.backcolor="556870912" values.dispattr.alignment="2" values.dispattr.autosize="1" values.dispattr.font.charset="0" values.dispattr.font.escapement="0" values.dispattr.font.face="Tahoma" values.dispattr.font.family="2" values.dispattr.font.height="0" values.dispattr.font.italic="0" values.dispattr.font.orientation="0" values.dispattr.font.pitch="2" values.dispattr.font.strikethrough="0" values.dispattr.font.underline="0" values.dispattr.font.weight="400" values.dispattr.format="[General]" values.dispattr.textcolor="0" values.dispattr.displayexpression="value" values.labeldispattr.backcolor="553648127" values.labeldispattr.alignment="2" values.labeldispattr.autosize="1" values.labeldispattr.font.charset="0" values.labeldispattr.font.escapement="0" values.labeldispattr.font.face="Tahoma" values.labeldispattr.font.family="2" values.labeldispattr.font.height="0" values.labeldispattr.font.italic="0" values.labeldispattr.font.orientation="0" values.labeldispattr.font.pitch="2" values.labeldispattr.font.strikethrough="0" values.labeldispattr.font.underline="0" values.labeldispattr.font.weight="700" values.labeldispattr.format="[general]" values.labeldispattr.textcolor="0" values.labeldispattr.displayexpression="valuesaxislabel" ) htmltable(border="1" ) htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" ) xhtmlgen() cssgen(sessionspecific="0" ) xmlgen(inline="0" ) xsltgen() jsgen() export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 ) import.xml() export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" ) export.xhtml()