API
The selection capability is not provided out of the box, but it can be implemented using the pointClick event. The following code gives an example of a scenario when clicking on a point selects it, and clicking on it again clears the selection. Call a point's isSelected() method to check whether it is selected.
- <template>
- <DxPieChart ...
- @point-click="onPointClick">
- </DxPieChart>
- </template>
- <script>
- import DxPieChart from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart
- },
- methods: {
- onPointClick({ target: point }) {
- if (point.isSelected()) {
- point.clearSelection();
- } else {
- point.select();
- }
- }
- }
- }
- </script>
In the previous code example, a specific point's selection was cleared. Call a series' clearSelection() method if you need to clear all the selected points in that series.
- <template>
- <DxPieChart ...
- @point-click="onPointClick">
- </DxPieChart>
- </template>
- <script>
- import DxPieChart from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart
- },
- methods: {
- onPointClick({ target: point }) {
- const series = point.series;
- if (series.isSelected()) {
- series.clearSelection();
- } else {
- series.select();
- }
- }
- }
- }
- </script>
In a multi-series PieChart, you can clear the entire selection at once by calling the PieChart instance's clearSelection() method.
- <template>
- <DxPieChart ref="pieChart">
- </DxPieChart>
- </template>
- <script>
- import DxPieChart from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart
- },
- methods: {
- clearSelection () {
- return this.$refs.pieChart.instance.clearSelection();
- }
- }
- }
- </script>
See Also
User Interaction
When a user selects a series point, its style changes to the one specified by the series.selectionStyle object.
- <template>
- <DxPieChart ... >
- <DxSeries>
- <DxSelectionStyle>
- <!-- ... -->
- </DxSelectionStyle>
- </DxSeries>
- </DxPieChart>
- </template>
- <script>
- import DxPieChart, {
- DxSeries,
- DxSelectionStyle
- } from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart,
- DxSeries,
- DxSelectionStyle
- }
- }
- </script>
You can disable the selection capability by settings the series.selectionMode property to "none".
- <template>
- <DxPieChart ... >
- <DxSeries selection-mode="none" />
- </DxPieChart>
- </template>
- <script>
- import DxPieChart, {
- DxSeries
- } from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart,
- DxSeries
- }
- }
- </script>
Only a single point can be in the selected state at a time by default. If you need to allow multiple points to be in this state, assign "multiple" to the pointSelectionMode property.
- <template>
- <DxPieChart
- point-selection-mode="multiple"> <!-- or 'single' -->
- </DxPieChart>
- </template>
- <script>
- import DxPieChart from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart
- }
- }
- </script>
Events
When a user selects a series point, the PieChart fires the pointSelectionChanged event that you can handle with a function. Assign this function to the onPointSelectionChanged property when you configure the UI component if it is going to remain unchanged during the UI component's lifetime. Call the point's isSelected() method to check whether it was selected or the selection was cleared.
- <template>
- <DxPieChart
- @point-selection-changed="onPointSelectionChanged">
- </DxPieChart>
- </template>
- <script>
- import DxPieChart from 'devextreme-vue/pie-chart';
- export default {
- components: {
- DxPieChart
- },
- methods: {
- onPointSelectionChanged({ target: point }) {
- if (point.isSelected()) {
- // Commands to execute when the point is selected
- } else {
- // Commands to execute when the selection is cleared
- }
- }
- }
- }
- </script>
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.