Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
lukesartain
New Contributor II

Automatically retrieve all data rows

Hi all

I am currently putting together my first extension - a mapping extension that will draw a polyline from the latitude and longitude coordinates taken from a GPX file.   I'm using the leaflet JS library (http://leafletjs.com/) in order to do this.  I have hit a bit of a stumbling block due to the fact that the initial data fetch (qHeight) is limited to 1000 which will only plot part of the route - a 3 hour ride could result in up to 10800 points, for example.  I have this currently:

return {

       initialProperties : {

       version: 1.0,

       qHyperCubeDef : {

       qDimensions : [],

       qMeasures : [],

       qInitialDataFetch : [{

            qWidth : 2,

            qHeight : 1000

       }]

  }

},

The values retrieved are then being added to a JavaScript array ready to plot using the following code:

var dimensions = layout.qHyperCube.qDimensionsInfo,

     qData = layout.qHyperCube.qDataPages[0].qMatrix;

var coords = [];

       $.each(qData, function(rownum, column){

            coords.push(L.latLng(column[0].qText,column[1].qText));

});

A colleague has worked on an algorithm that will reduce the number of data points to be plotted (to speed up the visualisation by removing points when stopped at traffic lights, etc) once the selections are passed to the extension but, as before, I can't figure out how to get +1000 rows.  I notice that the SimpleTable example extension is using the backendApi.getData to get any additional 50 rows each time the more button is clicked so it certainly seems possible.

So, would it be possible to automatically (without the user having to click a more button) retrieve all data points (latitude and longitude coordinates) to add to the JavaScript array ready for creating the polyline using the backendApi?  If so, any hints on how I could do so?

My thanks in advance for any assistance - any input will be greatly appreciated.

1 Solution

Accepted Solutions
erik_wetterberg
Honored Contributor

Re: Automatically retrieve all data rows

Hi Luke,

The maximum number of cells you can get in one go is 10.000 (se this thread) - note that the limit is on cells, not rows. If your qWidth is 2 you should be able to get all 3500 rows in one go.

You don't actually need to call the paint method again, but you need to call getData, which will run asynchronously and add the new values to your visualization in the callback.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
4 Replies
erik_wetterberg
Honored Contributor

Re: Automatically retrieve all data rows

Hi Luke,

You can use the getData method to get more data. Check out this thread for an example.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
lukesartain
New Contributor II

Re: Automatically retrieve all data rows

Many thanks, Erik.

Would I be correct in saying that the only way of plotting 3500 location points then would be to call the paint function four times - the first three plot 1000 points each and the fourth 500? 

erik_wetterberg
Honored Contributor

Re: Automatically retrieve all data rows

Hi Luke,

The maximum number of cells you can get in one go is 10.000 (se this thread) - note that the limit is on cells, not rows. If your qWidth is 2 you should be able to get all 3500 rows in one go.

You don't actually need to call the paint method again, but you need to call getData, which will run asynchronously and add the new values to your visualization in the callback.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
erik_wetterberg
Honored Contributor

Re: Re: Automatically retrieve all data rows

Another point to consider: if you are after the numeric value you probably should use qNum and not qText:

var coords = [];

       $.each(qData, function(rownum, column){

            coords.push(L.latLng(column[0].qNum,column[1].qNum));

});

qText will be formatted for display: use it for labels etc. qNum is the numeric value, use for all kinds of calculation etc.

Erik Wetterberg
https://extendingqlik.upper88.com/
Community Browser