In order to get what you want, you have to switch your columns to type 
"date" and "timeofday" instead of number columns.  Here's an example based 
off of your code: http://jsfiddle.net/asgallant/rWrXR/

On Wednesday, May 29, 2013 4:05:38 PM UTC-4, [email protected] wrote:
>
> Hello all-
>
> I'm working on a scatter chart that plots the hour of day on the vAxis and 
> day of the week on the hAxis. To do this, I needed to use the numeric 
> versions of those items (0-24 for hours, 0-6 for days). But for display 
> purposes, I'd like to do proper times for the hours (0=12am, 12=12pm, 
> 13=1pm, etc.) and days (0=Sunday, etc.).
>
> Can anyone offer guidance on how to do this? Using a formatter or running 
> some code to change formatted values does change how the plotted value 
> appears in the tooltip, but it does not change the labels on the axis.
>
> Here's the basic code I am working with:
>
> var data,chart;
> function drawVisualization() {
> var dates=[
> [new Date(Date.parse('March 13, 2013 5:00 AM')),1,'Survey #1'],
> [new Date(Date.parse('March 14, 2013 5:00 AM')),1,'Survey #2'],
> [new Date(Date.parse('March 15, 2013 7:00 AM')),0,'Survey #3'],
> [new Date(Date.parse('March 18, 2013 6:00 PM')),1,'Survey #2']
> ];
> data = new google.visualization.DataTable();
> data.addColumn('number', 'Day of Week');
> data.addColumn('number', 'Success');
> data.addColumn('number', 'Failure');
> for(var i=0;i<dates.length;i++) {
> var dt=dates[i];
> var day=dt[0].getDay()+1;
> var hour=dt[0].getHours();
> if (dt[1]==1) data.addRow([day,hour,null]);
> else data.addRow([day,null,hour]);   
> }; 
>  // Format data
> for(var i=0;i<data.getNumberOfRows();i++){
>   var hour=data.getValue(i,0);
>   data.setFormattedValue(i,0,hour+'AM');
> }
>
> // Create and draw the visualization.
> chart = new 
> google.visualization.ScatterChart(document.getElementById('chart_div')); 
> var options = {
> title: 'Contact Success',
> colors: ['#00FF00','#FF0000'],
> hAxis: {title: 'Day of Week', minValue:1, maxValue:7, gridlines: { count: 
> 7 }  },
> vAxis: {title: 'Hour of Day', minValue:0, maxValue:24 }
> };
> chart.draw(data, options);
> }
>
> Thanks in advance for any ideas you may have.
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to