I want to change the equation parameters label (only) from Age and Diameter to Y and X
from (Age = 4.885 * Diameter + 0.73) to (Y = 4.885 * X + 0.73)
in the title and inside the tooltip.
google.charts.load('current', {
callback: drawChart,
packages:['corechart']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Diameter', 'Age'],
[8, 37], [4, 19.5], [11, 52], [4, 22], [3, 16.5], [6.5, 32.8], [14, 72]]);
var options = {
title: 'Age of sugar maples vs. trunk diameter, in inches',
hAxis: {title: 'Diameter'},
vAxis: {title: 'Age'},
legend: {
alignment: 'end',
position: 'top'
},
series: {
0: {
visibleInLegend: true
}
},
trendlines: {
0: {
visibleInLegend: true
}
}
};
var container = document.getElementById('chart_div');
var chart = new google.visualization.ScatterChart(container);
google.visualization.events.addListener(chart, 'ready', function () {
var equation = $('text[text-anchor="start"][fill="#222222"]').text();
console.log(equation);
});
chart.draw(data, options);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
can some one help me please ?
there are no standard options,
you would need to change manually on the chart's
'ready'event.but it might be easier to change the column labels to
'X', 'Y',then manually change the title of the series to
'Age'...see following working snippet...
EDIT
to display
'Age'as the series title in the tooltip,you can use a custom tooltip.
here, a data view is used to add the tooltip column.
see following working snippet...