Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

Required plugins for this example: MBS ChartDirector Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /ChartDirector/waterfall
This example is the version from Sun, 17th Mar 2012.
Project "waterfall.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class PicWindow Inherits Window
EventHandler Sub Open() // 4 data points to represent the cash flow for the Q1 - Q4 dim data(-1) as double = array(230, 140, 220, 330, 150.0) // We want to plot a waterfall chart showing the 4 quarters as well as the total dim labels(-1) as string = array("Product 1", "Product 2", "Product 3", "Product 4", "Product 5", "Total") // The top side of the bars in a waterfall chart is the accumulated data. We use // the ChartDirector ArrayMath utility to accumulate the data. The "total" is // handled by inserting a zero point at the end before accumulation (after // accumulation it will become the total). dim boxTop as new CDArrayMBS(data) boxTop.insert(0, 1) boxTop.acc // The botom side of the bars is just the top side of the previous bar. So we // shifted the top side data to obtain the bottom side data. dim boxBottom as new CDArrayMBS(boxTop) boxBottom.shift(1, 0) // The last point (total) is different. Its bottom side is always 0. boxBottom.trim(0, 5) boxBottom.insert(0, 1) // Create a XYChart object of size 500 x 280 pixels. Set background color to // light blue (ccccff), with 1 pixel 3D border effect. dim c as new CDXYChartMBS(500, 290, &hccccff, &h000000, 1) // Add a title to the chart using 13 points Arial Bold Itatic font, with white // (ffffff) text on a deep blue (&h80) background c.addTitle("Product Revenue - Year 2004", "arialbi.ttf", 13, &hffffff).setBackground(&h000080) // Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative // white/grey background. call c.setPlotArea(55, 45, 430, 215, &hffffff, &heeeeee) // Set the labels on the x axis using Arial Bold font c.xAxis.setLabels(labels).setFontStyle("arialbd.ttf") // Set the x-axis ticks and grid lines to be between the bars c.xAxis.setTickOffset(0.5) // Use Arial Bold as the y axis label font call c.yAxis.setLabelStyle("arialbd.ttf") // Add a title to the y axis call c.yAxis.setTitle("USD (in millions)") dim bTop(-1) as Double dim bBottom(-1) as Double dim i,count as integer count=boxtop.count-1 for i=0 to count btop.append boxtop.getvalue(i) next count=boxbottom.count-1 for i=0 to count bbottom.append boxbottom.getvalue(i) next // Add a multi-color box-whisker layer to represent the waterfall bars dim layer as CDBoxWhiskerLayerMBS layer = c.addBoxWhiskerLayer2(bTop, bBottom) // Put data labels on the bars to show the cash flow using Arial Bold font layer.setDataLabelFormat("{={top}-{bottom}}M") layer.setDataLabelStyle("arialbd.ttf").setAlignment(c.kCenter) // Output the chart Backdrop=c.makeChartPicture End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS ChartDirector Plugin.

MBS Xojo blog