Select to view content in your preferred language

Statistics Query result as label

99
1
12-10-2024 12:05 AM
cadgism
Regular Contributor

Hi all

 I have created a client side count  statistic query  , that is working fine. How I can place the 

"outStatisticFieldName" as label of the layer.
 

 

 

query = tLayer.createQuery();
query.groupByFieldsForStatistics = ["FLATS"];
query.outStatistics = [sumFlats];

tLayer.queryFeatures(query)
      .then(function (response) {
      response.features.forEach((feature) => {
      console.log(feature.attributes);
      });
tLayer.refresh();
}); 

 

0 Kudos
1 Reply
MatthewDriscoll
MVP Alum

Try something like this inside the query.

 

// Style the label
      var labelClass = {
        symbol: {
          type: "text", // autocasts as new TextSymbol()
          color:[254, 252, 203], 
          haloColor: "Black",
          haloSize: 2,
          lineWidth:55,
          font: {
            // autocast as new Font()
            family: "Avenir Next LT Pro Medium",
            size: 8,
            weight: "bold"
          }
        },
        labelExpressionInfo: {
          expression: feature.attributes
        },
        labelPlacement: "always-horizontal",
        //minScale: 7500
      };
      tLayer.labelingInfo = [labelClass];
      tLayer.refresh()

 

 

 

0 Kudos