grafana / piechart-panel

Pie Chart Panel Plugin
MIT License
151 stars 102 forks source link

Cannot read property 'length' of undefined (influxdb) #113

Open shawafts opened 6 years ago

shawafts commented 6 years ago

Query: SELECT top(total, router,10) FROM (SELECT sum("value") as total FROM "autogen"."sessions" WHERE $timeFilter GROUP BY "router") Format As: Table

TypeError: Cannot read property 'length' of undefined at a.isMsResolutionNeeded (http://192.168.75.40/public/app/boot.8fcdddf2.js:29:26428) at new a (http://192.168.75.40/public/app/boot.8fcdddf2.js:29:23352) at PieChartCtrl.seriesHandler (http://192.168.75.40/public/plugins/grafana-piechart-panel/piechart_ctrl.js?bust=1512049737347:168:26) at Array.map () at PieChartCtrl.onDataReceived (http://192.168.75.40/public/plugins/grafana-piechart-panel/piechart_ctrl.js?bust=1512049737347:161:36) at f.emit (http://192.168.75.40/public/app/boot.8fcdddf2.js:62:13409) at a.emit (http://192.168.75.40/public/app/boot.8fcdddf2.js:62:15727) at PieChartCtrl.b.handleQueryResult (http://192.168.75.40/public/app/boot.8fcdddf2.js:56:15010) at i (http://192.168.75.40/public/app/boot.8fcdddf2.js:52:15288) at http://192.168.75.40/public/app/boot.8fcdddf2.js:52:15710

If I change the format as time series, it only displays one type of value where as the actual response contains more. The same query works fine if the panel is of type Table.

valavanraja commented 6 years ago

also facing similar issue

moriawan commented 6 years ago

Facing similar issue

Panel data error: TypeError: Cannot read property 'length' of undefined
    at t.isMsResolutionNeeded (time_series2.ts:238)
    at new t (time_series2.ts:60)
    at PieChartCtrl.seriesHandler (piechart_ctrl.js:92)
    at Array.map (<anonymous>)
    at PieChartCtrl.onDataReceived (piechart_ctrl.js:86)
    at o.emit (index.js:129)
    at t.emit (emitter.ts:13)
    at PieChartCtrl.e.handleQueryResult (metrics_panel_ctrl.ts:297)
    at u (angular.js:17051)
    at angular.js:17095
jganseman commented 6 years ago

Same issue here, using a local PostGreSQL backend on Windows 7 x64 with a query of the form:

  SELECT
      rating,
      COUNT (rating) AS total
  FROM myTable
  WHERE rating IS NOT NULL
  GROUP BY (rating)

Full error looks like:

TypeError: Cannot read property 'length' of undefined
    at t.isMsResolutionNeeded (http://localhost:8080/public/build/0.be20b78823b4c9d93a84.js:1:8586)
    at new t (http://localhost:8080/public/build/0.be20b78823b4c9d93a84.js:1:5491)
    at PieChartCtrl.seriesHandler (http://localhost:8080/public/plugins/grafana-piechart-panel/piechart_ctrl.js:171:26)
    at Array.map (<anonymous>)
    at PieChartCtrl.onDataReceived (http://localhost:8080/public/plugins/grafana-piechart-panel/piechart_ctrl.js:164:36)
    at o.emit (http://localhost:8080/public/build/vendor.ebd7fde2922615864fb4.js:15:520749)
    at t.emit (http://localhost:8080/public/build/app.5331f559bd9a1bed9a93.js:1:29217)
    at PieChartCtrl.e.handleQueryResult (http://localhost:8080/public/build/0.be20b78823b4c9d93a84.js:7:19860)
    at u (http://localhost:8080/public/build/vendor.ebd7fde2922615864fb4.js:43:68722)
    at http://localhost:8080/public/build/vendor.ebd7fde2922615864fb4.js:43:69127
bhaskarbanerjee commented 6 years ago

Has this been resolved ? OR Is there a workaround? I have a similar query as does @jganseman , connecting grafana with Postgres.

suikast42 commented 6 years ago

+1

JamesYangJian commented 6 years ago

Same error as below: TypeError: Cannot read property 'length' of undefined at e.isMsResolutionNeeded (http://10.196.12.26:3000/public/build/app.a4b7f5a163ea89ff6420.js:1:17556) at new e (http://10.196.12.26:3000/public/build/app.a4b7f5a163ea89ff6420.js:1:14461) at PieChartCtrl.seriesHandler (http://10.196.12.26:3000/public/plugins/grafana-piechart-panel/piechart_ctrl.js:171:26) at Array.map () at PieChartCtrl.onDataReceived (http://10.196.12.26:3000/public/plugins/grafana-piechart-panel/piechart_ctrl.js:164:36) at o.emit (http://10.196.12.26:3000/public/build/vendor.2c3c591224fb193f7fd3.js:44:25321) at e.emit (http://10.196.12.26:3000/public/build/app.a4b7f5a163ea89ff6420.js:1:13162) at PieChartCtrl.e.handleQueryResult (http://10.196.12.26:3000/public/build/0.2ba40e7163b7f9a6ed4b.js:7:18131) at u (http://10.196.12.26:3000/public/build/vendor.2c3c591224fb193f7fd3.js:92:69119) at http://10.196.12.26:3000/public/build/vendor.2c3c591224fb193f7fd3.js:92:69565

arianitu commented 6 years ago

+1

arianitu commented 6 years ago

It appears that the Pie Chart can only handle time series data, if you look at the handler:

    this.series = dataList.map(this.seriesHandler.bind(this));
    this.data = this.parseSeries(this.series);
    this.render(this.data);
  }

  seriesHandler(seriesData) {
    var series = new TimeSeries({
      datapoints: seriesData.datapoints,
      alias: seriesData.target
    });

    series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);
    return series;
  }

It's looking for seriesData.datapoints, which doesn't appear to exist when using Table as the Format As option, it probably only works with Format As Time series (I'm using Postgres instead of Influx, but I assume you have Table Query selected instead of Time Series)

In the case where there are rows and columns returned, there are no datapoints, just seriesData.rows

liangway commented 6 years ago

+1

seanlook commented 6 years ago

+1

kaiterramike commented 6 years ago

The workaround I used was to use Format As: Time Series, name your fields according to what the plugin expects, then insert a dummy time_sec field using now():

SELECT
    UNIX_TIMESTAMP(NOW()) AS time_sec,
    ifnull(some_field, 'unknown') as metric,
    COUNT(some_other_field) as value
FROM
    ...

The ifnull() and COUNT() are just for color in this example.

chershma commented 6 years ago

I had this issue with elastic query and solved it by performing the first group-by on my field and then another group by on date histogram. probably not a good solution for everyone.

Slach commented 4 years ago

same issue for "table" format in Clickhouse Grafana data source

gsouf commented 4 years ago

This issue literally breaks grafana ui.

image

@torkelo sorry to bug you - just seems to be a long forgoten issue

hougli commented 3 years ago

I had this issue with elastic query and solved it by performing the first group-by on my field and then another group by on date histogram. probably not a good solution for everyone.

I found pie chart only works for time series data too. But this solution will litttlely differ from original requirements.
I think the ultimate solusion is to enable pie chart on general groups-like data,can anyone give some directions?