On this page
The chart data profile defines the data to be shown in a user defined chart on a panel.
Profile variables
Variable name | Type | Description |
---|---|---|
$map | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. This can then be queried. |
$userId | Text | The unique user ID of the editor who is logged into the application. |
$userName | Text | The full name of the editor who is logged into the application. |
$userIdentity | Text | Provides a credential instance. This can be used when accessing external layers with the FeatureLayer function. The credentials represent the user’s logged in credentials. |
$session | Dictionary | A dictionary containing key value pairs. The dictionary contains all the session variables that have been configured in the app. When the application first launches, the user will be asked for values for the session variables. They can also (if configured) change session variables in the application. This provides programmatic access to the user’s choices / settings. |
$selection | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. It will only contain the features from each layer selected on the map. This can then be queried. |
$currentMapExtent | Extent | The current map extent. This value is not available for all scripts. |
$currentTool | Text | The type of tool selected. Will be one of ‘new’,’add’,’effects’, ‘reshape’,’subtract’,’pan’,’select’,’unprotect’. This value is not available for all scripts. It also represents the current state, not the state for why the script is running. |
$drawingShape | Polygon | The current drawing shape being digitised on the map. Not available for all scripts. |
$drawingShapeLastPoint | Point | The last vertex added to the drawing Shape being digitised on the map. Not available for all scripts. |
Return types
null | FeatureSet | Dictionary
Value | Description |
---|---|
null | Do not show a chart. |
FeatureSet | The table of data to be shown in the chart. |
Dictionary | A set of values to be shown in the chart. For example a gauge chart. Please see Script Editor Dialog for example of expected values. |
Example
Create a standard bar chart:
/** Create a standard bar chart.
*
* This script creates a new FeatureSet from a layer in the map and then
* uses this as the input for a bar chart. As data in the layer is updated,
* the bar chart will also be updated.
*
* @return a FeatureSet
*/
//Filter crops in the map "Crops" layer which do not have the type of none
var layer = Filter(FeatureSetByName($map, "Crops"), "TYPE<>'NONE'");
//Group crops of the same type and calculate the area of land
var groupedFeatSet = GroupBy(layer, 'Type', { name: 'landarea', expression: 'UsableLand', statistic: 'SUM'})
//The Bar Chart takes a featureset as an input.
return groupedFeatSet
null