jondot/graphene

null datapoint values result in uncaught TypeError for GaugeLabel gadget

Closed this issue · 5 comments

After got data:

Uncaught TypeError: Cannot read property '0' of undefined
Graphene.GaugeLabelView.b.by_typeindex.js:11
__bindindex.js:11
(anonymous function)index.js:11
findex.js:10
bi.dataindex.js:10
Graphene.GaugeLabelView.b.renderindex.js:11
__bindindex.js:11
c.Events.triggerindex.js:8
d.extend.changeindex.js:8
d.extend.setindex.js:8
Graphene.TimeSeries.b.process_dataindex.js:11
__bindindex.js:11
__bindindex.js:11
Graphene.GraphiteModel.b.refreshindex.js:11
d3.jsonindex.js:9
dindex.js:9
d3.xhr.d.onreadystatechangeindex.js:9
index.js:11

It would great if the control could handle a defined min value, or simply display 0 in the event of a return of all null datapoints.

Great catch!
There is a semantic issue here - would '0' be correct at this case?, it is a proper, valid value (e.g. in the case of a dashboard reporting 0 errors, it would lie to me because the first error is that i'm not getting any value from Graphite :).
I personally am leaning towards '-' or not display a value at all. Any thoughts?

I would tend to agree, but it would be GREAT to be able to define the label for null data event. So if I wanted '0' or perhaps 'NA'. In a pinch '-' would be better than bombing on the type error ;)

Agreed, I'll push a fix today / tomorrow.

More info, here is the returned JSON that generated the error:

[{"target": "hitcount(api.access.count, "1min")", "datapoints": [[null, 1330444120], [null, 1330444180], [null, 1330444240], [null, 1330444300], [null, 1330444360], [null, 1330444420], [null, 1330444480], [null, 1330444540], [null, 1330444600], [null, 1330444660], [null, 1330444720], [null, 1330444780], [null, 1330444840], [null, 1330444900], [null, 1330444960], [null, 1330445020], [null, 1330445080], [null, 1330445140], [null, 1330445200], [null, 1330445260], [null, 1330445320], [null, 1330445380], [null, 1330445440], [null, 1330445500], [null, 1330445560], [null, 1330445620], [null, 1330445680], [null, 1330445740], [null, 1330445800], [null, 1330445860], [null, 1330445920], [null, 1330445980], [null, 1330446040], [null, 1330446100], [null, 1330446160], [null, 1330446220], [null, 1330446280], [null, 1330446340], [null, 1330446400], [null, 1330446460], [null, 1330446520], [null, 1330446580], [null, 1330446640], [null, 1330446700], [null, 1330446760], [null, 1330446820], [null, 1330446880], [null, 1330446940], [null, 1330447000], [null, 1330447060], [null, 1330447120], [null, 1330447180], [null, 1330447240], [null, 1330447300], [null, 1330447360], [null, 1330447420], [null, 1330447480], [null, 1330447540], [null, 1330447600], [null, 1330447660]]}]

Tested the fix, resolves my use case!