Hey, I want a layer to show or hide depending on the value of the data label. for eg if the value in the data label is more than zero a layer should show up.
how to show/hide a layer with change in a data label value
Hi Sujith
You can do it by creating a script in the “Ready” action-event under properties for example (or other events if you want to do this)
// Get the canvas service
var canvasService = this.getService(“CanvasService”);
//Get Datalabel Value
var DataLabel = EnterYourDataLabelScriptName.metricSetBindings[0].dataResult.cellset
var ValueOfDataLabel = DataLabel.cells[0][0].value;
// Get the background layer
var backgroundLayer = canvasService.getLayersByFriendlyName(“NameOfYourLayer”)[0];
//If-statement to check if DataLabel value is over 0
if(ValueOfDataLabel < 0)
{
// Hide
canvasService.hideLayers([backgroundLayer]);
}
else
{
// Show
canvasService.showLayers([backgroundLayer]);
}
Hope this works
thanks Amir for the help