google areachart cannot access datatable rows -
i'm using google chart api draw area chart. chart represents altimetric profile , when pass mouse on it, shows position (lat , long) underlying data table.
so created chart:
data = new google.visualization.datatable(json); chart = new google.visualization.areachart(document.getelementbyid("chart-output"));
and draw it:
chart.draw(data, options);
and add handler mouseover event
when event triggers, want row underlying data source
if (event.row != null && event.column != null){ //data chart datasource var o = data.d[event.row]; var sel_x = o.c[0]["coords"]["x"]; var sel_y = o.c[0]["coords"]["y"]; ... //show x, y }
the point when project first released, last year, worked fine , property data.d
contained desired value. now, i've found same property undefined , rows array found in property data.tf
.
i expect gain access datasource rows through getter method, cannot find right one. datatable method ǵetrowproperties(rowindex)
not provide content.
what doing wrong?
thanks , regards
**edit 12/09 **
@juvian yr reply, it's bit more complicated that. datasource this:
{"cols": [ {"id":"distance","label":"distance","type":"number"}, {"id":"asfaltocemento","label":"asphalt/beton","type":"number"}, {"id":"rocciaghiaia","label":"fels/schotter","type":"number"}, {"id":"ghiaccio","label":"eis","type":"number"}, {"id":"terraprato","label":"erde/wiese","type":"number"}, {"id":"sassolastricato","label":"stein/pflaster","type":"number"}, {"id":"sconosciuto","label":"unbekannt","type":"number"}], "rows": [ {"c":[{"v":0,"coords": {"x":1296400.1245177952,"y":5885847.104437432,"z":1345.275458520788,"segment_no":0}},{},{"v":1345.275458520788},{},{},{},{}]}, {"c":[{"v":2.8740587294156668,"coords":{"x":1296395.9416741736,"y":5885847.412533606,"z":1345.4754191288682,"segment_no":0}},{},{"v":1345.4754191288682},{},{},{},{}]}, {"c":[{"v":17.583008965075226,"coords":{"x":1296374.532888888,"y":5885848.966197753,"z":1346.3169989102385,"segment_no":0}},{},{"v":1346.3169989102385},{},{},{},{}]}, {"c":[{"v":23.830815143830804,"coords":{"x":1296365.4205057025,"y":5885849.273363226,"z":1346.724445260275,"segment_no":0}}, {},{"v":1346.724445260275},{},{},{},{}]}, .... ]}
when event graphic, retrieve needed values way:
var o = data.tf[event.row]; var sel_x = o.c[0]["coords"]["x"]; var sel_y = o.c[0]["coords"]["y"];
i know it's not practise use property (tf) , should use accessor getvalue(), using getvalue method can't access 'coords' object , subobject.
any appreciated
well, data.d not public method, google can make changes that, should use public methods instead consistency.
try this:
var sel_x = data.getvalue(event.row, 0); // supposing x value in fisrt column var sel_y = data.getvalue(event.row, 1); // supposing y value in second column
more info here: google datatable
Comments
Post a Comment