2
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Day');
data.addColumn('number', 'AVG Position');
data.addRows([
[new Date('2015-04-14'),2.3],
[new Date('2015-04-13'),2.6],
[new Date('2015-04-12'),2.7],
[new Date('2015-04-11'),2.8],
[new Date('2015-04-10'),2.7],
[new Date('2015-04-09'),2.6],
[new Date('2015-04-08'),0.0],
[new Date('2015-04-07'),0.0],
[new Date('2015-04-06'),2.7],
[new Date('2015-04-05'),2.2]
]);
var formatadata = new google.visualization.DateFormat({pattern: 'dd/MM', timeZone: 0}).format(data, 0);
var options = {
title: 'AVG Position',
theme: 'maximized',
chartArea: {width: '100%', height: '100%'},
legend: {position: 'none'},
width: 600, height: 250,
hAxis: { format: 'dd/MM' },
pointSize: 5
};
chart = new google.visualization.AreaChart(document.getElementById('chart')).draw(data, options);
}
drawChart();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
</script>
<div id="chart"></div>
Problems:
1) The line is very glued at the top, necessary to pass the mouse to get an idea of what the highest values are. Even taking away the Settings of Theme and chartarea, the graph remains glued to the top. I would like to leave a slack to improve the graph view. I could set a value using max and min, but the values are not predefined.
2) Does not show start and end date, already tried with showEvery:1 and nothing.
the top and left just reposition Chart inside the div, having no practical effect.
– Eduardo Ferreira
TOP does not 'detach' the Top Hart, avoiding sticking together ?
– Diego Souza
the post has been edited, the code included and the fiddle has been removed. Look how strange is the graphic: https://jsfiddle.net/snkfqfhy/
– Eduardo Ferreira
I did a gambiarra
vAxis: { maxValue: (data.getColumnRange(1).max + (data.getColumnRange(1).max / 10))},
– Eduardo Ferreira
It can be like this:
title: 'AVG Position',
chartArea: {top: 20},
hAxis: { format: 'dd/MM' },
pointSize: 5,
vAxis: {minValue: 0}
– Diego Souza