I use the SHORT format my Google Column Chart. This format works great and it saves space for the bar. However, I like to show the actual number like 1180 instead of 1.2K when user hover the mouse over the bar. Currently, it shows the SHORT format number when user hovers the bar. Is that possible to show actual when hover, but keep the SHORT format for the bar display?
Thanks in advance,
Fiddle: https://jsfiddle.net/milacay/bq1srvdg/24/
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var array = [
["", "Today Hrs", "Goal Hrs"],
["Title1", 4553, 4151],
["Title2", 5560, 6150],
["Title3", 850, 920],
["Title4", 10505, 12320]
];
var data = new google.visualization.arrayToDataTable(array);
var formatter = new google.visualization.NumberFormat({
//prefix: '$',
pattern : 'short'
});
formatter.format(data, 1);
formatter.format(data, 2);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, {
calc : "stringify",
sourceColumn : 1,
type : "string",
role : "annotation"
},
2, {
calc : mystringy.bind(undefined, 2),
sourceColumn : 2,
type : "string",
role : "annotation"
},
]);
var options = {
vAxis : {
format : 'short',
title : 'Progress To-Date',
//viewWindowMode:'explicit',
//viewWindow: {
// max: 50,
// min:0
//},
gridlines : {
count : 8
}
},
chartArea : {
right : 0,
width : "80%",
height : "80%"
},
bar : {
groupWidth : 70 // Set the width for each bar
},
annotations : { // Setting for font style format of the bar series...
textStyle : {
fontName : 'Times-Roman',
fontSize : 10,
}
},
width : 500,
height : 500,
bars : 'vertical',
};
var chart = new google.visualization.ColumnChart(document.getElementById('classic_div'));
//chart.draw(data, options);
chart.draw(view, options);
}
function mystringy(column, data, row) {
return ' ' + data.getFormattedValue(row, column);
}