Loading
Introduction to Tooltip Macros
Prerequisites:
FusionCharts Suite XT supports macros to configure dynamic and contextual content in tooltips. A macro is an instruction recorded using a combination of characters for a specific purpose.
Tooltip macros in FusionCharts enable you to use chart labels, data values, display values etc. as variables, and plain text, to form a complete customized tooltip text.
Tooltips can be configured to include supplementary information about the data plotted on a chart. Macros allow you to automate the inclusion of this information, saving the effort of manual customization.
This article focuses on how macros can be used to customize the tooltip text for various chart elements. The article also introduces attributes that take the macros as values, along with plain text and HTML tags, to create and format the custom tooltip text.
Using Tooltip Macros
In the column 2D chart shown below, hover the mouse pointer over any of the data plots to see the default tooltip text:
{
"chart": {
"caption": "Harry's SuperMart: Sales Analysis for Top Five Store Locations",
"subCaption": "YTD",
"yAxisName": "Sales (In USD)",
"numberPrefix": "$",
"showValues": "1",
"theme": "fint"
},
"data": [
{
"label": "Bakersfield Central",
"value": "750000",
"displayValue": "Store manager: Victoria"
},
{
"label": "Garden Groove Harbour",
"value": "700000",
"displayValue": "Store manager: Teresa"
},
{
"label": "Los Angeles Topanga",
"value": "690000",
"displayValue": "Store manager: Elvis"
},
{
"label": "Compton-Rancho Dom",
"value": "650000",
"displayValue": "Store manager: Pete"
},
{
"label": "Daly City Serramonte",
"value": "620000",
"displayValue": "Store manager: Reesa"
}
]
}
<html>
<head>
<title>My first chart using FusionCharts Suite XT</title>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></script>
<script type="text/javascript">
FusionCharts.ready(function(){
var fusioncharts = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
id: "myChart",
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Harry's SuperMart: Sales Analysis for Top Five Store Locations",
"subCaption": "YTD",
"yAxisName": "Sales (In USD)",
"numberPrefix": "$",
"showValues": "1",
"theme": "fint"
},
"data": [{
"label": "Bakersfield Central",
"value": "750000",
"displayValue": "Store manager: Victoria"
}, {
"label": "Garden Groove Harbour",
"value": "700000",
"displayValue": "Store manager: Teresa"
}, {
"label": "Los Angeles Topanga",
"value": "690000",
"displayValue": "Store manager: Elvis"
}, {
"label": "Compton-Rancho Dom",
"value": "650000",
"displayValue": "Store manager: Pete"
}, {
"label": "Daly City Serramonte",
"value": "620000",
"displayValue": "Store manager: Reesa"
}]
}
}
);
fusioncharts.render();
});
</script>
</head>
<body>
<div id="chart-container">FusionCharts XT will load here!</div>
</body>
</html>
Now, look at the tooltip text for the data plots in the column 2D chart below:
Sales (YTD): $dataValue
$displayValue", "theme": "fint" }, "data": [ { "label": "Bakersfield Central", "value": "750000", "displayValue": "Store manager: Victoria" }, { "label": "Garden Groove Harbour", "value": "700000", "displayValue": "Store manager: Teresa" }, { "label": "Los Angeles Topanga", "value": "690000", "displayValue": "Store manager: Elvis" }, { "label": "Compton-Rancho Dom", "value": "650000", "displayValue": "Store manager: Pete" }, { "label": "Daly City Serramonte", "value": "620000", "displayValue": "Store manager: Reesa" } ] }
{
"chart": {
"caption": "Harry's SuperMart: Sales Analysis for Top Five Store Locations",
"subCaption": "YTD",
"yAxisName": "Sales (In USD)",
"numberPrefix": "$",
"showValues": "1",
"plotToolText": "Store location: $label <br> Sales (YTD): $dataValue <br> $displayValue",
"theme": "fint"
},
"data": [
{
"label": "Bakersfield Central",
"value": "750000",
"displayValue": "Store manager: Victoria"
},
{
"label": "Garden Groove Harbour",
"value": "700000",
"displayValue": "Store manager: Teresa"
},
{
"label": "Los Angeles Topanga",
"value": "690000",
"displayValue": "Store manager: Elvis"
},
{
"label": "Compton-Rancho Dom",
"value": "650000",
"displayValue": "Store manager: Pete"
},
{
"label": "Daly City Serramonte",
"value": "620000",
"displayValue": "Store manager: Reesa"
}
]
}
<html>
<head>
<title>My first chart using FusionCharts Suite XT</title>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></script>
<script type="text/javascript">
FusionCharts.ready(function(){
var fusioncharts = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
id: "myChart",
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Harry's SuperMart: Sales Analysis for Top Five Store Locations",
"subCaption": "YTD",
"yAxisName": "Sales (In USD)",
"numberPrefix": "$",
"showValues": "1",
"plotToolText": "Store location: $label <br> Sales (YTD): $dataValue <br> $displayValue",
"theme": "fint"
},
"data": [{
"label": "Bakersfield Central",
"value": "750000",
"displayValue": "Store manager: Victoria"
}, {
"label": "Garden Groove Harbour",
"value": "700000",
"displayValue": "Store manager: Teresa"
}, {
"label": "Los Angeles Topanga",
"value": "690000",
"displayValue": "Store manager: Elvis"
}, {
"label": "Compton-Rancho Dom",
"value": "650000",
"displayValue": "Store manager: Pete"
}, {
"label": "Daly City Serramonte",
"value": "620000",
"displayValue": "Store manager: Reesa"
}]
}
}
);
fusioncharts.render();
});
</script>
</head>
<body>
<div id="chart-container">FusionCharts XT will load here!</div>
</body>
</html>
The tooltip text for the second chart is configured using tooltip macros. The plotToolText
attribute is used to set a custom tooltip, using macros, and format it, using HTML tags, as shown in the code snippet below:
The table below describes the attribute and macros used in the above example:
Attribute/Macro Name | Description |
---|---|
|
This attribute accepts macros, plain text and HTML tags, as strings to create custom tooltip text for data plots. |
|
This macro represents the data plot, category, connector, and marker labels. |
|
This macro represents the formatted data plot, entity, and marker data values. In the above example it is the data plot value. |
|
This macro represents the value of the displayValue attribute of the |
Other Chart Attributes that Support Tooltip Macros
The table below describes some of the commonly used FusionCharts attributes that take tooltip macros as values to customize tooltip text for the various chart elements.
Attribute Name | Description |
---|---|
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for trend-lines |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for all/individual data plots in a Pareto Chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the target in the horizontal and vertical bullet graphs |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the milestones in Gantt charts |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the data plots in error charts |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the horizontal error bars in error scatter charts |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the vertical error bars in error scatter charts |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the entities in maps |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the markers in maps |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the connectors in maps and the drag-node chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the outliers in the Box and Whisker chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the mean icon in the Box and Whisker chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the standard deviation icon in the Box and Whisker chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the quartile deviation icon in the Box and Whisker chart |
|
Accepts macros, plain text, and HTML tags, as strings, for customizing tooltip text for the mean deviation icon in the Box and Whisker charts |