1 Reply Latest reply: Jun 30, 2017 9:20 AM by Hammond Mason RSS

    Quick Help on Extensions

    Olivier Buchy

      Hello,

       

      I've been looking into tutorials about Qlikview extensions for some time now and I still do not understand how the link is made between Qlikview data and the Javascript code

       

      I understand that all comes from this.Data.

      Assuming I deal with one "dimension" and one "measure",

          if r=this.Data.row[n],

      then the      nth value of my dimension    would be r0]

      and the        nth value of my measure        would be r[1]


      But where do I define that I deal with one "dimension" and one "measure"? When I look at the Definition.xml file, it does not seem that the link is made there.


      Example here (good tutorial btw) : Step2- Linking your D3 chart to Qlikview Data – Qlik and Dirty:

      (files are here : http://qlikanddirty.com/wp-content/uploads/2016/08/02-Linked-to-Data.qar )


      Definition.xml says :

      ...

      <Dimension Label="Dimension 1" Initial="Path" TargetName="Dimension Name" />

      <Measurement Label="Measure 1" Initial="Sum(Measure)"/>

      ...

       

      JS says :

      ...

      var row = _this.Data.Rows[f];

      var dim1 = row[0].text;

      var measure1 = row[1].text;

      ...

       

      Thanks for any hints.

        • Re: Quick Help on Extensions
          Hammond Mason

          'Data' is a JavaScript Array (actually, it's an Array of arrays, ie. a 2-dimensional object - just like a QlikView Straight Table).

          The 'Data' array your JavaScript interacts with is part of the JavaScript API that QlikTech have exposed to the developer.

          It's the 'portal' through which your Extension gets access to its host's (ie. QlikView's) data.
          The 'Data' array is created from the Dimension and Measurement tags you define in Definition.xml.
          To control what each Dimension and Measurement hold, you can use the 'Initiate' tag in Definition.xml.

          For example:

           

          <Dimension Label="Dim1" Initial=""/>
          <Dimension Label="Dim2" Initial=""/>
          <Dimension Label="Dim3" Initial=""/>
          <Measurement Label="Measure1" Initial=""/>

           

          <Initiate Name="Chart.Dimension.0.Field" Value="City"/>
          <Initiate Name="Chart.Dimension.1.Field" Value="Longitude"/>
          <Initiate Name="Chart.Dimension.2.Field" Value="Latitude"/>
          <Initiate Name="Chart.Expression.0.0.Definition" Value="Sum(Population)"/>

           

          Here I've created 3 Dimensions and 1 Measurement and defined what each holds.  This XML will lead to a 'Data' object with column 0 (JavaScript arrays are zero-based) having the values for 'City', column 1 having the values for 'Longitude', column 2 having the values for 'Latitude' and, finally, column 3 having the values for the SUM of 'Population'.  Think of it like a QlikView Straight Table with 3 Dimensions and 1 Expression (Measurement).

           

          The above code comes from an Extension I created to use the LeafletJS library.

          You can get the whole code from my GitHub repo in case you want to see how it works.