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/xyline
This example is the version from Sun, 17th Mar 2012.
Project "xyline.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 (x, y) data for the first line
dim dataX0(-1) as double = array(20, 90, 40, 30, 12.0)
dim dataY0(-1) as double = array(10, 40, 75, 54, 20.0)
// The (x, y) data for the second line
dim dataX1(-1) as double = array(10, 40, 75, 54, 60.0)
dim dataY1(-1) as double = array(50, 90, 40, 30, 10.0)
// Create a XYChart object of size 450 x 450 pixels
dim c as new CDXYChartMBS(450, 450)
// Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white
// background and a light grey border (0xc0c0c0). Turn on both horizontal and
// vertical grid lines with light grey color (0xc0c0c0)
call c.setPlotArea(55, 65, 350, 300, &hffffff, -1, &hc0c0c0, &hc0c0c0, -1)
// Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12
// pts Times Bold Italic font. Set the background and border color to
// Transparent.
c.addLegend(50, 30, false, "timesbi.ttf", 12).setBackground(c.kTransparent)
// Add a title to the chart using 18 pts Times Bold Itatic font
call c.addTitle("Reaction Path", "timesbi.ttf", 18)
// Add a title to the y axis using 12 pts Arial Bold Italic font
call c.yAxis.setTitle("Temperature (Celcius)", "arialbi.ttf", 12)
// Set the y axis line width to 3 pixels
c.yAxis.setWidth(3)
// Add a title to the x axis using 12 pts Arial Bold Italic font
call c.xAxis.setTitle("Pressure (Pa)", "arialbi.ttf", 12)
// Set the x axis line width to 3 pixels
c.xAxis.setWidth(3)
// Add a red (0xff3333) line layer using dataX0 and dataY0
dim layer1 as CDLineLayerMBS
layer1 = c.addLineLayer(dataY0, &hff3333, "Compound AAA")
layer1.setXData(dataX0)
// Set the line width to 3 pixels
layer1.setLineWidth(3)
// Use 9 pixel square symbols for the data points
layer1.getDataSet(0).setDataSymbol(c.kSquareSymbol, 9)
// Add custom text labels to the first and last point on the scatter plot using
// Arial Bold font
call layer1.addCustomDataLabel(0, 0, "Start", "arialbd.ttf")
call layer1.addCustomDataLabel(0, 4, "End", "arialbd.ttf")
// Add a green (0x33ff33) line layer using dataX1 and dataY1
dim layer2 as CDLineLayerMBS
layer2 = c.addLineLayer(dataY1, &h33ff33, "Compound BBB")
layer2.setXData(dataX1)
// Set the line width to 3 pixels
layer2.setLineWidth(3)
// Use 11 pixel diamond symbols for the data points
layer2.getDataSet(0).setDataSymbol(c.kDiamondSymbol, 11)
// Add custom text labels to the first and last point on the scatter plot using
// Arial Bold font
call layer2.addCustomDataLabel(0, 0, "Start", "arialbd.ttf")
call layer2.addCustomDataLabel(0, 4, "End", "arialbd.ttf")
// 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
See also:
The items on this page are in the following plugins: MBS ChartDirector Plugin.