Skip to content

Commit

Permalink
Merge pull request #195 from Esri/rslibed/scoreboard-193
Browse files Browse the repository at this point in the history
Scoreboard: Add property to optionally pass in geometry
  • Loading branch information
rslibed authored Aug 3, 2023
2 parents ea37880 + 418e079 commit cadc64d
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 183 deletions.
4 changes: 2 additions & 2 deletions packages/instant-apps-components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/instant-apps-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"homepage": "https://esri.github.io/instant-apps-components",
"name": "@esri/instant-apps-components",
"version": "1.0.0-beta.107",
"version": "1.0.0-beta.108",
"description": "Reusable ArcGIS Instant Apps web components.",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/instant-apps-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ export namespace Components {
* Controls the behavior to auto dock the scoreboard to the bottom in smaller parent containers/mobile devices.
*/
"autoDockEnabled": boolean;
/**
* Optional geometry in which the statistics will be calculated. To re-calculate the scoreboard's statistics based on the current view extent, set this property to `null`.
*/
"geometry": __esri.Geometry | null;
/**
* Number of scoreboard items that can be viewed at a time. Minimum: 2, Maximum : 6.
*/
Expand Down Expand Up @@ -1154,6 +1158,10 @@ declare namespace LocalJSX {
* Controls the behavior to auto dock the scoreboard to the bottom in smaller parent containers/mobile devices.
*/
"autoDockEnabled"?: boolean;
/**
* Optional geometry in which the statistics will be calculated. To re-calculate the scoreboard's statistics based on the current view extent, set this property to `null`.
*/
"geometry"?: __esri.Geometry | null;
/**
* Number of scoreboard items that can be viewed at a time. Minimum: 2, Maximum : 6.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ export class InstantAppsScoreboard {
@Prop()
autoDockEnabled = true;

/**
* Optional geometry in which the statistics will be calculated. To re-calculate the scoreboard's statistics based on the current view extent, set this property to `null`.
*/
@Prop({
mutable: true
})
geometry: __esri.Geometry | null = null;

// Internal state
@State() state: ScoreboardState = Scoreboard.Loading;

Expand Down Expand Up @@ -171,6 +179,11 @@ export class InstantAppsScoreboard {
}
}

@Watch('geometry')
protected calculateScoreboardItemValuesFromGeometry() {
this.calculateScoreboardItemValues();
}

@Watch('layerViews')
protected async calculateScoreboardItemValues(): Promise<void> {
if ((this.layers && this.layers.length === 0) || (this.layerViews && this.layerViews.length === 0)) return;
Expand Down Expand Up @@ -510,9 +523,9 @@ export class InstantAppsScoreboard {
const getStatDefinitionQuery = (layerView: __esri.FeatureLayerView | __esri.SceneLayerView, statDefinition: __esri.StatisticDefinition) => {
const query = layerView.createQuery();
const outStatistics = [statDefinition];
const geometry = this.view.extent;
const geometry = this.geometry ? this.geometry : this.view.extent;
query.outStatistics = outStatistics;
query.geometry = geometry;
query.geometry = geometry as __esri.Extent;
return query;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ Calculates and displays a series of statistics based on a layer(s) and field att

## Properties

| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | --------------------- |
| `autoDockEnabled` | `auto-dock-enabled` | Controls the behavior to auto dock the scoreboard to the bottom in smaller parent containers/mobile devices. | `boolean` | `true` |
| `itemLimit` | `item-limit` | Number of scoreboard items that can be viewed at a time. Minimum: 2, Maximum : 6. | `number` | `6` |
| `items` | -- | Data on layers, field attribute info, operations, for each scoreboard item | `ScoreboardItem[]` | `undefined` |
| `mode` | `mode` | Mode of scoreboard i.e. 'floating' or 'pinned'. | `Scoreboard.Floating \| Scoreboard.Pinned` | `Scoreboard.Floating` |
| `position` | `position` | Position of scoreboard i.e. 'bottom', 'left', or 'right'. | `Scoreboard.Bottom \| Scoreboard.Left \| Scoreboard.Right` | `Scoreboard.Bottom` |
| `view` | -- | MapView or SceneView to reference extent, viewpoint, and layers in map to perform calculations. | `MapView \| SceneView` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | --------------------- |
| `autoDockEnabled` | `auto-dock-enabled` | Controls the behavior to auto dock the scoreboard to the bottom in smaller parent containers/mobile devices. | `boolean` | `true` |
| `geometry` | -- | Optional geometry in which the statistics will be calculated. To re-calculate the scoreboard's statistics based on the current view extent, set this property to `null`. | `Geometry \| null` | `null` |
| `itemLimit` | `item-limit` | Number of scoreboard items that can be viewed at a time. Minimum: 2, Maximum : 6. | `number` | `6` |
| `items` | -- | Data on layers, field attribute info, operations, for each scoreboard item | `ScoreboardItem[]` | `undefined` |
| `mode` | `mode` | Mode of scoreboard i.e. 'floating' or 'pinned'. | `Scoreboard.Floating \| Scoreboard.Pinned` | `Scoreboard.Floating` |
| `position` | `position` | Position of scoreboard i.e. 'bottom', 'left', or 'right'. | `Scoreboard.Bottom \| Scoreboard.Left \| Scoreboard.Right` | `Scoreboard.Bottom` |
| `view` | -- | MapView or SceneView to reference extent, viewpoint, and layers in map to perform calculations. | `MapView \| SceneView` | `undefined` |


## Events
Expand Down
Loading

0 comments on commit cadc64d

Please sign in to comment.