Get rows from data table


#1

Hello guys! I'm struggling to get the rows array from a data table visualization.

First of all: I want to avoid making request to elasticsearch from my backend and compose the result by myself cause I think I can reuse the existing data. I know how to fetch the same data and the query to be used but it's not my desired logic.

If I have one or more data tables vis already rendered into my view, Is there a way to get rows from the visualizations handler?

EmbeddedVisualizeHandler {
   _element: ...
   _firstRenderComplete: ...
   _listeners: ...
   _scope: ...
}

The problem comes from I want to get the a similar content like when we click in download csv content from saveAs.

As I can see here https://github.com/elastic/kibana/blob/f0cc432fafd6f7053f32d493aba8b576dcb20539/src/ui/public/agg_table/agg_table.js

What I'm looking for is $scope.table.rows, so my question is How to access $scope.table.rows out of the Kibana directive code? I have the visualization object, the handler, etc ..

Thanks in advance,
Jesús


(Tim Roes) #2

Hey,

there is currently no option via the handler and vis loader to reach the data within the visualization. We are also not planning to add such an interface, since we have no knowledge about the data inside the visualization (if it is even using any), it might not be in a tabular format, etc.

Dirty workaround from 6.4 onwards! :radioactive:

There is a dirty workaround, that you can use, if you have access to the Vis instance, which I don't recommend and this might never work in a backward compatible manner. If you've got access to the Vis instance of that visualization, you can use the attached data adapter, which is used to log the data for the inspector and get your data from it, something like that:

vis.API.inspectorAdapters.data.getTabular()

Which would return a promise that resolves with a table of the data. But since we are not making any guarantee on this API the format might change in upcoming versions (though no current plans to do so).

Cheers,
Tim


#3

Ok Tim thanks for your response. One more thing, Have you got a raw response parser implemented? I need to implement one by myself but I think you could have something into your code which parse an elastic raw response from a data table request...

Thanks in advance,
Jesús


(Tim Roes) #4

Hi,

you can try having a look at tabify which is what we are currenlty using. But you should neither consider that a public API. In fact we know we'll change the output format in one of the upcoming versions (https://github.com/elastic/kibana/issues/20197).

Cheers,
Tim


#5

Yep, I was looking into it hahaha. Thanks Tim I'll write here again if I'm facing troubles.
BTW awesome work with Kibana.

Regards,
Jesús


(system) #6

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