[comment]: # ({09f5b760-2be71f02})
# 11 Graph prototype

[comment]: # ({/09f5b760-2be71f02})

[comment]: # ({42eb93ed-4ce2099a})
### 説明

これらのパラメータおよび各ダッシュボードウィジェットフィールドオブジェクトに対応する使用可能なプロパティ値により、`dashboard.create` および `dashboard.update` メソッドで [*グラフプロトタイプ*](/manual/web_interface/frontend_sections/dashboards/widgets/graph_prototype) ウィジェットを設定できます。

::: noteimportant
ダッシュボードの作成または更新時に、ウィジェットの `fields` プロパティは検証されません。
これにより、ユーザーは [組み込みウィジェット](/manual/web_interface/frontend_sections/dashboards/widgets) を変更したり、[カスタムウィジェット](/devel/modules/tutorials/widget) を作成したりできますが、その一方で、ウィジェットを誤って作成または更新してしまうリスクも生じます。
*グラフプロトタイプ* ウィジェットの作成または更新を正常に行うため、以下の表に示すパラメータの動作を参照してください。
:::

[comment]: # ({/42eb93ed-4ce2099a})

[comment]: # ({30d7fc2f-83184d1c})
### パラメータ

以下のパラメータは、*グラフプロトタイプ*ウィジェットでサポートされています。

|パラメータ|<|[type](/manual/api/reference/dashboard/object#dashboard-widget-field)|name|value|
|-|-----|-|-----|-------------------|
|*更新間隔*|<|0|rf_rate|0 - 更新なし;<br>10 - 10秒;<br>30 - 30秒;<br>60 - *(デフォルト)* 1分;<br>120 - 2分;<br>600 - 10分;<br>900 - 15分。|
|*ソース*|<|0|source_type|2 - *(デフォルト)* グラフプロトタイプ;<br>3 - シンプルグラフプロトタイプ。|
|*グラフプロトタイプ*|<|7|graphid.0|[グラフプロトタイプ](/manual/api/reference/graphprototype/get) ID。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *ソース*が「グラフプロトタイプ」に設定されている場合は*必須*|
|*アイテムプロトタイプ*|<|5|itemid.0|[アイテムプロトタイプ](/manual/api/reference/itemprototype/get) ID。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *ソース*が「シンプルグラフプロトタイプ」に設定されている場合は*必須*|
|*期間*|<|1|time_period.\_reference|`DASHBOARD._timeperiod` - [*期間*セレクター](/manual/web_interface/time_period_selector)をデータソースとして設定します;<br>`ABCDE._timeperiod` - [互換性のあるウィジェット](/manual/web_interface/frontend_sections/dashboards/widgets#widget-compatibility)（*参照*パラメータが「`ABCDE`」に設定されているもの）をデータソースとして設定します。<br><br>デフォルト: `DASHBOARD._timeperiod`<br><br>または、*開始*および*終了*パラメータでのみ期間を設定することもできます。|
|<|*開始*|1|time_period.from|絶対時間（`YYYY-MM-DD hh:mm:ss`）または[相対](/manual/web_interface/time_period_selector)時間構文（`now`、`now/d`、`now/w-1w` など）の有効な時間文字列。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *期間*が設定されていない場合に*サポート*<br>- `time_period.to` が設定されている場合は*必須*|
|^|*終了*|1|time_period.to|絶対時間（`YYYY-MM-DD hh:mm:ss`）または[相対](/manual/web_interface/time_period_selector)時間構文（`now`、`now/d`、`now/w-1w` など）の有効な時間文字列。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *期間*が設定されていない場合に*サポート*<br>- `time_period.from` が設定されている場合は*必須*|
|*凡例の表示*|<|0|show_legend|0 - 無効;<br>1 - *(デフォルト)* 有効。|
|*ホストの上書き*|<|1|override_hostid.\_reference|`ABCDE._hostid` - [互換性のあるウィジェット](/manual/web_interface/frontend_sections/dashboards/widgets#widget-compatibility)（*参照*パラメータが「`ABCDE`」に設定されているもの）をホストのデータソースとして設定します;<br>`DASHBOARD._hostid` - ダッシュボードの[*ホスト*セレクター](/manual/web_interface/frontend_sections/dashboards/widgets#override-host)をホストのデータソースとして設定します。<br><br>このパラメータは、[テンプレートダッシュボード](/manual/api/reference/templatedashboard/object)でウィジェットを設定する場合はサポートされません。|
|*列数*|<|0|columns|指定可能な値は 1～24 です。<br><br>デフォルト: 2。|
|*行数*|<|0|rows|指定可能な値は 1～16 です。<br><br>デフォルト: 1。|
|*参照*|<|1|reference|5文字で構成される任意の文字列値（例: `ABCDE` または `JBPNL`）。この値は、ウィジェットが属するダッシュボード内で一意である必要があります。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *必須*|

[comment]: # ({/30d7fc2f-83184d1c})

[comment]: # ({bc39c20a-df884afa})
### 例

次の例は、*グラフのプロトタイプ*ウィジェットのダッシュボードウィジェットフィールドオブジェクトの設定を説明することだけを目的としています。
ダッシュボードの設定の詳細については、[`dashboard.create`](/manual/api/reference/dashboard/create)を参照してください。

[comment]: # ({/bc39c20a-df884afa})

[comment]: # ({247e9c9f-826a8d29})
#### *グラフのプロトタイプ*ウィジェットの設定

ローレベルディスカバリによってアイテムのプロトタイプ(ID: "42316")から作成された3つのグラフ(3列、1行)のグリッドを表示する*グラフのプロトタイプ*ウィジェットを設定します。

[リクエスト](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.create",
    "params": {
        "name": "My dashboard",
        "display_period": 30,
        "auto_start": 1,
        "pages": [
            {
                "widgets": [
                    {
                        "type": "graphprototype",
                        "name": "Graph prototype",
                        "x": 0,
                        "y": 0,
                        "width": 48,
                        "height": 5,
                        "view_mode": 0,
                        "fields": [
                            {
                                "type": 0,
                                "name": "source_type",
                                "value": 3
                            },
                            {
                                "type": 5,
                                "name": "itemid.0",
                                "value": 42316
                            },
                            {
                                "type": 0,
                                "name": "columns",
                                "value": 3
                            },
                            {
                                "type": 1,
                                "name": "reference",
                                "value": "OPQWX"
                            }
                        ]
                    }
                ]
            }
        ],
        "userGroups": [
            {
                "usrgrpid": 7,
                "permission": 2
            }
        ],
        "users": [
            {
                "userid": 1,
                "permission": 3
            }
        ]
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/247e9c9f-826a8d29})

[comment]: # ({e9d30322-46917953})
### 参照

-   [Dashboard widget field](/manual/api/reference/dashboard/object#dashboard-widget-field)
-   [`dashboard.create`](/manual/api/reference/dashboard/create)
-   [`dashboard.update`](/manual/api/reference/dashboard/update)

[comment]: # ({/e9d30322-46917953})
