Chart.js: How do i style the tooltip?

Created on 10 Sep 2014  Â·  4Comments  Â·  Source: chartjs/Chart.js

I'm trying to outline the values in my tooltip to the right.
By reading the documentation, I find the following under chart configuration:

tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",

My guess is, I can add a style somehow here? This structure makes no sense to me and I don't know how to edit the example code to my liking.
How would I go about chaning this sample code to make the numbers in the tooltip outline to the right?

Most helpful comment

How about if you want to enter a new line? I would like to have label and value under in a new line, centered. I tried HTML br but didn't seem to help..

All 4 comments

Template is just for listing labels and their values, like this.
Label: value

You can't style tooltip directly with css because it's draw in canvas with paths.

By the way, you can (only) change these options (see docs):
tooltipXPadding,
tooltipYPadding,
tooltipFillColor,
tooltipFontColor,
tooltipFontFamily,
tooltipFontStyle,
tooltipFontSize,
tooltipCaretSize,
tooltipCornerRadius.

To change template from previous to, for example, Label = value€, you must change this option:
tooltipTemplate : "<%if (label){%><%=label%>= <%}%><%= value %>€"

Yep, thanks @fntneves - couldn't have put it any better!

How about if you want to enter a new line? I would like to have label and value under in a new line, centered. I tried HTML br but didn't seem to help..

how do I add more lines to tooltips?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JAIOMP picture JAIOMP  Â·  3Comments

SylarRuby picture SylarRuby  Â·  3Comments

Woogles picture Woogles  Â·  3Comments

srijitcoder picture srijitcoder  Â·  3Comments

HeinPauwelyn picture HeinPauwelyn  Â·  3Comments