Google Chart - Showing different dates

Asked

Viewed 513 times

1

I’m developing some test with the google Chart API.
And I’m having a somewhat 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);

Upshot

inserir a descrição da imagem aqui

As you can see in the X-axis it displays, correct the date informed, however the label is showing 1day retroactive.

If you notice in this test you still have the column with role : 'annotation', in which I had to put the hours to keep on the day of the X-axis, if I remove the hours until the same annotation retroactive display.

Jsfiddle

http://jsfiddle.net/r1q245Lj/

Does anyone know if any configuration should be made to resolve this?
I’ve done a lot of research and I haven’t found anything about it.

1 answer

0


Solution

Alternative 1:

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

Alternative 2:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.