Kibana plugin: embedded visualization error

Hello,

Based on Peter Pišljar's example (https://www.elastic.co/blog/developing-new-kibana-visualizations), I'm trying to embed a visualization inside my kibana plugin.

My controller looks like this:

app.controller('TestVisApp', function ($scope, Private, serviceSettings) {
  const visContainer = $('.test-vis-app-visualize');
  getVisualizeLoader().then(loader => {
    loader.embedVisualizationWithId(visContainer, '68a473b0-8168-11e8-b601-d5f98337454c',
      {
        timeRange: {
          from: 'now-1y',
          to: 'now'
        }
      });
  });
});

Nevertheless, no matter which visualization id I try, I get the following error:

Uncaught TypeError: Cannot read property 'from' of undefined (https://131.101.126.10:5601/zrq/bundles/vendors.bundle.js?v=8467:1903)

Error: Uncaught TypeError: Cannot read property 'from' of undefined (https://131.101.126.10:5601/zrq/bundles/vendors.bundle.js?v=8467:1903) at window.onerror (https://131.101.126.10:5601/zrq/bundles/commons.bundle.js?v=8467:36474:16)

Here's the browser log:
:5601/zrq/bundles/commons.bundle.js?v=8467:734 Error: Uncaught TypeError: Cannot read property 'from' of undefined (https://131.101.126.10:5601/zrq/bundles/vendors.bundle.js?v=8467:1903)
_ at window.onerror (:5601/zrq/bundles/commons.bundle.js?v=8467:36474)_
Notifier.showFatal @ :5601/zrq/bundles/commons.bundle.js?v=8467:734
:5601/zrq/bundles/vendors.bundle.js?v=8467:1903 Uncaught TypeError: Cannot read property 'from' of undefined
_ at Timefilter.calculateBounds (:5601/zrq/bundles/commons.bundle.js?v=8467:33417)

_ at Timefilter.getBounds (:5601/zrq/bundles/commons.bundle.js?v=8467:33412)_
_ at getUpdateStatus (:5601/zrq/bundles/commons.bundle.js?v=8467:20052)_
_ at Object.callee$ (:5601/zrq/bundles/commons.bundle.js?v=8467:40108)
_ at tryCatch (:5601/zrq/bundles/vendors.bundle.js?v=8467:193098)_
_ at Generator.invoke [as invoke] (:5601/zrq/bundles/vendors.bundle.js?v=8467:193336)
_ at Generator.prototype.(anonymous function) [as next] (https://131.101.126.10:5601/zrq/bundles/vendors.bundle.js?v=8467:193150:21)_
_ at step (:5601/zrq/bundles/commons.bundle.js?v=8467:40003)_
_ at :5601/zrq/bundles/commons.bundle.js?v=8467:40003_
:5601/zrq/bundles/commons.bundle.js?v=8467:698 Uncaught Error: Uncaught TypeError: Cannot read property 'from' of undefined (https://131.101.126.10:5601/zrq/bundles/vendors.bundle.js?v=8467:1903)
_ at window.onerror (:5601/zrq/bundles/commons.bundle.js?v=8467:36474)_
:5601/zrq/bundles/commons.bundle.js?v=8467:1010 tabify agg response
:5601/zrq/bundles/commons.bundle.js?v=8467:1006 complete in 0.90ms

Any ideas?
I am using Kibana 6.2.1 and Elasticsearch 6.2.1.

Thanks in advance,
Arturo.

1 Like

Hm. It's hard to tell from that stacktrace. It looks like you're running your plugin in a production release of Kibana, which doesn't produce very easy stack traces for debugging purposes. I'd suggest pulling down Kibana's source code and running your plugin inside of that:

That'll help you pinpoint the source of the error.

Chris,

thanks for your response.

I am running in kibana's development code. Any other thing I can try?

This is how the fatal error is shown:

Thanks.
Arturo.

Ah. Wow, that's not a great stacktrace! Well, if you're running in dev-mode, you should have sourcemaps available if you pull up your browser's dev tools. Here's a link to how to pull those up for Chrome:

If you open your dev tools, then refresh the page, you should see something in the console that pinpoints the source. I generally start poking around with breakpoints and console.logs until I track down the issue. I don't think there's a quick answer to your question. It'll require some digging in the dev tools to figure out where the problem lies.

Chris,

Sorry if I was not clear, by browser log above I meant the logging in Chrome's DevTools.
The first error occurs when the loader.embedVisualizationWithId is called.

Any ideas?

Hi Arturo, sorry for the late response.

Did you ever solve this?

I don't have ideas other than to start putting debug console logs into your code to find out where it's going wrong. it sounds like it's trying to access a property "from" on an undefined time range, but it's not clear from the error whether that invalid access is happening in your visualization or in Kibana itself.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.