Google Chart - Displaying Different Dates

1

I'm developing some testing with the google chart API. And I'm having a rather peculiar problem.

Code

data = new google.visualization.DataTable();

data.addColumn({ type : 'date', label : 'Day' });
data.addColumn({ type : 'date', label : 'DayAnnotation', role : 'annotation' });
data.addColumn({ type : 'number', label : 'Total' });
data.addColumn({ type : 'number', label : 'Frete' });

data.addRow([ new Date('2015-06-01'), new Date('2015-06-01T23:00'), 24974.46, 10871 ]);
data.addRow([ new Date('2015-06-02'), new Date('2015-06-02T23:00'), 26075.61, 12485 ]);
data.addRow([ new Date('2015-06-03'), new Date('2015-06-03T23:00'), 41915.09, 22489 ]);

var options = {
    title : 'Monthly Coffee Production by Country',
    vAxis :  { title : 'Cups' },
    hAxis :  { title : 'Month' },
    seriesType : 'bars',
    series : { 5: { type : 'line' } },
    width : 500,
    height : 300,
};

chart = new google.visualization['ComboChart'](Element);
chart.draw(data, options);

Result

AsyoucanseeontheX-axisitdisplays,correctthedateentered,howeveronthelabelitisdisplayed1dayretroactive.

Ifyounoticeinthistestthereisstillthecolumnwithrole:'annotation',inwhichIhadtobythehourstostayonthedayoftheXaxis,ifyouremovethehoursuntilthesameas%with_of%displaysretroactive.

Jsfiddle

link

Does anyone know if any configuration should be done to resolve this?
I've done a lot of research and found nothing about it.

    
asked by anonymous 02.07.2015 / 14:26

1 answer

0

Solution

Alternative 1:

The date must be specified by parameters: new Date(2015,05,01) . Note that the months range from 0 to 11 being January - December.

Alternative 2:

The date must contain T00:00:00 : new Date('2015-06-02T00:00:00') . Note that it should not contain the Z format at the end.

    
02.07.2015 / 15:26