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/explodedpie
This example is the version from Sun, 17th Mar 2012.
Project "explodedpie.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 pie chart
dim data(-1) as double = array(21.0, 18, 15, 12, 8, 24)
// The labels for the pie chart
dim labels(-1) as string = array("Labor", "Licenses", "Taxes", "Legal", "Facilities", "Production")
// The colors to use for the sectors
dim colors(-1) as integer
colors.Append &h66aaee
colors.Append &heebb22
colors.Append &hbbbbbb
colors.Append &h8844ff
colors.Append &hdd2222
colors.Append &h009900
// Create a PieChart object of size 600 x 360 pixels.
dim c as new CDPieChartMBS(600, 360)
// Use the white on black palette, which means the default text and line colors
// are white
c.setWhiteOnBlackColors
// Use a vertical gradient color from deep blue (000066) to blue (0000cc) as
// background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.
c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight, &h000066, &h0000cc))
c.setRoundedFrame(&hffffff, 20)
c.setDropShadow
// Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top
// margin to the title.
c.addTitle("Exploded Pie Chart Demonstration", "timesbi.ttf", 18).setMargin(0, 0, 16, 0)
// Set the center of the pie at (300, 195) and the radius to 110 pixels
c.setPieSize(300, 195, 110)
// Set the pie data and the pie labels
c.setData(data, labels)
// Set the sector colors
c.setColors(CDPieChartMBS.kDataColor, colors)
// Use local gradient shading for the sectors, with 5 pixels wide
// semi-transparent white (bbffffff) borders
c.setSectorStyle(CDPieChartMBS.kLocalGradientShading, &hbbffffff, 5)
// Use the side label layout method
c.setLabelLayout(CDPieChartMBS.kSideLayout)
// Use 10pt Arial Bold as the default label font. Set the label box background
// color the same as the sector color. Use soft lighting effect with light
// direction from right. Use 8 pixels rounded corners.
dim t as CDTextBoxMBS = c.setLabelStyle("arialbd.ttf", 10, &h000000)
t.setBackground(CDPieChartMBS.kSameAsMainColor, CDPieChartMBS.kTransparent, CDPieChartMBS.softLighting(CDPieChartMBS.kRight, 0))
t.setRoundedCorners(8)
// Set the sector label format. The label is centered in a 110 pixels wide
// bounding box. It consists of two lines. The first line is the sector name. The
// second line shows the data value and percentage.
c.setLabelFormat("<*block,halign=center,width=110*>{label}"+EndOfLine.unix+"<*font=arial.ttf,size=8*>US$ {value}M ({percent}%)<*/*>")
// Explode all sectors 10 pixels from the center
c.setExplode(-1, 10)
// 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.