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/markzone
This example is the version from Sun, 17th Mar 2012.
Project "markzone.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 chart
dim data(-1) as double = array(40, 45, 37, 24, 32, 39, 53, 52, 63, 49, 46, 40, 54, 50, 57, 57, 48, 49, 63, 67, 74, 72, 70, 89, 74.0)
dim labels(-1) as string = array("0"+endofline.unix+"Jun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0"+endofline.unix+"Jun 5")
// Create a XYChart object of size 400 x 270 pixels
dim c as new CDXYChartMBS(400, 270)
// Set the plotarea at (80, 60) and of size 300 x 200 pixels. Turn off the grid
// lines by setting their colors to Transparent.
c.setPlotArea(80, 28, 300, 200).setGridColor(CDXYChartMBS.kTransparent)
// Add a title to the y axis
dim TextBox as CDTextBoxMBS
textbox = c.yAxis.setTitle("Temperature")
// Set the y axis title upright (font angle = 0)
textbox.setFontAngle(0)
// Put the y axis title on top of the axis
textbox.setAlignment(CDXYChartMBS.kTopLeft2)
// Add green (&h99ff99), yellow (&hffff99) and red (&hff9999) zones to the y axis
// to represent the ranges 0 - 50, 50 - 80, and 80 - max.
c.yAxis.addZone(0, 50, &h99ff99)
c.yAxis.addZone(50, 80, &hffff99)
c.yAxis.addZone(80, 9999, &hff9999)
// Add a purple (&h800080) mark at y = 70 using a line width of 2.
c.yAxis.addMark(70, &h800080, "Alert = 70").setLineWidth(2)
// Add a green (&h008000) mark at y = 40 using a line width of 2.
c.yAxis.addMark(40, &h008000, "Watch = 40").setLineWidth(2)
// Add a legend box at (165, 0) (top right of the chart) using 8 pts Arial font.
// and horizontal layout.
dim legend as CDLegendBoxMBS
legend = c.addLegend(165, 0, false, "arialbd.ttf", 8)
// Disable the legend box boundary by setting the colors to Transparent
legend.setBackground(CDXYChartMBS.kTransparent, CDXYChartMBS.kTransparent)
// Add 3 custom entries to the legend box to represent the 3 zones
legend.addKey("Normal", &h80ff80)
legend.addKey("Warning", &hffff80)
legend.addKey("Critical", &hff8080)
// Set the labels on the x axis.
call c.xAxis.setLabels(labels)
// Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining
// labels.
c.xAxis.setLabelStep(3, 1)
// Add a 3D bar layer with the given data
dim layer as CDBarLayerMBS
layer = c.addBarLayer(data, &hbbbbff)
// Set the bar gap to 0 so that the bars are packed tightly
layer.setBarGap(0)
// Set the border color of the bars same as the fill color, with 1 pixel 3D
// border effect.
layer.setBorderColor(CDXYChartMBS.kSameAsMainColor, 1)
// 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
The items on this page are in the following plugins: MBS ChartDirector Plugin.