How do I do a multi line chart tooltip (MVVM, if that matters)?

1 Answer 135 Views
Charts ToolTip
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Jay asked on 16 May 2023, 03:30 PM | edited on 16 May 2023, 06:19 PM

I'm trying to get a chart to display a multi line tooltip. I've seen elsewhere that I'm supposed to put a <br/> in it for new lines, but that doesn't seem to be working. The text from the tooltip template is being run through kendo.htmlEncode, which translates the <br/> into &lt;br&gt;. which of course doesn't provide the wanted line break.

Here is a dojo.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 May 2023, 11:41 AM

Hi Jay,

I recommend directly using a Kendo template and building the tooltip markup as desired. For example:

data-series-defaults="{ type: 'column', tooltip: { visible: true, template: $('#tmp').html() } }"
...
<script type="x-kendo/tmp" id="tmp">
    Value
    <br>
  	#= kendo.format("{0:c0}", value) #
  </script>

Dojo demo: https://dojo.telerik.com/uTolANAD

Regards,
Nikolay
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 23 May 2023, 03:28 PM

Thanks, Nikolay, that got me pointed in the right direction. Turns out I just had to change my tooltip template definition slightly from 
template: '#: tooltipText(value) #'
to
template: '#= tooltipText(value) #'
I noticed your example used the #= syntax, and the template link you provided explained that the #= renders as HTML while the #: renders using encoding.
Nikolay
Telerik team
commented on 26 May 2023, 08:34 AM

Hi Jay,

Thank you for the update.

Indeed, the different syntax changes the rendering:

 - (#= #) - Render values as HTML.
 - (#: #) - Use HTML encoding to display values.

The article: https://docs.telerik.com/kendo-ui/framework/templates/essentials#template-syntax

Regards,

Nikolay

 

Tags
Charts ToolTip
Asked by
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Nikolay
Telerik team
Share this question
or