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/multistackbar
This example is the version from Sun, 17th Mar 2012.
Project "multistackbar.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class PicWindow Inherits Window
EventHandler Sub Open() // The data for the bar chart dim data0(-1) as double = array( 44, 55, 100.0) dim data1(-1) as double = array( 97, 87, 167.0) dim data2(-1) as double = array( 156, 78, 147.0) dim data3(-1) as double = array( 125, 118, 211.0) // The labels for the bar chart. The labels contains embedded images as icons. dim labels(-1) as string = array("<*img=service.png*><*br*>Service","<*img=software.png*><*br*>Software", "<*img=computer.png*><*br*>Hardware") // Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the // background color, 0xccccff as the border color, with 1 pixel 3D border effect. dim c as new CDXYChartMBS(600, 350, &he0e0ff, &hccccff, 1) // Add a title to the chart using 14 points Times Bold Itatic font and light blue // (0x9999ff) as the background color dim t as new CDTextBoxMBS t=c.addTitle("Business Results 2001 vs 2002", "timesbi.ttf", 14) t.setBackground(&h9999ff) // Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white // (0xffffff) as the background call c.setPlotArea(60, 45, 500, 210, &hffffff) // Swap the x and y axes to create a horizontal bar chart c.swapXY // Add a title to the y axis using 11 pt Times Bold Italic as font call c.yAxis.setTitle("Revenue (millions)", "timesbi.ttf", 11) // Set the labels on the x axis call c.xAxis.setLabels labels // Disable x-axis ticks by setting the tick length to 0 call c.yAxis.setTickLength(0) // Add a stacked bar layer to the chart dim layer as CDBarLayerMBS layer = c.addBarLayer(c.kStack) // Add the first two data sets to the chart as a stacked bar group call layer.addDataGroup("2001") call layer.addDataSet(data0, &haaaaff,"Local") call layer.addDataSet(data1, &h6666ff,"International") // Add the remaining data sets to the chart as another stacked bar group call layer.addDataGroup("2002") call layer.addDataSet(data2, &hffaaaa, "Local") call layer.addDataSet(data3, &hff6666, "International") // Set the sub-bar gap to 0, so there is no gap between stacked bars with a group layer.setBarGap(0.2, 0) // Set the bar border to transparent layer.setBorderColor(c.kTransparent) // Set the aggregate label format layer.setAggregateLabelFormat("Year {dataGroupName}"+EndOfLine.UNIX+"{value} millions") // Set the aggregate label font to 8 point Arial Bold Italic call layer.setAggregateLabelStyle("arialbi.ttf", 8) // Reverse 20% space at the right during auto-scaling to allow space for the // aggregate bar labels c.yAxis.setAutoScale(0.2) // Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid // layout, and use 8 pts Arial Bold Italic as font dim legendBox as CDLegendBoxMBS legendBox = c.addLegend(310, 300, 2, "arialbi.ttf", 8) legendBox.setAlignment(c.kTopCenter) // Set the format of the text displayed in the legend box legendBox.setText("Year {dataGroupName} {dataSetName} Revenue") // Set the background and border of the legend box to transparent legendBox.setBackground(c.kTransparent, c.kTransparent) // 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.

The biggest plugin in space...

MBS FileMaker blog

Start Chat