google / google-visualization-issues

288 stars 35 forks source link

charts display improperly when only a single row of data is used on a continuous axis #1255

Open orwant opened 9 years ago

orwant commented 9 years ago
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
1. populate a DataTable with one row of data, where the domain column is a continuous
data type (date, datetime, timeofday, number)
2. create a Bar, Column, or Candlestick chart and draw it with the DataTable

In the production version, the axis values will be wildly off, and the bars won't be
centered in the chart.  In the RC, neither the bars nor the axis values are drawn.

See this in production version (as of 7/4/2013): http://jsfiddle.net/asgallant/EKADZ/
release candidate version (as of 7/4/2013): http://jsfiddle.net/asgallant/EKADZ/1/

Temporary fix is to specify h/vAxis.viewWindow.min/max values; see http://jsfiddle.net/asgallant/EKADZ/4

What component is this issue related to (PieChart, LineChart, DataTable,
Query, etc)?
Bar, Column, and Candlestick charts.  Line, Area, and Scatter charts are also affected
to a lesser extent (the points will render off center with the odd axis values in both
production and RC).

Are you using the test environment (version 1.1)?
(If you are not sure, answer NO)
Problem applies in different ways in each.

What operating system and browser are you using?

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by drew_gallant@abtassoc.com on 2013-07-05 05:20:30

orwant commented 9 years ago
Any update on this one? Having issues and setting the min and max of Axis doesnt resolve
the issue for me

Original issue reported on code.google.com by stacey.burnsy on 2014-04-22 13:32:30

orwant commented 9 years ago
There is a basic ambiguity about what to do here.  With only one row of data, it has
no range of values to infer the viewWindow of the axis.  So for dates, it picks years,
and a range of about 50 years.  It would probably make more sense to pick days, but
maybe not.  The same problem occurs for numbers, but it chooses 1 as the minimum range.

In any case, for unstacked bar, column, and candlestick charts, and now histogram also,
showing extra ticks within the range of one group of bars is, at best, very misleading.
 In fact, for any group of bars, there is no indication of what the value is of the
group, except by proximity to some tick value.  

So perhaps the best thing to do is only show one tick value for one gridline, at the
same exact value as the data row specifies.  There would be no context about the range
of the axis, but no context makes sense in this case.

Original issue reported on code.google.com by dlaliberte@google.com on 2014-04-22 17:36:13

orwant commented 9 years ago
We are also getting same problem for single row of data. It is scattering for 50 years
on x-axis for single row of data of type date.

This is very sad. Is there any fix for this?

Original issue reported on code.google.com by sachin.gangarde on 2014-04-30 08:33:57


orwant commented 9 years ago
The simplest workaround is to specify the viewWindow min and max that you want to see.

The fix I am anticipating is to only show a single tick value for your single row of
data, if there is no explicit viewWindow (or minValue, maxValue, baseline to help provide
context), because we have no context to decide what the "proper" range of data should
be.  How would that be for you?

Original issue reported on code.google.com by dlaliberte@google.com on 2014-04-30 13:15:05

orwant commented 9 years ago
The challenge comes in determining what should be the min and max values should be.

I create a Google table with my data but based on selections from the user, I then
filter the table. 
This means each time i redraw the chart I need to sort the data by the X-Axis and retrieve
the first and last values. 
Once I have these, I minus one month and set that as min and plus one month and set
it as max. (my X is date formatted mm-yyyy ) 
Its a bit of a pain :-) 
The fix you suggest sounds good to me.

Original issue reported on code.google.com by stacey.burnsy on 2014-04-30 15:20:19