基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/popup/content/ExpressionContent"], (ExpressionContent) => { /* code goes here */ });
ESM:
import ExpressionContent from "@arcgis/core/popup/content/ExpressionContent";
類:
esri/popup/content/ExpressionContent
繼承: ExpressionContent > Content > Accessor
自從:用於 JavaScript 4.22 的 ArcGIS API
用法說明
ExpressionContent 元素允許您使用 Arcade 表達式定義彈出內容元素。表達式必須計算為表示 TextContent 、 FieldsContent 或 MediaContent 彈出元素的字典,如 Popup Element web map specification 中定義的那樣。
定義彈出內容的表達式通常使用元素的attributes
屬性來引用在表或圖表中的表達式內計算的值。
此內容元素專為圖表、表格或富文本元素中的內容基於邏輯條件的高級方案而設計。例如,如果一個或多個字段中的數據為空,您可以使用此元素動態創建一個表,該表僅由包含有效數據值的字段組成。您還可以使用此元素創建由聚合數據值組成的圖表或其他內容類型。這在 cluster popups 中特別有用。
例子:
// Creates an column chart where each category/value
// is an aggregate of two or more fields
layer.popupTemplate = {
title: "Educational Attainment",
content: [{
type: "expression",
expressionInfo: {
expression: `
// Create a dictionary of attributes representing the values
// to display in the chart
var attributes = {
"No School": $feature.no_school + $feature.some_primary,
"Primary": $feature.primary_complete + $feature.some_secondary,
"Secondary": $feature.secondary_complete + $feature.some_highSchool,
"High School": $feature.highSchool_diploma + $feature.highSchool_ged + $feature.some_college,
"College/University": $feature.associates + $feature.bachelors + $feature.masters + $feature.doctorate + $feature.professional;
};
var fields = [];
// Create an array representing the attribute names (or keys)
for (var k in attributes){
Push(fields, k);
}
// Returns a dictionary providing the information
// required by the popup to render a column chart
return {
type: "media",
attributes: attributes,
title: "Educational attainment",
mediaInfos: [{
type: "columnchart",
value: {
// The list of attribute names (keys) to include in the chart
fields: fields
}
}]
};
`,
title: "Educational Attainment"
}
}]
};
相關用法
- JavaScript ArcGIS ExpressionInfo.title用法及代碼示例
- JavaScript ArcGIS ExpressionInfo.expression用法及代碼示例
- JavaScript ArcGIS ExpressionInfo.name用法及代碼示例
- JavaScript ArcGIS ExpressionInfo用法及代碼示例
- JavaScript ArcGIS Expand.when用法及代碼示例
- JavaScript ArcGIS Expand用法及代碼示例
- JavaScript ArcGIS Expand.classes用法及代碼示例
- JavaScript ArcGIS Expand.group用法及代碼示例
- JavaScript ArcGIS Expand.content用法及代碼示例
- JavaScript ArcGIS Expand.closeOnEsc用法及代碼示例
- JavaScript ArcGIS Expand.container用法及代碼示例
- JavaScript ArcGIS Expand.on用法及代碼示例
- JavaScript ArcGIS Expand.visible用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer.castShadows用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer.clone用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer.edges用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer.size用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer.material用法及代碼示例
- JavaScript ArcGIS ExtrudeSymbol3DLayer用法及代碼示例
- JavaScript ArcGIS ElementExpressionInfo.expression用法及代碼示例
- JavaScript ArcGIS ElevationProfile.profiles用法及代碼示例
- JavaScript ArcGIS ElevationLayer.fullExtent用法及代碼示例
- JavaScript ArcGIS ElevationLayer layerview-create-error事件用法及代碼示例
- JavaScript ArcGIS Editor.classes用法及代碼示例
- JavaScript ArcGIS ElevationLayer.on用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 ExpressionContent。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。