pie(n)
π pie(n) β the tkpiechart pie class, but make it make sense β¨
okay bestie, so this is the manual for <rainbow>pie(n)</rainbow>, aka the tkpiechart pie class β and yes it's the Tcl/Tk one, not the dessert (sadly π). It's giving very much "my chart ate" energy. Let's get into it π«Ά
πΈ NAME πΈ
pie β a 2D or 3D pie chart object that lives in a canvas. That's it, that's the whole vibe π
β¨ SYNOPSIS β¨
so first you gotta require the packages, and the versions matter, don't @ me:
package require stooop 4.1
package require switched 2.2
package require tkpiechart 6.6
and then the actual calls, in all their glory:
stooop::new pie canvas x y ?options?
switched::configure pieObject ?options?
switched::cget pieObject option
stooop::delete pieObject
pie::newSlice pieObject ?labelText?
pie::deleteSlice pieObject sliceObject
pie::sizeSlice pieObject sliceObject unitShare ?displayedValue?
pie::labelSlice pieObject sliceObject string
pie::selectedSlices pieObject
π DESCRIPTION π
So a pie object is literally there to visualize a set of values β usually as shares of a total, iykyk. Each value? That's a colored slice π, and it can have a 2 dimensional or 3 dimensional look. Every slice gets a label showing the data name, plus a numerical field showing the percentage that slice takes up. The labels are placed by whichever labeler object you picked (the -labeler option), and each label's color matches its related slice. color-coordinated, main character energy π
A pie chart is made of Tk canvas items β found in pieBoxLabeler, piePeripheralLabeler and canvasLabel objects β that compose the pie object. The pie constructor creates the pie itself and its background slice inside the parent canvas. Once the pie object exists, slices can be created and resized. And important: at the time the pie is created, the parent Tk canvas widget must already exist. no cap, it has to be there first π«Ά
Slice colors are automatically generated using a default color list for all pies β unless you use another list via the -colors option. When you go 3D, the slice edge is darker than its top, but it keeps the same color tone. aesthetic β¨
stooop::new pie canvas x y ?options? β Creates a pie object in the specified Tk canvas. The upper left corner of the pie is placed at those coordinates in the canvas. It returns the pie object identifier (referred to as pieObject in this document). π
switched::configure pieObject ?options? β Configures a pie object, or returns all the options with their current values if you pass no options. lowkey handy π
switched::cget pieObject option β Returns an option value for the specified pie object.
stooop::delete pieObject β Deletes the specified pie object. bye bestie π
π¦ OVERVIEW π¦
The pie class is part of the tkpiechart extension, which lets you create and dynamically update 2D or 3D pie charts in a Tcl/Tk application. The tkpiechart package is written in Tcl only, using object oriented techniques thanks to the stooop package β which is included in tcllib. Tcl-only, no compiled nonsense, we love that for us π
π OPTIONS π
-autoupdate booleanβ Boolean value saying whether all the slices and their labels get redrawn when a slice size changes. On by default. Turn it off and callpie::updateif you're changing a bunch of slices at once and want better performance. performance queen πββοΈ-background colorβ Slices may or may not fill up 100% of the pie. The unoccupied part of the pie is a slice that takes 100% of the pie. It's transparent by default with a black border. You can set the color of this background slice using color names, same as the standard-backgroundoption (peep the Tk options manual page for more details). When the pie has a 3D look, the background of a slice edge is darker than the top and uses the same color tone. π-colors listβ Specifies a list of colors for slices. In that case, slice colors get drawn successively from the list in list order, cycling through if there are more slices than colors in the list. Colors use the same format as the-backgroundoption. π¨-height valueβ Specifies the total height for the pie, including the room taken by the labeler labels. The pie slices get resized when labels are added or deleted (i.e. when adding or deleting slices) so the total height stays constant. This value may be specified in any of the forms described in the canvasCOORDINATESmanual section. π-labeler objectβ Specifies a placer object for the slice labels, so that, for example, slice values may be placed next to them. If you don't specify one,pieBoxLabeleris used (see corresponding manual) β the other option being thepiePeripheralLabelerclass. Each labeler has its own specific behavior which may be set via its options. The labeler object is automatically deleted when the pie object itself is deleted. And heads up: the labeler cannot be changed once the pie is created. π-selectable booleanβ Boolean value saying whether slices are selectable or not. Acceptable values are the ones the Tcl language itself defines for boolean values. If selectable, slices can be selected with the first mouse button, by clicking either the slice or its label. Selection can be extended using the classical Ctrl or Shift clicks. The list of currently selected slices can be retrieved at any time using theselectedSlicespie class member procedure. π±οΈβ¨-title textβ Title text to be placed above the pie. π-titlefont valueβ Font for the title text. π-titleoffset valueβ Distance between the bottom of the title text and the top of the pie slices. This value may be specified in any of the forms described in the sizes section below. (that's theSIZESsection, bestie, keep scrolling π)-thickness valueβ Thickness is set to0by default, which gives the pie a simple 2D shape, much faster to display. A positive thickness value gives the pie a 3D look with matched darker colors for the slice edges. These values may be specified in any of the forms described in theSIZESsection below. π§-width valueβ Specifies the total width for the pie, including the room taken by the labeler labels. The pie slices get resized when labels are added or deleted (i.e. when adding or deleting slices) so the total width stays constant. This value may be specified in any of the forms described in the canvasCOORDINATESmanual section. π
π MEMBER PROCEDURES π
pie::newSlice pieObject ?labelText? β Creates a slice. Returns a unique object identifier (referred to as sliceObject in this document). The slice color is automatically allocated and the slice label is placed using the specified labeler (via the -labeler option). The slice itself is placed after (clockwise) the existing slices. That slice object identifier is what you'll use for sizing and resizing the slice. π°
If the label text isn't specified, it gets set to "slice n", where n is the number of the slice in the order of creation (first slice is number 1).
pie::deleteSlice pieObject sliceObject β Deletes a slice. The following slices (clockwise), if any, are then moved to compensate for the empty space the deleted slice left behind. π
pie::sizeSlice pieObject sliceObject unitShare ?displayedValue? β Sizes or resizes a slice. The slice is then automatically recalculated so it occupies the proper share of the whole pie. The unitShare parameter is a floating point number expressed as a share (between 0 and 1) of the whole pie. The following slices (clockwise) are moved to accommodate the new slice size. The slice size value next to the slice label is also updated with the new share value, or with displayedValue if you specified it. π₯
pie::labelSlice pieObject sliceObject string β Updates a slice label. Can be invoked at any time. π·οΈ
pie::selectedSlices pieObject β Returns a list of currently selected slice objects. π«Ά
β TAGS β
The whole pie, the pie graphics (all slices), and each slice have these specific tags:
pie(pieObject)pieSlices(pieObject)slice(sliceObject)
So for example, the whole pie can be moved using the canvas move command on the pie tag, or bindings on slices can be set using the slice tags (peep the canvas manual page ITEM IDS AND TAGS section for more info). π«
πΈ SIZES πΈ
All sizes related to pies are stored as floating point numbers. The coordinates and sizes are specified in screen units, which are floating point numbers optionally followed by one of several letters, as specified in the canvas COORDINATES manual section. π’
π LIMITATIONS π
If the number of slices is too big, identical colors will be used for some of the slices. In that case you may set your own colors. yeah. it's giving "we ran out of crayons" π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tkpiechart of the Tklib Trackers at http://core.tcl.tk/tklib/reportlist. Please also report any ideas for enhancements you may have for either the package and/or the documentation. we appreciate you fr fr π«Ά
π SEE ALSO π
canvasLabel, pieBoxLabeler, piePeripheralLabeler β go read those next, bestie π
π KEYWORDS π
canvas, labeler, pie, slice
π COPYRIGHT π
Copyright (c) 1995-2004 Jean-Luc Fontaine <jfontain@free.fr>
okay that's the whole page, no skips, no "etc." β every flag, every number, every path is in there π
and that's a wrap, bestie π this one's from tklib, version 6.6, and the doc itself is the pie(n) page from the tkpiechart pie class β periodt. ππ¦
π¦ where this page comes from
- alpine 3.24: tk-lib-doc 0.7-r0 Β· TCL
- Copyright (c) 1995-2004 Jean-Luc Fontaine <jfontain@free\&.fr>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms