Qlik Community

Qlik GeoAnalytics Documents

Documents related to Qlik GeoAnalytics.

Extending features of GeoAnalytics map info bubble

Employee
Employee

Extending features of GeoAnalytics map info bubble

bps Patric Nordström and mto Mike Tarallo have recently highlighted a wonderful feature of embedded charts:

Adding a Sense chart into a Qlik GeoAnalytics map info bubble

Get Familiar with Qlik GeoAnalytics - Custom Info Bubble

 

Here are some steps to extend this feature (please see the pdf attached).

Any other ideas, suggestions, critic are more than welcome.

 

 

  1. Get different charts embedded

 

Steps to do

  • Prepare chart icons you want to have embedded (insert the following load inline into your load script):

DI_SWITCH_EMBEDDED:

NoConcatenate LOAD * Inline [

    EMBEDDED_CHART_ID, EMBEDDED_CHART_NAME, EMBEDDED_CHART_ICON

      1,NONE,

       2,BAR,     

       3,LINE,    

        4,PIE,

        5,DONAT,

        6,SCATTERPLOT,

7,TREEMAP,

8,TABLE,

];

  • Create an extension object having the icons as dimension

 

Dimension: =[ EMBEDDED_CHART_ICON]

I’m usually using senseFieldUI (https://github.com/balexbyrd/sense-FieldUI).

You need an always one selected here.

 

  • Create respective charts you want to embed and get their IDs (via Single Configurator). Every chart must relate to the id field as Mike Tarallo has shown in his video (i.e. it must have the Set Analysis with this id wihtin the charts measure).

 

  • Create a variable vEMBEDDEDCHART_ID

if([EMBEDDED_CHART_ID]=2,'vhPxmN',

if([EMBEDDED_CHART_ID]=3,'jSnpuY',

                if([EMBEDDED_CHART_ID]=4,'FJTEDm' ,

                     if([EMBEDDED_CHART_ID]=5, 'jHKLG',

                          if([EMBEDDED_CHART_ID]=6,'sdShMA',

                               if([EMBEDDED_CHART_ID]=7,'LWurz',

                                    if([EMBEDDED_CHART_ID]=8,'HQmDyY','n.a.')

                               )

                          )

                     )

                )

           )

)

  • Add this variable into your script within the Info Bubble like this:

'<b>Land: ' & A0 & '</b><br>' &

'<b>Staat: ' & A1 & '</b><br>' &

if(GetSelectedCount(A1Polygon)>0,'<b>County: ' & A2 & '</b><br>', '') &

if(GetSelectedCount(A2Polygon)>0,'<b>PLZ: ' & num(A4) & '</b><br>', '') &

if($(v_a_val_KPI)=1, '<b>Umsatz: </b>' & money($(vGEOFORMEL),'#.##0 €',',','.'),

if($(v_a_val_KPI)=2,  '<b>Kosten: </b>' & money($(vGEOFORMEL),'#.##0 €',',','.'),

    if($(v_a_val_KPI)=3,  '<b>Gewinn: </b>' & money($(vGEOFORMEL),'#.##0 €',',','.'),

        if($(v_a_val_KPI)=4,  '<b>Verkaufte Einheiten: </b>' & num($(vGEOFORMEL),'#.##0'),'XXX')

        )

    )

)

& '<br>' & if(isNull([DI_SWITCH_EMBEDDED.ID])=-1 or [DI_SWITCH_EMBEDDED.ID]=1, ' ', $(v_a_fu_EMBEDDED_CODE))

 

v_a_fu_EMBEDDED_CODE:

'<br>' &

'<div id="diagram1" style="position: relative; width: 700px; height: 500px;"></div>'&

'<script>

var app = qlik.currApp();

app.variable.setStringValue("vId","'&id&'");

app.getObject("diagram1","'&$(vEMBEDDEDCHART_ID)&'",{noSelections: false});

</script>'

 

  • Now you should be able to see the selected chart embedded into the map.

 

  1. 2. Drill down by the mouse move

 

This example relates to a data model having 4 geo areas: whereby A1, A2, A3, A4 are your area fields hanging together in your data model in an appropriate way (example: if A4 is your zip-area, then every A4-value can be referred to certain single A3, A2 and A1 area.

Example for Germany: A1 as Bundesland, A2 as Regierungsbezirk, A3 as Kreis, A4 as PLZ

 

Steps to do:

 

AREA LAYER

  • Dimension: DrillDown Dimension containing 4 areas (each field is a geo polygon data)
  • Measure: any, for example UnitsSold
  • SCRIPT within Area Layer Info Bubble (everything between <script> and </script> must be one code line only – here in example it is outlined for better view)

'<br>' &

'<div id="diagram1" style="position: relative; width: 700px; height: 500px;"></div>'&

'<script>

var app = qlik.currApp();

  1. app.variable.setStringValue("vGEOObject","'&$(vGEOEBENEembeddedChart)&'");
  2. app.getObject("diagram1","'&$(v_a_fu_EMBEDDEDCHART_ID)&'",{noSelections: false});

</script>'

 

  • VARIABLES
    • Create a variable vGEOObject (or vId as Mike Tarallo does it in his video) and leave it empty.
    • If your data model has 4 geo areas create a variable vGEOEBENEembeddedChart as follows:

=if(vLNr = 0,'A1',

if(vLNr = 1, 'A2',

if(vLNr = 2, 'A3',

if(vLNr = 3, 'A4', 'n.a.')

)

)

)

  • Create variable vLNr as follows:

vLNr ->

=if($(vLNr4)=0,

   if($(vLNr3)=0,

      if($(vLNr2)=0,

if($(vLNr1)=0,0,1),

2),

   3),

4)

 

  • Create variables as follows:

vLNr1 -> =if(GetSelectedCount(A1)>0 or GetSelectedCount(A1Polygon), 1, 0)

vLNr2 -> =if(GetSelectedCount(A2)>0 or GetSelectedCount(A2Polygon), 2, 0)

vLNr3 -> =if(GetSelectedCount(A3)>0 or GetSelectedCount(A3Polygon), 3, 0)

vLNR4 -> =if(GetSelectedCount(A4)>0, 4, 0)

 

 

EMBEDDED CHART

  • Create a chart that must be embedded.
  • Dimension: =$(vGEOEBENEembeddedChartLower)
    • Create variable vGEOEBENEembeddedChartLower

=if(vLNr = 0,'A2',

if(vLNr = 1, 'A3',

if(vLNr = 2, 'A4',

if(vLNr = 3, 'A4', 'n.a.')

)

)

)

  • Measure: any formula calculating something in the embedded chart (example: revenue, marge, etc.):  =$(vRevenueEembeddedChart)
    • Create variable vRevenueEembeddedChart

if(vLNr = 0, sum({$< A1 = {'$(vGEOObject)'} >} myRevenue),

if(vLNr = 1, sum({$< A2 = {'$(vGEOObject)'} >} myRevenue),

if(vLNr = 2, sum({$< A3 = {'$(vGEOObject)'} >} myRevenue),

if(vLNr = 3, sum({$< A4 = {'$(vGEOObject)'} >} myRevenue), 'n.a.')

)

)

)

 

  • Move your mouse over certain geo area: if everything goes fine you must be able to see the embedded chart containing data for the subarea of the area where you’ve just positioned your mouse (please see screenshots attached).

 

Any other ideas, suggestions, critic are more than welcome.

Labels (2)
Comments
Employee
Employee

Brilliant! Will add reference from my page!

Btw, please tag the article with "geoanalytics"

Employee
Employee

Thank you, Patric! I actually did tagged it with "geoanalytics" (please see the screenshot attached)Tag_GeoAnalytics.JPG

0 Likes
Version history
Revision #:
2 of 2
Last update:
‎2019-02-01 12:13 PM
Updated by:
 
Contributors