Your column 3 is a "string" type column, not a "date" type column, so you
can't use a DateFormatter on it. If you need to store the string instead
of a Date object, you can use this (assuming that column 3 contains Unix
timestamps) to get the format you want:
view.setColumns([{
type: 'string',
label: data.getColumnLabel(3),
calc: function (dt, row) {
var date = new Date(parseInt(dt.getValue(row, 3));
return dateFormatter.formatValue(date);
}
}, 1]);
On Wednesday, April 16, 2014 8:44:58 AM UTC-4, Missy wrote:
>
> Dear all,
>
> I have a tooltip property setup in my line chart control, but I cannot get
> it to show correct date output format, instead it shows as ' Date : NaN'.
> Is their a property in the api documentation, i need to add to resolve
> this issue.
>
>
> function drawVisualization(dataValues, chartTitle, columnNames,
> categoryCaption) {
> if (dataValues.length < 1)
> return;
>
> var data = new google.visualization.DataTable();
> data.addColumn('string', columnNames.split(',')[0]);
> data.addColumn('number', columnNames.split(',')[1]);
> data.addColumn('string', columnNames.split(',')[2]);
> data.addColumn('string', columnNames.split(',')[3]);
> data.addColumn('number', columnNames.split(',')[4]);
>
> for (var i = 0; i < dataValues.length; i++) {
> //var date = new Date(parseInt(dataValues[i].Date.substr(6),
> 10));
>
> data.addRow([dataValues[i].ColumnName, dataValues[i].Value,
> dataValues[i].Type, dataValues[i].Date, dataValues[i].ID]);
> }
>
> // Define a Pie chart
> var pie = new google.visualization.ChartWrapper({
> 'chartType': 'LineChart',
> 'containerId': 'PieChartContainer',
> 'options': {
> 'width': 950,
> 'height': 450,
> 'legend': 'right',
> 'hAxis': {
> 'format': "dd-MMM-yyyy",
> 'hAxis.maxValue' : 'viewWindow.max',
> 'maxValue': new Date (2014, 04, 17), 'minValue': new Date
> (2014, 03, 20),
> 'viewWindow':{'max': new Date (2014, 04, 17)},
> },
> 'title': chartTitle,
> 'chartArea': { 'left': 100, 'top': 100, 'right': 0,
> 'bottom': 100 },
> 'tooltip': { isHtml: true }
> },
> 'view': {
> 'columns': [3, 1, {
> type: 'string',
> role: 'tooltip',
> calc: function (dt, row) {
> return 'Name: ' + dt.getValue(row, 0) + ', Decimal
> Price: ' + +dt.getValue(row, 1) + ', Date: ' + +dt.getFormattedValue(row,
> 3);
> }
> }]
> }
> });
>
> var dateFormatter = new google.visualization.DateFormat({pattern:
> 'dd MM yyyy'});
> var view = new google.visualization.DataView(data);
> view.setColumns([{
> type: 'string',
> label: data.getColumnLabel(3),
> calc: function (dt, row) {
> return dateFormatter.formatValue(dt.getValue(row, 3));
> }
> }, 1]);
>
> new
> google.visualization.Dashboard(document.getElementById('PieChartExample')).bind([categoryPicker,
>
> stringFilter], [pie]).draw(data);
> }
>
> Any advice or help would be very much appreciated.
> Thanks
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.