Pie Charts
import { PieChart, PieSlice } from 'cx/charts';Pie charts are commonly used to compare parts to the whole. In Cx, pie charts are implemented using
PieChart and PieSlice.
<Legend />
<Svg style="width:600px; height:400px;">
<ColorMap />
<PieChart angle-bind="$page.angle" startAngle-bind="$page.start" gap-bind="$page.gap">
<Repeater records-bind="$page.points">
<PieSlice
value-bind="$record.value"
active-bind="$record.active"
colorMap="pie"
r={80}
r0-bind="$page.r0"
borderRadius-bind="$page.borderRadius"
tooltip={{
text: {
tpl: "Item {$index}: {$record.value:n;2}",
},
trackMouse: true,
globalMouseTracking: true,
destroyDelay: 50,
createDelay: 0,
animate: false,
}}
innerPointRadius={80}
outerPointRadius={90}
name-bind="$record.name"
legendDisplayText-tpl="{$record.name} ({$record.value:n;1})"
selection={{
type: KeySelection,
bind: "$page.selection",
records: { bind: "$page.points" },
record: { bind: "$record" },
index: { bind: "$index" },
keyField: "id",
}}
>
<Line style="stroke:gray" />
<Rectangle anchors='1 1 1 1' offset="-10 20 10 -20" style="fill:white; stroke: gray">
<Text tpl="{$record.value:n;1}" dy="0.4em" ta="middle" />
</Rectangle>
</PieSlice>
</Repeater>
</PieChart>
</Svg>
<LabelsTopLayout columns={3}>
<Slider
value-bind="$page.count"
help-tpl="{$page.count} points"
increment={1}
step={1}
minValue={1}
maxValue={50}
label="Points"
/>
<Slider
value-bind="$page.gap"
help-tpl="{$page.gap}px"
increment={1}
step={1}
minValue={0}
maxValue={50}
label="Gap"
/>
<Slider
value-bind="$page.r0"
help-tpl="{$page.r0:ps;0}"
increment={1}
step={1}
minValue={0}
maxValue={70}
label="r0"
/>
<Slider
value-bind="$page.borderRadius"
help-tpl="{$page.borderRadius:n;0}px"
increment={1}
step={1}
minValue={0}
maxValue={50}
label="Border Radius"
/>
<Slider
value-bind="$page.start"
help-tpl="{$page.start:n;0}deg"
increment={1}
step={1}
minValue={0}
maxValue={270}
label="Start Angle"
/>
<Slider
value-bind="$page.angle"
help-tpl="{$page.angle:n;0}deg"
increment={1}
step={1}
minValue={10}
maxValue={360}
label="Total Angle"
/>
</LabelsTopLayout>| Property | Description | Type |
|---|---|---|
angle | Angle in degrees. Default is | number |
clockwise | When set to | boolean |
gap | Gap between slices in pixels. Default is | number |
startAngle | Start angle in degrees. Indicates the starting point of the first stack. Default is | number |
anchors | Anchor defines how child bounds are tied to the parent. Zero aligns with the top/left edge. One aligns with the bottom/right edge. See Svg for more information. | string/number/rect |
items | List of child elements. | array |
margin | Apply margin to the given boundaries. See Svg for more information. | string/number/rect |
mod | Appearance modifier. For example, | string/array |
offset | Move boundaries specified by the offset. See Svg for more information. | string/number/rect |
outerLayout | Defines the outer layout which wraps the widget. | widget |
padding | Padding to be applied to the boundaries rectangle before passing to the children. | string/number/rect |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
vdomKey | Key that will be used as the key when rendering the React component. | string |
visible | Visibility of the widget. Defaults to | boolean |
| Property | Description | Type |
|---|---|---|
active | Used to indicate whether an item is active or not. Inactive items are shown only in the legend. | boolean |
borderRadius | Border radius of the slice. Default is | number |
name | Name of the item as it will appear in the legend. | string |
offset | Value in pixels to be used to explode the pie. | number |
r | Outer pie radius in percents of the maximum available radius. If | number |
r0 | Inner pie radius in percents of the maximum available radius. If | number |
selection | Selection model to be used. | config |
class | Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list. | string/object |
hoverChannel | A value used to identify the group of components participating in hover effect synchronization. See HoverSync. | string |
hoverId | A value used to uniquely identify the record within the hover sync group. See HoverSync. | string |
items | List of child elements. | array |
layout | Define an inner layout. | string/object |
legend | Name of the legend to be used. Default is | string | false |
legendDisplayText | Text to be displayed in the legend. The default is copying the | string |
mod | Appearance modifier. For example, | string/array |
outerLayout | Defines the outer layout which wraps the widget. | widget |
plainText | Set to | boolean |
preserveWhitespace | Keep whitespace in text based children. Default is | boolean |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
stack | Multi-level pie charts consist of multiple stacks. Assign a unique name to each level. Default is | string |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
trimWhitespace | Remove all whitespace in text based children. Default is | boolean |
vdomKey | Key that will be used as the key when rendering the React component. | string |
visible | Visibility of the widget. Defaults to | boolean |