Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/ChartDirector/iconpie
Function:
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/iconpie
This example is the version from Thu, 6th Apr 2016.
Project "iconpie.rbp"
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( 72.0, 18, 15, 12) // The depths for the sectors dim depths(-1) as double = array(30.0, 20, 10, 10) // The labels for the pie chart dim labels(-1) as string=array("Sunny", "Cloudy", "Rainy", "Snowy") // The icons for the sectors dim icons(-1) as FolderItem icons.append FindFile("sun.png") icons.append FindFile("cloud.png") icons.append FindFile("rain.png") icons.append FindFile("snowy.png") // Create a PieChart object of size 400 x 310 pixels, with a blue (CCCCFF) // vertical metal gradient background, black border, 1 pixel 3D border effect and // rounded corners dim c as new CDPieChartMBS(400, 310, CDPieChartMBS.metalColor(&hccccff, 0), &h000000, 1) c.setRoundedFrame // Set the center of the pie at (200, 180) and the radius to 100 pixels c.setPieSize(200, 180, 100) // Add a title box using 15 pts Times Bold Italic font, on a blue (CCCCFF) // background with glass effect dim t as CDTextBoxMBS t=c.addTitle("Weather Profile in Wonderland", "timesbi.ttf", 15) t.setBackground(&hccccff, &h000000, c.glassEffect) // Set the pie data and the pie labels c.setData data,labels // Add icons to the chart as a custom field c.addExtraField(icons) // Configure the sector labels using CDML to include the icon images c.setLabelFormat("<*block,valign=absmiddle*><*img={field0}*> <*block*>{label}"+EndOfLine.UNIX+"{percent}%<*/*><*/*>") // Draw the pie in 3D with variable 3D depths c.set3D depths // Set the start angle to 225 degrees may improve layout when the depths of the // sector are sorted in descending order, because it ensures the tallest sector // is at the back. c.setStartAngle(225) // 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

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS ChartDirector Plugin.




Links
MBS Xojo PDF Plugins