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

/ChartDirector/posnegbar
Function:
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/posnegbar
This example is the version from Sun, 17th Mar 2012.
Project "posnegbar.rbp"
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 data(-1) as double = array( -6.3, 2.3, 0.7, -3.4, 2.2, -2.9, -0.1, -0.1, 3.3, 6.2, 4.3, 1.6) // The labels for the bar chart dim labels(-1) as string = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") // Create a XYChart object of size 500 x 320 pixels dim c as new CDXYChartMBS(500, 320) // Add a title to the chart using Arial Bold Italic font call c.addTitle("Productivity Change - Year 2005", "arialbi.ttf") // Set the plotarea at (50, 30) and of size 400 x 250 pixels call c.setPlotArea(50, 30, 400, 250) // Add a bar layer to the chart using the Overlay data combine method dim layer as CDBarLayerMBS layer = c.addBarLayer(c.kOverlay) // Select positive data and add it as data set with blue (6666ff) color dim d(-1) as Double dim i,count as integer count=UBound(data) for i=0 to count if data(i)>=0 then d.append data(i) else d.append c.knoValue end if next call layer.addDataSet(d, &h6666ff) redim d(-1) count=UBound(data) for i=0 to count if data(i)<0 then d.append data(i) else d.append c.knoValue end if next // Select negative data and add it as data set with orange (ff6600) color call layer.addDataSet(d, &hff6600) // Add labels to the top of the bar using 8 pt Arial Bold font. The font color is // configured to be red (0xcc3300) below zero, and blue (0x3333ff) above zero. call layer.setAggregateLabelStyle("arialbd.ttf", 8, layer.yZoneColor(0, &hcc3300, &h3333ff)) // Set the labels on the x axis and use Arial Bold as the label font dim t as CDTextBoxMBS t=c.xAxis.setLabels(labels) t.setFontStyle("arialbd.ttf") // Draw the y axis on the right of the plot area c.setYAxisOnRight(true) // 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("Percentage") // Add a light blue (0xccccff) zone for positive part of the plot area call c.yAxis.addZone(0, 9999, &hccccff) // Add a pink (0xffffcc) zone for negative part of the plot area call c.yAxis.addZone(-9999, 0, &hffcccc) 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

See also:

Feedback, Comments & Corrections

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




Links
MBS FileMaker blog