AnsweredAssumed Answered

ESRI Cluster layer dynamic label colors

Question asked by Sycosys on Mar 10, 2016

I am using extras/clusterlayer to render clusters for a uniquevalue renderer.. all that works well and good except that the label colors are all white/black/whatever you set them to..

I though I'd just loop through the cluster layer object and change the label colors on a per graphic basis based on the color it got from the renderer.. This does not work. All label change color even if you specifically change one graphic[i]. The loop is working and it seems to swap the colors properly but in the end the last color applied to the label has been propagated through all the graphics..

the little test loop below should alternate white and black labels for each cluster.. It doesn't, the best i can get it to do is change all the labels from black to white and back again.

 

  clusterLayer.setRenderer(UniRenderer);
  
var graphics = clusterLayer.graphics;
  console
.log(graphics.length);
  
for(var i=0; i<graphics.length;i++)
  
{
  
if(i%2==0)
  
{
  console
.log("black");
  
//have also tried clusterLayer.graphics[i]._graphicsLayer.clusterLabelColor
  clusterLayer
.graphics[i]._layer._clusterLabelColor= "#000";
  
}
  
else
  
{
  console
.log("white");
  clusterLayer
.graphics[i]._layer._clusterLabelColor= "#FFF";
  
}
  
//console.log(label);
  
//label = "#000";
  
}
  console
.log(clusterLayer);
  
var symbolList = clusterLayer.renderer._symbols;

Outcomes