Legend
import { Legend, LegendEntry } from 'cx/charts';<div class="widgets" controller={PageController}> <Svg style="width:300px; height:300px;"> <ColorMap /> <PieChart angle={360}> <Repeater records-bind="$page.points"> <PieSlice value-bind='$record.value' active-bind='$record.active' colorMap="pie" r={80} r0={20} offset={5} tooltip-tpl="{$record.name}: {$record.value:n;2}" innerPointRadius={80} outerPointRadius={90} name-bind="$record.name" selection={{ type: KeySelection, bind: '$page.selection', records: {bind: '$page.points'}, record: {bind: '$record'}, index: {bind: '$index'}, keyField: 'id' }}/> </Repeater> </PieChart> </Svg> <Grid records-bind="$page.points" style="width: 200px" columns={columns} selection={{ type: KeySelection, bind: '$page.selection', keyField: 'id' }}/> </div>
Note on Legend: If multiple charts are rendered on the same page, use Legend.Scope to prevent Legends from interfering with one another,
as shown in this example.
Legend Configuration
| Property | Description | Type |
|---|---|---|
name | Name of the legend. Default is | string |
showValues | Whether to show values in the legend. Default is | boolean |
vertical | Switch to vertical mode. | boolean |
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 |
entryClass | Additional CSS classes to be applied to the legend entry elements. | string/object |
entryStyle | Additional CSS styles to be applied to the legend entry elements | string/object |
mod | Appearance modifier. For example, | string/array |
outerLayout | Defines the outer layout which wraps the widget. | widget |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
shape | Specifies the shape of the symbol in the legend entries. By default, the shape of the series in the chart is used. | string |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
valueClass | Additional CSS classes to be applied to the legend entry values. | string/object |
valueFormat | Format string for the legend entry values. Default is | string |
valueStyle | Additional CSS styles to be applied to the legend entry values. | string/object |
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 |
|---|---|---|
colorIndex | Index of a color from the standard palette of colors. 0-15. | number |
colorMap | Used to automatically assign a color based on the | string |
colorName | Name used to automatically resolve color based from the contextual | string |
name | Name of the item as it will appear in the legend. | string |
selected | Indicate that entry is selected. | boolean |
shape | Shape of the symbol. | string |
size | Size of the symbol. Default value is | number |
active | Used to indicate if an item is active or not. Inactive items are shown only in the legend. | boolean |
autoFocus | Set to | boolean |
baseClass | Base CSS class to be applied to the element. No class is applied by default. | string |
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 |
innerHtml | HTML to be injected into the element. | 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 |
legendAction | Action to be performed if the user clicks on the legend entry. Default value is | string |
legendShape | Shape of the icon in the the legend. Default value is based on the chart type.
Additional shapes can be registered using 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 |
rx | Applies to rectangular shapes. The horizontal corner radius of the rect. Defaults to | string/number |
ry | Applies to rectangular shapes. The vertical corner radius of the rect. Defaults to | string/number |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
tag | Name of the HTML element to be rendered. Default is | string |
text | Inner text contents. | string |
tooltip | Tooltip configuration. For more info see Tooltips. | 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 |