Filter in SharedTemplate chart tooltip

1 Answer 134 Views
Chart wrappers (package)
Ken
Top achievements
Rank 1
Ken asked on 27 Jul 2021, 08:40 PM

I'm using vuejs.

I've got a chart with a tooltip:

import { bytes } from '...fileBytesIsIn'
get tooltip () {
  const sharedTemplate = `<table class="tooltip-table" width="150">
  // removed header to save space
  # for (var i = 0; i < points.length; i++) { #
    <tr>
      <td><div class="swatch #: points[i].series.class#">&nbsp;</span></td>
      <td class="name" nowrap>#: points[i].series.name#</td>
      <td class="val">#: bytes(points[i].value) #</td>
    </tr>
  # } #
  </table>`
  return {
    visible: true,
    shared: true,
    template: '#= value #',
    sharedTemplate: sharedTemplate
  }
}
My issue: bytes is undefined. I've tried it like a filter 
#: points[i].value | bytes #
and several other ways, but nothing seems to work. Is there any way I can apply my formatting function to this value in the tooltip sharedTemplate so I can display these values as readable file sizes?

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 Jul 2021, 11:55 AM

Hello,

In such cases you can define the custom function in the global javascript scope as it is described here. Here is a dummy example where I defined the 'myCustomFunction' function in the index.html file. 

Regards,
Plamen
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Chart wrappers (package)
Asked by
Ken
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or