Skip to main content
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
jonvitale
Creator III
Creator III

I'll try that, but one last question and I'll stop bugging you. Do you know how to view the code for the built in charts? that would certainly solve all my problems.

jonvitale
Creator III
Creator III

erik.wetterberg

Unbelievable, it worked! The actual code for the reference should be this:

qHyperCubeDef.qMeasures.1.qDef.qDef

(the first qDef is an object containing the qDef expression.). The new calculated measure now sits there right along side my other measure.

I think this is all I need. When I put everything together, I'll write up a little reference guide and be sure to give you a lot of credit!

pasi_lehtinen
Partner - Contributor III
Partner - Contributor III

Hi Jonathan,

I came up with the same need. Could you please share the complete solution?

Thanks in advance

jonvitale
Creator III
Creator III

Hi Pasi,

What exactly are you trying to do? I found that if I used a reference like, "qHyperCubeDef.qMeasures.1.qDef.qDef", anywhere in the property definition, I could define a new measure. You'll even see this measure in the list of measures. But it didn't quite work because the visualization would crash when I tried to put a new visualization on a sheet. Not sure why.

I wound up just adding a new expression attribute to my dimensions. Which I can explain if you need help. Let me know what you are working on. Really I want to document this whole thing at some point anyhow.

Jonathan

Anonymous
Not applicable
Author

Hi im working with navigation button and I have to add a functionality in it ColorByExpression  so I have included this  in my code

colorExpression:{

type: "string",

label: "Enter color expression",

ref:"qHyperCubeDef.myColorSelection.expression",

expression:"always"

}

but still im not able to achive this.

I also want to ask is myColorSelection.expression  is a builtin functionality of qHypercubeDef or we have to add its definition else where in the code also???

Please help me out in this.

ErikWetterberg

Hi,

If you do not have a HyperCubeDef in your properties structure (most likely for a button) then you cant use this method. Instead you could use a string or possibly a color-picker.

Hope this helps

Erik Wetterberg

Anonymous
Not applicable
Author

Hi Erik,

I have to change the background color of the navigation button when I click on it and it gets back to the original color when I select any other navigation button. how can I do it?

I tried using this code for that purpose. I have also set the variables  and kept this expression in background color  field

expression ---> if(vbutton='1',Red(),Green()).

but it didn't work out.

can u suggest me any alternate way or  code which whould help me out of this issue.

Thanx

sadhana

Anonymous
Not applicable
Author

Hi,

can we do the  same to change the background color of the extension based on set variable.

Thanx

sadhana

humesh_sindpure
Partner - Contributor III
Partner - Contributor III

Hello Jonathan Sir,

  My name is Humesh . I am developing an extention for table.I want to add custome color property to every dimentions and measures.

I found your this code :

  1. colorExpression:{ 
  2.      type: "string"
  3.      label: "Enter color expression"
  4.      ref:"qAttributeExpressions.0.qExpression"
  5.      expression:"optional" 

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) {

                   

               }

please give me solution

jonvitale
Creator III
Creator III

Humeshkumar,

You'll need to loop through all rows of the Hypercube. The row itself will be an array with each dimension and each column, so given that you are putting this in the first dimension, the index you'll want to use is 0.

So, something like this.

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

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

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

}

Good luck