From c5f141306f358d099eda96e3c0d21aff5604be25 Mon Sep 17 00:00:00 2001 From: Tyler Romeo Date: Fri, 8 Jan 2016 20:02:45 -0800 Subject: [PATCH] Added documentation about tooltip templates It can be a little unclear what the actual format for tooltip templates are. Added information concerning how the tooltip templates are evaluated, and what context, i.e., variables, is available inside of them. --- docs/00-Getting-Started.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index a16692d53..d6db4651f 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -226,3 +226,22 @@ Chart.defaults.global.responsive = true; ``` Now, every time we create a chart, `options.responsive` will be `true`. + +###Tooltip Templates +For the `tooltipTemplate` and `multiTooltipTemplate` configuration options, you may use special template blocks. **Do not use user input in the tooltip template, as it may be executed as raw JavaScript.** + +Anything in between `<%` and `%>` will be executed as JavaScript. As in the example shown above, `<% if (label) { %>` and later `<% } %>`. Using `<%= expr %>` will print the value of the variable named by `expr` into the tooltip. + +The available variables to print into the tooltip depends on the chart type. In general, the following variables are available: + +```javascript +{ + value : "value of the data point", + label : "label for the position the data point is at", + datasetLabel: "label for the dataset the point is from", + strokeColor : "stroke color for the dataset", + fillColor : "fill color for the dataset", + highlightFill : "highlight fill color for the dataset", + highlightStroke : "highlight stroke color for the dataset" +} +``` -- 2.47.2