Platforms to show: All Mac Windows Linux Cross-Platform

/ChartDirector/smallsectorpie print


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/smallsectorpie print

This example is the version from Tue, 12th Dec 2016.

Project "smallsectorpie print.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class PicWindow Inherits Window
Control out Inherits Canvas
ControlInstance out Inherits Canvas
EventHandler Sub Open() // fix some properties if set wrong in IDE me.DoubleBuffer = false me.EraseBackground = false #if RBVersion >= 2013.0 then me.Transparent = False #endif End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawPicture pic,0,0,g.Width,g.Height,0,0,pic.width,pic.height End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim g as Graphics = OpenPrinterDialog if g=nil then Return dim p as Picture=run(4) dim x,y,w,h as integer dim f as double f=min(g.height/pic.Height,g.width/pic.Width) w=pic.Width*f h=pic.Height*f x=(g.width-w)/2 y=(g.height-h)/2 g.DrawPicture p,x,y,w,h,0,0,p.Width,p.Height End EventHandler
End Control
EventHandler Sub Open() pic=run(1) End EventHandler
Function run(f as Double) As picture // The data for the pie chart dim data(-1) as double = array(35.0, 30, 25, 7, 6, 5, 4, 3, 2, 1) // The labels for the pie chart dim labels(-1) as string= array("Labor", "Production", "Facilities", "Taxes", "Misc", "Legal", "Insurance", "Licenses", "Transport", "Interest") // Create a PieChart object of size 560 x 270 pixels, with a golden background // and a 1 pixel 3D border dim c as new CDPieChartMBS(f*560, f*270, CDPieChartMBS.goldColor, -1, f) // Add a title box using 15 pts Times Bold Italic font and metallic pink // background color dim t as CDTextBoxMBS t=c.addTitle("Project Cost Breakdown", "timesbi.ttf", 15*f) t.setBackground(c.metalColor(&hff9999)) // Set the center of the pie at (280, 135) and the radius to 110 pixels c.setPieSize(280*f, f*135, f*110) // alternative a donut: 'c.setDonutSize(280, 140, 110, 55) // Draw the pie in 3D with 20 pixels 3D depth c.set3D(f*20) // Use the side label layout method c.setLabelLayout(c.kSideLayout) // Set the label box background color the same as the sector color, with glass // effect, and with 5 pixels rounded corners t = c.setLabelStyle("",8*f) t.setBackground(c.kSameAsMainColor, c.kTransparent, c.glassEffect()) t.setRoundedCorners(5) c.setJoinLine(0,f) // Set the border color of the sector the same color as the fill color. Set the // line color of the join line to black (0x0) c.setLineColor(c.kSameAsMainColor, &h000000) // Set the start angle to 135 degrees may improve layout when there are many // small sectors at the end of the data array (that is, data sorted in descending // order). It is because this makes the small sectors position near the // horizontal axis, where the text label has the least tendency to overlap. For // data sorted in ascending order, a start angle of 45 degrees can be used // instead. c.setStartAngle(135) // Set the pie data and the pie labels c.setdata(data, labels) return c.MakeChartPicture End Function
Property pic As Picture
Property printPicture As Picture
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.


The biggest plugin in space...