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/enhancedarea
This example is the version from Thu, 6th Apr 2016.
Project "enhancedarea.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 area 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 area 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 600 x 300 pixels, with a pale blue (eeeeff)
// background, black border, 1 pixel 3D border effect and rounded corners.
dim c as new CDXYChartMBS(600, 300, &heeeeff, &h000000, 1)
c.setRoundedFrame
// Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff)
// background. Set horizontal and vertical grid lines to grey (cccccc).
call c.setPlotArea(55, 55, 520, 195, &hffffff, -1, -1, &hcccccc, &hcccccc)
// Add a title box to the chart using 15 pts Times Bold Italic font. The text is
// white (ffffff) on a deep blue (000088) background, with soft lighting effect
// from the right side.
dim path as string =c.GetPath(FindFile("star.png"))
call c.addTitle("<*block,valign=absmiddle*><*img="+path+"*><*img="+path+"*> Performance Enhancer <*img="+path+"*><*img="+path+"*><*/*>", "timesbi.ttf", 15, &hffffff).setBackground(&h000088, -1, CDXYChartMBS.softLighting(CDXYChartMBS.kRight))
// 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 using a gradient color that changes vertically
// from semi-transparent red (80ff0000) to semi-transparent white (80ffffff)
call c.addAreaLayer(data, c.linearGradientColor(0, 50, 0, 255, &h80FF0000, &h80FFFFFF))
// Add a custom CDML text at the bottom right of the plot area as the logo
call c.addText(575, 245, "<*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
The items on this page are in the following plugins: MBS ChartDirector Plugin.