google / google-visualization-issues

288 stars 35 forks source link

Bug: JSON conversion failing for vertical axis value labels #1861

Open orwant opened 9 years ago

orwant commented 9 years ago
1. Create spread sheet 2 cols, in my case xaxis = date, yaxis = number
2. Load spreadsheet into column chart via query
3. copy JSON from chrome console via 'console.log( data.toJSON() );'
4. store JSON in file, and load same chart but from the JSON data.

The result will cause all the value labels up the vertical axis to be NaN,
the data points in the chart are still correct.

Column chart, using prototype.js.

Are you using the test environment (version 1.1)?
No

What operating system and browser are you using?
Windows XP Chrome

*********************************************************
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 kristrygg on 2015-02-12 16:32:01

orwant commented 9 years ago
Sorry, should add - here is a vaxis label after the conversion - it's actually the x
and width attributes that are NaN

<rect x="NaN" y="169" width="NaN" height="12" stroke="none" stroke-width="0" fill-opacity="0"
fill="#ffffff"></rect>

Original issue reported on code.google.com by kristrygg on 2015-02-12 16:37:08

orwant commented 9 years ago
Thanks for your report.  I am curious what happens if you load 1.1, since we did some
work to make the treatment of nulls and NaNs work more consistently, especially regarding
the JSON notation.

Original issue reported on code.google.com by dlaliberte@google.com on 2015-02-12 16:45:47

orwant commented 9 years ago
Also, could you include what your data.toJSON() output is.  Thanks.

Original issue reported on code.google.com by dlaliberte@google.com on 2015-02-12 16:48:11

orwant commented 9 years ago
Hi, thanks for the quick response.

Loaded 1.1 and I'm not seeing a difference. I've attached the JSON I'm working from,
extract of my code follows:

var graphObj = this.graphs[index];
var data;

// debug just swaps to accept the query response from the sheet or the data from the
loaded JSON    
if( this.debug )
   data = response.getDataTable();
else
   data = new google.visualization.DataTable( graphObj.data );

var element = document.getElementById(graphObj.element.id);
var chart; 

switch( graphObj.settings.type )
{
    case 'ColumnChart': chart = new google.visualization.ColumnChart(element);break;
    case 'LineChart': chart = new google.visualization.LineChart(element);break;
}

var options = {
   title: 'test',
   width:500,
   height:350,
   vAxis: { title: "Number"},
   legend:{ position:'top',alignment:'start'},
   hAxis: {
        title: "Date",
        format: 'dd-MM-yy',
        gridlines:{ count:16 },
        slantedText:true,
        slantedTextAngle:90

      }
};

chart.draw(data, options); 

Original issue reported on code.google.com by kristrygg on 2015-02-12 17:07:11


orwant commented 9 years ago
It appears to be a bug with prototype.js 1.6 conflicting with Google Charts, the JSON
is fine and works with prototype 1.7.

Is there anyway to get around this? I can't deploy prototype 1.7 on our server at the
moment.

Original issue reported on code.google.com by kristrygg on 2015-02-16 16:42:31