AnsweredAssumed Answered

Precision of labels in GenerateRendererParameters

Question asked by schlot on Jul 2, 2014
Latest reply on Feb 10, 2016 by rozekc_washtenaw
I have a generateRendererTask and generateRendererParameters defined and I want to be able to format my labels to only have 2 decimal places. 
  function generateClassBreaks(c1, c2) {
    var classDef = new ClassBreaksDefinition();
    classDef.classificationField = classBreakField;
    classDef.classificationMethod = "quantile";
    classDef.breakCount = interval;  //defined as 5

    var colorRamp = new AlgorithmicColorRamp();
    colorRamp.fromColor = new Color.fromHex(c1);
    colorRamp.toColor = new Color.fromHex(c2);
    colorRamp.algorithm = "hsv"; // options are:  "cie-lab", "hsv", "lab-lch"
    
  classDef.baseSymbol = new SimpleFillSymbol("solid", null, null);
  classDef.baseSymbol = defaultSymbol;    
  classDef.colorRamp = colorRamp;

    var params = new GenerateRendererParameters();
    params.classificationDefinition = classDef;
    params.precision = 2;
    params.formatLabel = true;
    var clauseInput = classDef.classificationField;
    params.where= clauseInput + " > 0";
    var generateRenderer = new GenerateRendererTask(myLayer.url+"/0");
    generateRenderer.on("error", taskErrorHandler);
    generateRenderer.execute(params, applyRenderer);
  }


This is then used to generate my legend.  In my legend, the values are not rounded to two decimal places like I expected.  Instead they round to a whole number.  They're this way because that's how the label got generated from the generateRendererTask.

I have worked around this by creating my own labels using the minValue and maxValue for each class, but I don't feel like I should have had to do this.  I read in the API reference that precision is only for ClassBreakRenderers, but it seems like should be inclusive of the tools that let you generate those renderers dynamically. 

This seems like a bug to me.  I didn't get an error defining a precision parameter, just this unintended format.  Has anyone else had a similar experience?

Outcomes