The y-axis is easy, just set the vAxis.format option to '# Pounds'.
Getting the x-axis formatted correctly depends on how your data is
structured. If you need a continuous axis, then you will have to put your
data in a Date object. If you can get by with a discrete axis, then you
can put the data in string format. Either way, you will need to use a
DataView with a calculated column for the date. To get the data in Date
object form, use this:
var view = new google.visualization.DataView(data);
var baseDate = /*date to start from, in ms from the Unix Epoch (Jan 1, 1970
00:00:00:000 GMT)*/;
view.setColumns([{
type: 'date',
label: 'Date',
calc: function (dt, row) {
// get ms from minutes
var ms = dt.getValue(row, 0) * 60000;
return new Date(baseDate + ms);
}
}, 1]);
to get it in string format use this:
var view = new google.visualization.DataView(data);
// assumes the DataTable contains the formatted date value
view.setColumns([{
type: 'string',
label: 'Date',
calc: function (dt, row) {
return dt.getFormattedValue(row, 0);
}
}, 1]);
Then you draw the chart using the view instead of the dataTable:
chart.draw(view, {/*options*/});
On Tuesday, July 24, 2012 2:53:35 AM UTC-4, Seddi1 wrote:
>
> I need to display the formatted value along the X and Y axis of the chart.
> The trick is I need to use the value (not the formatted one) for all
> calculation purposes of the chart, but I don't want to display this value
> along X and Y axis, instead I want display the formatted value along X and
> Y axis. Right now the formatted value is displayed on mouse over the chart,
> and I also want this formatted value to be displayed along X and Y axis.
>
> For example:
>
> Date - (X Axis)
>
> Jan 1 2000 (Formated Value), 2,220,0000 (Value in minutes
> corresponding to this date which should be used for graph calculation but
> not display)
> Jan 1 2005 (Formatted Value), 2,720,0000 (Value in minutes
> corresponding to this date which should be used for graph calculation but
> not display)
> Jan 1 2010 (Formatted Value), 3,120,0000 (Value in minutes
> corresponding to this date which should be used for graph calculation but
> not display)
>
> Weight (Y Axis)
>
> 100 Pounds (Formatted Value), 100 (Value which should be used for
> graph calculation but not display)
> 140 Pounds (Formatted Value), 140 (Value which should be used for
> graph calculation but not display)
> 160 Pounds (Formatted Value), 160 (Value which should be used for
> graph calculation but not display)
>
> Current/default behavior that I am seeing when the chart is drawn:
>
> 160 |
> 140 |
> 100 |
> ----------------------------------------------------------------
> 2,220,0000 2,720,0000 3,120,0000
>
> Behavior that I am looking to achieve
>
> 160 Pounds |
> 140 Pounds |
> 100 Pounds |
>
> ----------------------------------------------------------------
> Jan 1 2000 Jan 1 2005 Jan 1 2010
>
> I highly appreciate your help here.
>
> Thanks
> Nvas
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/kKOoueS04JwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.