1 Reply Latest reply: Oct 17, 2017 11:41 AM by Jonathan Vitale RSS

    color chart by expression in API

    Samrat Maskey

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

              });