When you use the datetime type of value, this is a 'continuous' type of
value, so the chart uses the value to compute the position on along the
axis.  Therefore, all the April 11 values will therefore end up at the same
horizontal position, so this is correct.  If you, instead, want to treat
each entry discretely regardless of its value, then convert the values to
strings.

It doesn't help to specify the formatted representation of the value, which
is always a string.  You'll have to change your column type to string, and
convert the values to strings when you put them into the data table.

A side effect of doing this conversion is that your minValue, maxValue, and
viewWindow.max options won't work, at least not with dates, since it no
longer knows about the values as dates.  You can actually use the index of
the discrete values, such that the first value is at index 0, second at
index 1, etc.

Hope that provides enough clues to work out the solution.



On Mon, Apr 14, 2014 at 11:11 AM, Missy <[email protected]> wrote:

> Hi,
>
> I am trying to get the line chart to plot duplicate dates along the x-axis
> but all the 11 April points are plotted in one line, instead of spread
> frequency on the x-axis.  I have added dateFormatter but I am not sure
> where I may be going wrong.
>
> This is what I currently have:
>     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('datetime', 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, 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);
>     }
>
> And this the output I am getting:
>
>
> <https://lh5.googleusercontent.com/-1qK8hNE1rns/U0v6ptzPqKI/AAAAAAAAAQA/UyibP9vFnwA/s1600/april_duplicate_date.png>
>
>
> Could anyone please advice any feedback.  Many 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.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>  -
978-394-1058
[email protected] <[email protected]>   5CC, Cambridge MA
[email protected] <[email protected]> 9 Juniper Ridge
Road, Acton MA

-- 
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.

Reply via email to