This is a migrated thread and some comments may be shown as answers.

Can I display custom tooltips on a pie chart via a callback?

1 Answer 157 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Rik
Top achievements
Rank 1
Rik asked on 12 Jun 2012, 02:51 PM
I have data that is in minutes, but I want to display the tooltip in hours and minutes. For example, if value was 200, the displayed tooltip would be "3 hours 20 minutes". 

I know I can use the templates to display a custom tooltip that is made up of the value and text, but I need to do more manipulation of the value to make it more friendly.

Thanks

Rik

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 15 Jun 2012, 10:41 AM
Hi Rik,

To achieve this you could create a function which implement the logic you need and call it in the tooltip. For example: 
$("#chart").kendoChart({
  ...
  tooltip: {
      visible: true,
       template: "#= templateFormat(value) #"
   },
});
...
               
function templateFormat(value) {
   var hours = Math.floor(value/60);
   var minutes = Math.floor(value%60);
   return hours + " hours " + minutes + " minutes";
}

For convenience, I created a simple project which illustrates such approach in action.

 

Greetings,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Charts
Asked by
Rik
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or