charts-customizedtooltip.mustache revision 9cd4693ce0f719a022c641a0032163bb2c2acbb5
ad127d839d2e7aa542939a8a336691407e23397eMark Andrews<style scoped>
ad127d839d2e7aa542939a8a336691407e23397eMark Andrews margin:10px 10px 10px 10px;
ad127d839d2e7aa542939a8a336691407e23397eMark Andrews max-width: 800px;
ad127d839d2e7aa542939a8a336691407e23397eMark Andrews height:400px;
<p>A `Chart` instance comes with a simple default tooltip. This tooltip is represented by the `tooltip` attribute. Through the tooltip attribute you can do the following:
<dt>hideEvent</dt><dd>Event that should trigger the removal of a tooltip (can be an event or an array of events)</dd>
<dt>markerLabelFunction</dt><dd>Reference to the function used to format a marker event triggered tooltip's text. The method contains
<dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided).</dd>
The method returns an `HTMLElement` which is written into the DOM using `appendChild`. If you override this method and choose to return an html string, you
<dt>planarLabelFunction</dt><dd>Reference to the function used to format a planar event triggered tooltip's text
<dt>valueItems</dt><dd>Array of objects for each series that has a data point in the coordinate plane of the event. Each object contains the following data:
The method returns an `HTMLElement` which is written into the DOM using `appendChild`. If you override this method and choose to return an html string, you
<dt>setTextFunction</dt><dd>Method that writes content returned from `planarLabelFunction` or `markerLabelFunction` into the the tooltip node.
<dt>val</dt><dd>The content to be rendered into tooltip. This can be a `String` or `HTMLElement`. If an HTML string is used, it will be rendered as a
<p>In this example, we have changed the styles and set a custom `markerLabelFunction` to format the text.</p>
var msg = document.createElement("div"),
underlinedTextBlock = document.createElement("span"),
boldTextBlock = document.createElement("div");
underlinedTextBlock.style.textDecoration = "underline";
boldTextBlock.style.marginTop = "5px";
boldTextBlock.style.fontWeight = "bold";
categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")])));
boldTextBlock.appendChild(document.createTextNode(valueItem.axis.get("labelFunction").apply(this, [valueItem.value, {prefix:"$", decimalPlaces:2}])));
msg.appendChild(underlinedTextBlock);
msg.appendChild(boldTextBlock);
var mychart = new Y.Chart({