How to set an individual Pie Chart ToolTip text colour

1 Answer 54 Views
Chart (HTML5)
Adam
Top achievements
Rank 1
Iron
Adam asked on 18 Jun 2024, 11:42 AM | edited on 18 Jun 2024, 11:44 AM

Hi all,

I have tried to use the samples shown in this post ( https://www.telerik.com/forums/determine-column-series-color ) but cannot get it to apply for a pie chart. I have several dark & light coloured pie segments (eg: black & yellow) and cannot set a single colour across the board.

My current function looks like this:

function Chart1SeriesHover(e) { setTimeout(function () { switch (e.category) { case'Not Done': $telerik.$('.k-tooltip')[0].style.color = "white"; //black pie segment break; default: break;

} }, 10); }


but I keep getting the following error in DevTools:

Uncaught TypeError: Cannot read properties of undefined (reading 'style')

Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vasko
Telerik team
answered on 19 Jun 2024, 05:51 AM

Hello Adam,

The error you're getting is due to the time set in the setTimeout method, as tooltips need more than 10 milliseconds to render on the page, hence the tooltip you're targeting is undefined, therefore erroring out. 

Try adjusting to bigger time values, when I tested it, I found 110 works perfectly fine. 

Regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Adam
Top achievements
Rank 1
Iron
commented on 19 Jun 2024, 05:54 AM

Thanks Vasko - that worked!
Tags
Chart (HTML5)
Asked by
Adam
Top achievements
Rank 1
Iron
Answers by
Vasko
Telerik team
Share this question
or