Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set color by expression in extension

Hi all,

I would like to define the coloring option by expression in the properties panel of a visualization extension.

I looked at several extensions and none of them have used any expressions in the properties panel excluding dimension, measure, and appearance > general panes which are all auto created/defined parts of the properties panel, having no setting attributes in the js file.

When I tried the expression: "always" element  in the js file I got the orange fx sign show up in the properties panel but the calculations were not carried out...

Any kind of help would be greatly appreciated!

24 Replies
humesh_sindpure
Partner - Contributor III
Partner - Contributor III

I have written this code inside of dimention shown below:

definition : {

  type : "items",

  component : "accordion",

    items : {

         dimensions : {

                uses : "dimensions",

                min : 1,

                items: {

               colorExpression:{

                                          type: "string",

                                          label: "Enter color expression",

                                          ref:"qAttributeExpressions.0.qExpression",

                                          expression:"optional"

                                         }

                 }

  },

now please tell me what should I need to write inside of function

      paint: function ($element,layout) {

                      this.backendApi.eachDataRow( function (rownum, row){

                          var dimIndex = 0; // you are putting the value in your first dimension

                           row[dimIndex].qAttrExps.qValues[0].qText;

                      });

                              if ( !this.$scope.table ) {

                              this.$scope.table = qlik.table(this);

                                     }

                           return qlik.Promise.resolve();

               }

but Sir , this is not working for me.

please give me any solution

jonvitale
Creator III
Creator III

The expression: row[dimIndex].qAttrExps.qValues[0].qText;

should have the calculated color expression. You'll need to save those in an array.

Beyond that I don't know how to actually background color columns of the table. You'll have to figure it out with the Visualization API I believe. Good luck.

https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/CapabilityAPIs/Vis...

mayuringale25
Partner - Creator
Partner - Creator

Hi Jonathan

Can you please share the code

Thanks and Regards
Mayur Ingale
jonvitale
Creator III
Creator III

mayuringale25pasi.lehtinen

Sorry, I don't actually have the code for this because I wound up going in a different direction. I had the idea to use a measure to define the color of something, but then decided that I needed the color to be related to dimensions. So, I wound up using an expression in each dimension to color the representation of that dimension. So, in my dimension I use a reference like, "qAttributeExpressions.0.qExpression" and then access with something like, "row.qAttrExps.qValues[0].qText", where I'm iterating over the rows of the hypercube with this, "this.backendApi.eachDataRow(function(rownum, row){..."

You can see my code here:

https://github.com/jonvitale/SenseColorableSankey/blob/master/SenseColorableSankey.js