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/rotatedline
This example is the version from Sun, 17th Mar 2012.
Project "rotatedline.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()
//
// We use a random table to simulate generating 12 months of data
//
// Create the random table object with 4 cols * 12 rows, using 3 as seed
dim rantable as new CDRanTableMBS(3, 4, 12)
// Set the 1st column to be the 12 months of year 2002
rantable.setDateCol(0, CDXYChartMBS.chartTime(2002, 1, 1), 86400 * 30)
// Set the 2nd, 3rd and 4th columns to be random numbers starting from 125, 75,
// and 100 respectively. The change between rows is set to -35 to + 35. The
// minimum value of any cell is 0.
rantable.setCol(1, 125, -35, 35, 0)
rantable.setCol(2, 75, -35, 35, 0)
rantable.setCol(3, 100, -35, 35, 0)
// Get the 1st column (time) as the x data
dim dataX as CDArrayMBS = rantable.getCol(0)
// Get the 2nd, 3rd and 4th columns as 3 data sets
dim dataY0 as CDArrayMBS = rantable.getCol(1)
dim dataY1 as CDArrayMBS = rantable.getCol(2)
dim dataY2 as CDArrayMBS = rantable.getCol(3)
// Create a XYChart object of size 360 x 400 pixels
dim c as new CDXYChartMBS(360, 400)
// Add a title to the chart
call c.addTitle("<*underline=2*>Rotated Line Chart Demo", "timesbi.ttf", 14)
// Set the plotarea at (60, 75) and of size 190 x 320 pixels. Turn on both
// horizontal and vertical grid lines with light grey color (0xc0c0c0)
call c.setPlotArea(60, 75, 190, 320).setGridColor(&hc0c0c0, &hc0c0c0)
// Add a legend box at (270, 75)
call c.addLegend(270, 75)
// Swap the x and y axis to become a rotated chart
c.swapXY
// Set the y axis on the top side (right + rotated = top)
c.setYAxisOnRight
// Add a title to the y axis
call c.yAxis.setTitle("Throughput (MBytes)")
// Reverse the x axis so it is pointing downwards
c.xAxis.setReverse
// Add a line chart layer using the given data
dim layer as CDLineLayerMBS
layer = c.addLineLayer
call layer.setXData(dataX)
call layer.addDataSet(dataY0, &hff0000, "Server A")
call layer.addDataSet(dataY1, &h338033, "Server B")
call layer.addDataSet(dataY2, &h0000ff, "Server C")
// Set the line width to 2 pixels
layer.setLineWidth(2)
// 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.