Default Tooltip can be modified at dataSeries or dataPoint level. You can add content to be displayed in toolTip using toolTipContent. toolTipContent set at dataPoint will override toolTipContent set at dataSeries level.
Default: auto set depending on chart type.toolTipContent can either be literal string or keywords. You can also use HTML tags.
eg: toolTipContent: "x: {x}, y: {y} "
eg: toolTipContent: " x: {x}, y: {y[0]} , {y[1]} "
eg: toolTipContent: " x: {x}, y: {y[0]}, {y[1]}, {y[2]}, {y[3]} "
eg: toolTipContent: "y: <span style='\"'color: red;'\"'>{y}</span>"
eg: toolTipContent: "{x}<br/> <span style='\"'color: {color};'\"'>{name}</span>, <strong>{y}</strong>",
eg: toolTipContent: "x:{x}, y: {y} <br/> name: {name}, label:{label}"
eg: toolTipContent: "{label} <hr/> x: {x}, y: {y}"
eg. toolTipContent: "<a href = '\"'http://apple.com'\"' target='\"'_blank'\"' >{label} </a> <hr/> x: {x}, y: {y}"
var chart = new CanvasJS.Chart("container", { . . data: [{ toolTipContent: "{y} sales", }, ] . . }); chart.render();
Try various combinations below.
Below is one more example showing how toolTipContent can be customized in range Charts. Note that y is an array in case of range charts.
8 Comments
Hey,
I try to have a tooltip on click, that simply shows me the label and the {y} in a pie chart, but I don’t get it :(
Can you help me please?
Sure.. Can you please create a jsfiddle for the same so that I can have a look?
Hi , Can I apply any conditional operator in tool tip for example (‘{y}’ == 0 ? ‘DOWN’ : ‘UP’) ?
Sumit,
This is not possible. Instead you can write your own custom content function which enables you to customize the toolTip content. Please refer this example.
Hi,
Can anyone help me out how to use tooltip for legend text
Do you mean to display toolTip when mouseover on legend ?
Yes Naveen. Is it posible to tooltip on legend text?
Sorry, toolTips are not supported on Legend yet.