I am working on angularjs google charts. I want to customize the tooltip. In my tooltip i want to show the multiple series data as well as some text as shown in the demo https://plnkr.co/edit/orQchHKMeErVesXW2M0u?p=preview I want to see the legend and the title of the value beside the value displayed in the tooltip as shown in the https://plnkr.co/edit/6iw39IRFY7mwdQzjAVR6?p=preview
In the above plunker, i'm not customizing the tooltip and so it works as expected but when i customized the text in tooltip as shown in first plunker link(replaced First Series with Jan - July ...) the tooltip is not shown as expected. Any advices?
js code:
'use strict';
angular.module('google-chart-example', ['googlechart']).controller("MainCtrl", function ($scope) {
var createChart = function (rows, label) {
return {
"type": "ColumnChart",
"data": {
"cols": [
{"id": label, "label": label, "type": "string"},toolTipVar,
{"id": "count", "label": "count", "type": "number"},
{"id": "pizza", "label": "Pizza", "type": "number"},
{"id": "softdrink", "label": "Softdrink", "type": "number"}
],
"rows": rows
},
"options": {
"title": label,
"isStacked": "true",
focusTarget: 'category',
// "displayExactValues": true
"tooltip": {'text' : 'value' },
}
}
};
var toolTipVar = {
role: "tooltip",
type: "string",
p: {
'html': true
}
};
var data = [
{"c":[{"v":"First Series"},{"v":"Jan - July" + "\n" + "63" + "\n" + "30" + "\n" + "33"},{"v":63},{"v":"30"},{"v":"33"}]},
{"c":[{"v":"Second series"},{"v":"Aug - Sept" + "\n" + "70" + "\n" + "35" + "\n" + "35"},{"v":70},{"v":"35"},{"v":"35"}]},
{"c":[{"v":"Third series"},{"v":"Oct - Dec" + "\n" + "80" + "\n" + "40" + "\n" + "40"},{"v":80},{"v":"40"},{"v":"40"}]}
];
$scope.myChart = createChart(data, "Data Series");
});
if you use a continuous axis (
'number'
,'date'
,'timeofday'
, etc...) for the first column,you can provide the tooltip value as the formatted value (
f:
)then use
hAxis.ticks
for the axis labelsuse the same object notation to set the label value
other options are included in the following snippet,
to format the chart similar to using a discrete axis (
'string'
)UPDATE
placing the above changes in angular...