-
onStatisticField
String
定义将为其计算统计数据的字段。这可以是服务字段名称或 SQL 表达式。有关示例,请参见下面的片段。
例子:
// query for the sum of the population in all features let sumPopulation = { onStatisticField: "POP_2015", // service field for 2015 population outStatisticFieldName: "Pop_2015_sum", statisticType: "sum" } let query = layer.createQuery(); query.outStatistics = [ sumPopulation ]; layer.queryFeatures(query) .then(function(response){ let stats = response.features[0].attributes; console.log("output stats:", stats); });
// query for the average of the population change for all features // Notice that you can pass a SQL expression as a field name to calculate statistics let populationChangeDefinition = { onStatisticField: "POP_2015 - POP_2010", // service field for 2015 population outStatisticFieldName: "avg_pop_change_2015_2010", statisticType: "avg" } let query = layer.createQuery(); query.outStatistics = [ populationChangeDefinition ]; layer.queryFeatures(query) .then(function(response){ let stats = response.features[0].attributes; console.log("Average change:", stats.avg_pop_change_2015_2010); });
// query for the average of the population change grouped by regions // query result will also return an extent for each group encompassing // all features in each group. let populationChangeDefinition = { onStatisticField: "POP_2015 - POP_2010", // service field for 2015 population outStatisticFieldName: "avg_pop_change_2015_2010", statisticType: "avg" }; let aggregatedExtent = { statisticType: "envelope-aggregate" }; let query = layer.createQuery(); query.groupByFieldsForStatistics = ["Region"]; query.outStatistics = [ populationChangeDefinition, aggregatedExtent ]; layer.queryFeatures(query).then(displayResults);
基本信息
以下是所在类或对象的基本信息。
AMD:
require(["esri/rest/support/StatisticDefinition"], (StatisticDefinition) => { /* code goes here */ });
ESM:
import StatisticDefinition from "@arcgis/core/rest/support/StatisticDefinition";
类:
esri/rest/support/StatisticDefinition
继承: StatisticDefinition > Accessor
自从:用于 JavaScript 4.0 的 ArcGIS API
用法说明
StatisticDefinition.onStatisticField
函数(或属性)的定义如下:
相关用法
- JavaScript ArcGIS StatisticDefinition.statisticParameters用法及代码示例
- JavaScript ArcGIS StatisticDefinition.statisticType用法及代码示例
- JavaScript ArcGIS StatisticDefinition用法及代码示例
- JavaScript ArcGIS StreamLayer.timeOffset用法及代码示例
- JavaScript String.prototype.toLocaleLowerCase()用法及代码示例
- JavaScript String slice()用法及代码示例
- JavaScript String length用法及代码示例
- JavaScript String padStart()用法及代码示例
- JavaScript ArcGIS StreamLayer layerview-create-error事件用法及代码示例
- JavaScript String strike()用法及代码示例
- JavaScript ArcGIS StreamLayer.minScale用法及代码示例
- JavaScript ArcGIS StreamLayerView.queryFeatureCount用法及代码示例
- JavaScript String fromCodePoint()用法及代码示例
- JavaScript String blink()用法及代码示例
- JavaScript String repeat()用法及代码示例
- JavaScript ArcGIS Stop用法及代码示例
- JavaScript ArcGIS StreamLayer.purgeOptions用法及代码示例
- JavaScript String charCodeAt()用法及代码示例
- JavaScript String fontcolor()用法及代码示例
- JavaScript String endsWith()用法及代码示例
- JavaScript ArcGIS StreamLayerView.queryObjectIds用法及代码示例
- JavaScript String substr()用法及代码示例
- JavaScript String toLocaleLowerCase()用法及代码示例
- JavaScript ArcGIS StreamLayer.fields用法及代码示例
- JavaScript ArcGIS StreamLayer.effect用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 StatisticDefinition.onStatisticField。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。