

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 建立儀表板 AWS CLI
<a name="create-dashboards-ai-dashboard-cli"></a>

**注意**  
SiteWise Monitor 功能不再可供新客戶使用。現有客戶可以繼續正常使用該服務。如需詳細資訊，請參閱 [SiteWise Monitor 可用性變更](https://docs.aws.amazon.com/iot-sitewise/latest/appguide/iotsitewise-monitor-availability-change.html)。

當您使用 在儀表板中定義視覺效果 （或小工具） 時 AWS CLI，您必須在 `dashboardDefinition` JSON 文件中指定下列資訊。此定義是 [CreateDashboard](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_CreateDashboard.html) 和 [UpdateDashboard](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateDashboard.html) 操作的參數。

`displaySettings`  
具有下列參數的顯示設定：  
+ `numRows` – 儀表板配置中的資料列數。每一列皆為 **cellSize** wide。
+ `numColumbs` – 儀表板配置中的欄數。每個資料欄都是 **cellSize** 寬。
+ `cellSize` – （選用） 配置中儲存格的大小，以像素為單位。它必須是正數。預設為 10。
+ `significantDigits` – （選用） 要在儀表板中顯示的簽署人位數。預設值為 4。

`querySettings`  
具有下列參數的查詢資訊：  
+ `refreshRate` – （選用） 資料重新整理的速率，以毫秒為單位。接受下列值 - 1000、5000、10000、60000、300000。

`defaultViewport`  
如果未提供，則 預設為最後五分鐘。包含下列參數：  
+ `duration` – （選用） 決定從目前時間開始查詢資料的過去時間。
+ `start` – （選用） 其類型為 Date。查詢資料的開始時間範圍。需要指定`end`日期。
+ `end` – （選用） 其類型為 Date。查詢資料的結束時間範圍。需要指定`start`日期。

`widgets`  
包含下列資訊的小工具定義結構清單：    
`type`  
widget 的類型。 AWS IoT SiteWise 提供下列小工具類型：  
+ <a name="xy-plot"></a>`xy-plot` – 根據組態的折線圖或散佈圖。
+ <a name="bar-chart"></a>`bar-chart` – 長條圖。
+ <a name="kpi-chart"></a>`kpi-chart` – 關鍵效能指標圖表。
+ <a name="status-timeline"></a>`status-timeline` – 狀態小工具，可視覺化並導覽來自一或多個資料來源的時間序列資料。
+ <a name="text-widget"></a>`text` – 文字小工具。
+ <a name="table-widget"></a>`table` – 資料表小工具。  
`id`  
小工具的唯一識別符。  
`x`  
小工具的水平位置，從儀表板左側開始。此值是指 Widget 在儀表板格線中的位置。  
`y`  
小工具的垂直位置，從儀表板頂端開始。此值是指 Widget 在儀表板格線中的位置。  
`z`  
小工具的相對排序。如果較低的 Z 值小工具重疊，則會在較低的 Z 值小工具前面顯示較大的 Z 值小工具。  
`width`  
小工具的寬度，以儀表板上的儲存格數目表示。  
`height`  
小工具的高度，以儀表板上的儲存格數目表示。  
`properties`  
小工具的屬性清單。它取決於小工具的類型。如需詳細資訊，請參閱 [IoT 應用程式套件](https://awslabs.github.io/iot-app-kit/?path=/docs/components-statustimeline--docs)。

**Example 範例儀表板定義**  
下列範例會從存放在 JSON 檔案中的承載來定義儀表板。  

```
aws iotsitewise create-dashboard \
  --project-id a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE \
  --dashboard-name "Example Dashboard" \
  --dashboard-definition file://dashboard-definition.json
```
`dashboard-definition.json` 的下列 JSON 範例，會使用下列視覺效果 Widget 來定義儀表板：  

```
{
    "displaySettings": {
        "numColumns": 200,
        "numRows": 1000,
        "cellSize": 20,
        "significantDigits": 4
    },
    "widgets": [{
        "id": "Ot73JcxUoc6oEXAMPLE",
        "type": "xy-plot",
        "width": 33,
        "height": 20,
        "x": 0,
        "y": 0,
        "z": 0,
        "properties": {
            "aggregationType": "AVERAGE",
            "queryConfig": {
                "source": "iotsitewise",
                "query": {
                    "assets": [{
                        "assetId": "97c97abf-e883-47bb-a3f4-EXAMPLE",
                        "properties": [{
                            "propertyId": "97cc61f4-57a4-4c5f-a82c-EXAMPLE",
                            "refId": "692ce941-f3d9-4074-a297-EXAMPLE",
                            "aggregationType": "AVERAGE",
                            "color": "#7d2105",
                            "resolution": "1m"
                        }]
                    }],
                    "properties": [],
                    "assetModels": [],
                    "alarms": [],
                    "alarmModels": []
                }
            },
            "line": {
                "connectionStyle": "linear",
                "style": "solid"
            },
            "symbol": {
                "style": "filled-circle"
            },
            "axis": {
                "yVisible": true,
                "xVisible": true
            },
            "legend": {
                "visible": true,
                "position": "right",
                "width": "30%",
                "height": "30%",
                "visibleContent": {
                    "unit": true,
                    "asset": true,
                    "latestValue": true,
                    "latestAlarmStateValue": true,
                    "maxValue": false,
                    "minValue": false
                }
            }
        }
    }, {
        "id": "fto7rF40Ny1EXAMPLE-G",
        "type": "bar-chart",
        "width": 33,
        "height": 20,
        "x": 0,
        "y": 20,
        "z": 0,
        "properties": {
            "aggregationType": "AVERAGE",
            "queryConfig": {
                "source": "iotsitewise",
                "query": {
                    "assets": [{
                        "assetId": "97c97abf-e883-47bb-a3f4-EXAMPLE",
                        "properties": [{
                            "propertyId": "c84ca8f3-3dea-478a-afec-EXAMPLE",
                            "aggregationType": "AVERAGE",
                            "refId": "2960b958-2034-4d6e-bcc2-EXAMPLE"
                        }]
                    }],
                    "properties": [],
                    "assetModels": [],
                    "alarms": [],
                    "alarmModels": [],
                    "requestSettings": {
                        "aggregation": "AVERAGE"
                    }
                }
            },
            "axis": {
                "showX": true,
                "showY": true
            },
            "styleSettings": {
                "2960b958-2034-4d6e-bcc2-360f1f02e505": {
                    "color": "#7d2105"
                }
            }
        }
    }],
    "querySettings": {
        "refreshRate": 5000
    }
}
```