I am using the google line chart to show some details. The x-axis is in DateTime format and the following are the data,
As you can see there are two dates from March and the other details are from May.
The resulting Line chart is as follows,
in the X-axis there is extra Apri filed so the chart goes straight and I want to remove this April and show only relevant time lapses. Is there any way to remove or hide the months which does not contain any value?
My code:
function SalesbyDay() {
$.ajax({
type: 'POST',
url: 'ChartDemo.aspx/SalesbyDay',
dataType: 'json',
data: '{"pageSession":"' + $("#hdnPageSession").val() + '"}',
contentType: 'application/json',
success: function (data) {
dataValues = data.d;
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'date');
data.addColumn('number', 'SalesValue');
var mindate = eval(dataValues[0].date.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
var maxdate = eval(dataValues[dataValues.length - 1].date.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
for (var i = 0; i < dataValues.length; i++) {
var sdate = dataValues[i].date;
var newDate = eval(sdate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
data.addRow([
newDate,
dataValues[i].SalesValue
]);
}
var chart = new google.visualization.LineChart(document.getElementById('chartdiv2'));
var options = {
legend: { position: 'top', alignment: 'start' },
hAxis: {
viewWindow: {
min: mindate,
max: maxdate
},
gridlines: {
count: -1,
units: {
days: { format: ['MMM dd'] },
hours: { format: ['HH:mm', 'ha'] },
}
},
minorGridlines: {
units: {
hours: { format: ['hh:mm:ss a', 'ha'] },
minutes: { format: ['HH:mm a Z', ':mm'] }
}
}
},
};
chart.draw(data, options);
}
});
}
Please help.

