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: 
samratmaskey
Contributor II
Contributor II

color chart by expression in API

I was trying to color the chart by expression through API. below is the code, i kept missing "id":"colorByExpression", and lost some time while creating it. hope it would be helpful to someone.


app.visualization.create( 'barchart',

      [ "Dimension",

        { "qDef": { "qDef": "Measure"}, "qAttributeExpressions": [{ "id":"colorByExpression", "qExpression": "=If(Dimension='D1', RGB(255,0,0), If(Dimension='D2', RGB(0,255,0)))" }] }

    ],

      {

          "color": { "auto": false, "mode": "byExpression" }

      }

    ).then(function (chart) {

            chart.show(chartid);

            deferred.resolve(chart);

        });

2 Replies
jonvitale
Creator III
Creator III

Samrat,

Can you explain what this is doing a bit? For example, what is setting qDef to Measure doing? What's the measure?

Also (a shot in the dark here), have you developed an extensions where you do something similar - i.e., setting color by dimension expression?

IVAN-FELIPE
Employee
Employee

Thanks for sharing Samrat, I've been looking for the solution for hours without success!

Very useful