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/concentric
This example is the version from Sun, 17th Mar 2012.
Project "concentric.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()
// Data for outer ring
dim data(-1) as double=array(88.0, 124, 96)
// Data for inner ring
dim data2(-1) as double=array(77.0, 87, 45)
// Labels for the sectors
dim labels(-1) as string =array("Hardware", "Software", "Services")
// Colors for the sectors
dim color1 as integer=&hff9999
dim color2 as integer=&h9999ff
dim color3 as integer=&h66ff66
dim colors(-1) as integer= array(color1, color2, color3)
//
// Create the main chart, which contains the chart title, the outer ring, and the
// legend box
//
// Create a PieChart object of size 450 x 360 pixels, with transparent background
dim c as new CDPieChartMBS(450, 360)
// Add a title to the chart with 18pts Times Bold Italic font
call c.addTitle("Concentric Donut Chart", "timesbi.ttf", 18)
// Set donut center at (160, 200), and outer/inner radii as 150/100 pixels
c.setDonutSize(160, 200, 150, 100)
// Add a label at the bottom-right corner of the ring to label the outer ring Use
// 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)
// background, with soft lighting effect and 5 pixels rounded corners
dim t as CDTextBoxMBS
t = c.addText(260, 300, " Year 2006 ", "arialbi.ttf", 12, &hffffff)
t.setBackground(&h008800, c.kTransparent, C.softLighting())
t.setRoundedCorners(5)
// Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no
// border
t=c.addLegend(320, 50, true, "arialbi.ttf", 13)
t.setBackground(c.kTransparent,c.kTransparent)
// Set the pie data and the pie labels
c.setData(data,labels)
// Set the pie colors
c.setColors(c.kDataColor, colors)
// Set pie border color to white (ffffff)
c.setLineColor(&hffffff)
// Set pie label to value in $###M format, percentage in (##.#%) format, in two
// lines.
c.setLabelFormat("${value}M<*br*>({percent|1}%)")
// Use 10pts Airal Bold for the sector labels
call c.setLabelStyle("arialbd.ttf", 10)
// Set the label position to -25 pixels from the sector (which would be internal
// to the sector)
c.setLabelPos(-25)
//
// Create the inner ring.
//
// Create a PieChart object of size 280 x 320 pixels, with transparent background
dim c2 as new CDPieChartMBS(280, 320, c.kTransparent)
// Set donut center at (110, 110), and outer/inner radii as 100/50 pixels
c2.setDonutSize(110, 110, 100, 50)
// Add a label at the center of the ring to label the inner ring. Use 12pts Arial
// Bold Italic font in white (ffffff) color, on a deep blue (0000cc) background,
// with soft lighting effect and 5 pixels rounded corners
t=c2.addText(110, 110, " Year 2005 ", "arialbi.ttf", 12, &hffffff, c.kCenter)
t.setBackground(&h0000cc, c.kTransparent, c.softLighting())
t.setRoundedCorners(5)
// Set the pie data and the pie labels
c2.setData(data2,labels)
// Set the pie colors
c2.setColors(c.kDataColor, colors)
// Set pie border color to white (ffffff)
c2.setLineColor(&hffffff)
// Set pie label to value in $###M format, percentage in (##.#%) format, in two
// lines.
c2.setLabelFormat("${value}M<*br*>({percent|1}%)")
// Use 10pts Airal Bold for the sector labels
call c2.setLabelStyle("arialbd.ttf", 10)
// Set the label position to -25 pixels from the sector (which would be internal
// to the sector)
c2.setLabelPos(-25)
// merge the inner ring into the outer ring at (50, 90)
c.makeChart.merge(c2.makeChart, 50, 90, c.kTopLeft, 0)
// 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.