Change background color on onClick event - Kendo React

1 Answer 558 Views
Charts Grid
User
Top achievements
Rank 1
User asked on 12 Nov 2022, 12:00 AM

Hello, 

I need to change the background color on onClick event when I have a multiple donut chart and a bar chart on a page. When I click on BarChart it needs to be selected and the bgColor changes to grey similarly when I select DonutChart - BarChart bgcolor resets and donut charts changes to grey instead

onPlotArea event did not work on DonutChart

This is what I have tried so far : 

const [selected, setSelected] = useState(false);
  const handleClick = () => {
    setSelected(selected => !selected);
  };

 

 <Grid container direction={{ xs: 'row', sm: 'column' }}>
      <Grid item onClick={handleClick}>
        {data ? (
          <BarChart
             data={data}
              title={'title}
          ></BarChart>
        ) : null}
      </Grid>
      {data ? (
        <>
          <Grid item>
            <DonutChart
              data={data}
              title={'title}
            ></DonutChart>
          </Grid>) : null}
    </Grid>

 

 

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 15 Nov 2022, 04:26 PM

Hello,

The plotAreaClick event is not available for pie / donut charts - it is supported only for charts which have axes. A possible option I can suggest you is to wrap each chart inside a standard `<div>` element and handle its click event instead:

https://stackblitz.com/edit/react-yz2esz-aftgvr?file=app%2Fmain.jsx

 

Regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Charts Grid
Asked by
User
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or