0

I am trying to customize the tooltip as follows,

self.updateChart = function () {
    if ($("#chart").data("kendoChart") != undefined) {
        var chart = $("#chart").data("kendoChart");
        // the following line throws an error
        chart.options.tooltip.template= "#= myTooltip(value) # ";
    }
    chart.refresh();
}


function myTooltip(value) {
    return Math.abs(value.x) + " ,  " + Math.abs(value.y);
}

However I am getting the following error

"Uncaught Reference Error:myToolTip is not defined"

Doing as follows work; however I would like to keep working on the above code that will give me more flexibility.

$("#chart").kendoChart({
    tooltip: {
        visible: true,
        template: "#= myTooltip(value) # "
    }
});

function myTooltip(value) {
    return Math.abs(value.x) + " ,  " + Math.abs(value.y);
}
Nic
  • 12,220
  • 20
  • 77
  • 105
casillas
  • 16,351
  • 19
  • 115
  • 215
  • The message is telling you that `chart.options.series.tooltip` is undefined. What is `chart.options.series` and where is it coming from? – garryp May 08 '15 at 21:57
  • I have fixed that problem actually, then I have faced another issue and my question is updated – casillas May 08 '15 at 22:03
  • 1
    Did you define the myTooltip function above the Kendo chart function? Sometimes that's required. – Nic May 09 '15 at 01:30
  • @Vash, do you have any knowledge on the following question http://stackoverflow.com/questions/30144782/tooltip-with-multiple-parameters-in-kendo-ui – casillas May 09 '15 at 20:40

1 Answers1

1

Try this instead:

$("#chart").kendoTooltip(
{
    content : '#= myTooltip(value) #'
    ...
});

Check the docs which have some good samples:

http://demos.telerik.com/kendo-ui/tooltip/api

Also check this example out:

http://demos.telerik.com/kendo-ui/tooltip/template

Nic
  • 12,220
  • 20
  • 77
  • 105
garryp
  • 5,508
  • 1
  • 29
  • 41
  • Do you have direct solution to my issue? I am quite new on this platform. I could able to make it work my code in viewController, but once I decided to move it modelcontroller, then it throws that error. See my updated question added what you recommended. – casillas May 08 '15 at 22:09