The graph I created does not expand to the entire screen and does not show the range (units) at the bottom of the graph.
Here is my code:
google.charts.load('current', { packages: ['corechart', 'line'] });
google.charts.setOnLoadCallback(drawLogScales);
function drawLogScales() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'X');
data.addColumn('number', 'Total Entries');
data.addColumn('number', 'Organic Google');
data.addColumn('number', 'Google Ads');
data.addColumn('number', 'Social Media');
data.addRows([
[new Date(2021, 0, 1), 0, 0, 0, 0],
[new Date(2021, 1, 1), 16, 12, 2, 2],
[new Date(2021, 2, 1), 50, 20, 20, 10],
[new Date(2021, 3, 1), 100, 70, 15, 15],
[new Date(2021, 4, 1), 60, 9, 40, 11],
[new Date(2021, 5, 1), 260, 60, 100, 100],
[new Date(2021, 6, 1), 500, 300, 100, 200],
[new Date(2021, 7, 1), 1000, 700, 200, 100],
[new Date(2021, 8, 1), 250, 220, 30, 0],
[new Date(2021, 9, 1), 700, 400, 250, 50],
[new Date(2021, 10, 1), 1300, 700, 400, 200],
[new Date(2021, 11, 1), 700, 500, 120, 80],
[new Date(2022, 0, 1), 1400, 1000, 340, 60],
[new Date(2022, 1, 1), 1936, 903, 1000, 33],
[new Date(2022, 2, 1), 2100, 1000, 400, 700],
[new Date(2022, 3, 1), 2345, 1243, 1000, 102],
[new Date(2022, 4, 1), 2000, 1500, 300, 200],
[new Date(2022, 5, 1), 890, 300, 90, 500]
]);
var options = {
height: 500,
hAxis: {
title: 'Period',
viewWindow: {
min: new Date(2020, 11, 31),
max: new Date(2022, 5, 3, 1)
},
gridlines: {
count: -1,
units: {
years: { format: ['yyyy'] },
months: { format: ['MMM yyyy'] },
}
},
logScale: true
},
vAxis: {
title: 'Entries',
minValue: 0,
logScale: false
},
colors: ['#2A7AED', '#279846', '#E84133', '#F9BF18']
};
var chart = new google.visualization.LineChart(document.getElementById('entries-number'));
chart.draw(data, options);
}
This is the result:
The result
It’s not clear to me what I’m missing.
- Why does the graph not expand to the end?
- And why am I not shown the years and the month below the graph?
I would appreciate your assistance.