Platforms to show: All Mac Windows Linux Cross-Platform

/ChartDirector/yzonecolor


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/yzonecolor

This example is the version from Thu, 6th Apr 2016.

Project "yzonecolor.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() // The data for the chart dim data(-1) as double = array(30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62.0) // The labels for the chart dim labels(-1) as string = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24") // Create a XYChart object of size 500 x 300 pixels, with a pale yellow // (&hffffc0) background, a black border, and 1 pixel 3D border effect dim c as new CDXYChartMBS(500, 330, &hffffc0, &h000000, 1) // Set the plotarea at (55, 50) and of size 420 x 205 pixels, with white // background. Turn on both horizontal and vertical grid lines with light grey // color (&hc0c0c0) c.setPlotArea(55, 50, 420, 205, &hffffff).setGridColor(&hc0c0c0, &hc0c0c0) // Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 8 // pts Arial font. Set the background and border color to Transparent. dim legendBox as CDLegendBoxMBS legendBox = c.addLegend(55, 25, false, "", 8) legendBox.setBackground(CDXYChartMBS.kTransparent) // Add keys to the legend box to explain the color zones legendBox.addKey("Normal Zone", &h8033FF33) legendBox.addKey("Alert Zone", &h80FF3333) // Add a title box to the chart using 13 pts Arial Bold Italic font. The title is // in CDML and includes embedded images for highlight. The text is white // (&hffffff) on a black background, with a 1 pixel 3D border. dim path as string path=c.GetPath(FindFile("star.png")) c.addTitle("<*block,valign=absmiddle*><*img="+path+"*><*img="+path+"*> Y Zone Color Demo <*img="+path+"*><*img="+path+"*><*/*>", "arialbi.ttf", 13, &hffffff).setBackground(&h000000, -1, 1) // Add a title to the y axis call c.yAxis.setTitle("Energy Concentration (KJ per liter)") // Set the labels on the x axis. call c.xAxis.setLabels(labels) // Display 1 out of 3 labels on the x-axis. c.xAxis.setLabelStep(3) // Add a title to the x axis using CDML call c.xAxis.setTitle("<*block,valign=absmiddle*><*img="+c.GetPath(FindFile("clock.png"))+"*> Elapsed Time (hour)<*/*>") // Set the axes width to 2 pixels c.xAxis.setWidth(2) c.yAxis.setWidth(2) // Add an area layer to the chart. The area is using a y zone color, where the // color is semi-transparent green below 60, and semi-transparent red above 60. call c.addAreaLayer(data, c.yZoneColor(60, &h8033FF33, &h80FF3333)) // Add a custom CDML text at the bottom right of the plot area as the logo c.addText(475, 255,"<*block,valign=absmiddle*><*img="+c.GetPath(FindFile("small_molecule.png"))+"*> <*block*><*font=timesbi.ttf,size=10,color=804040*>Molecular"+endofline.unix+"Engineering<*/*>").setAlignment(CDXYChartMBS.kBottomRight) // output the chart Backdrop=c.makeChartPicture End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
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:

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


The biggest plugin in space...