I'm pretty new to PHP and was given a project that uses Google Visualization. In the code below, how do I permanently display the data values and data points on the line chart?
Things I've tried:
1. Setting pointSize
to some value
2. Setting dataOpacity
to 1
3. Adding this annotation column <? php echo {type: 'string', role: 'annotation'} ?>,
as suggested here: Google Charts API: Always show the Data Point Values using arrayToDataTable. How?
but gota server error instead. I'm probably doing this wrong.
Appreciate your help. Thanks!
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Payout Ratio'],
[<?php echo json_encode(date('Y', strtotime('-1 year'))); ?>, <?php echo json_encode($oneYearAgoPayoutRatio); ?>],
[<?php echo json_encode(date('Y', strtotime('-2 year'))); ?>, <?php echo json_encode($twoYearsAgoPayoutRatio); ?>],
[<?php echo json_encode(date('Y', strtotime('-3 year'))); ?>, <?php echo json_encode($threeYearsAgoPayoutRatio); ?>],
[<?php echo json_encode(date('Y', strtotime('-4 year'))); ?>, <?php echo json_encode($fourYearsAgoPayoutRatio); ?>],
[<?php echo json_encode(date('Y', strtotime('-5 year'))); ?>, <?php echo json_encode($fiveYearsAgoPayoutRatio); ?>]
]);
var options = {
chart: {
title: 'Payout Ratio',
},
backgroundColor: '#fafbfc',
colors: ['#3073b5'],
};
var chart = new google.charts.Line(document.getElementById('payout_ratio'));
chart.draw(data, google.charts.Line.convertOptions(options));
}
google.charts.Line
) vs. a Classic (google.visualization.LineChart
) -- there are a number of options that are not supported by Material, includingpointSize
&dataOpacity
, as well as column roles (annotations), see --> Tracking Issue for Material Chart Feature Parity... – WhiteHat