ダッシュボード
名前付きデータセットにバインドされたチャートウィジェットで構築する分析ページ。グローバルフィルター、自動更新、元のレコードへのドリルスルーを備えます。
ダッシュボードはウィジェットのグリッドであり、すべてのウィジェットはデータセットにバインドします。 データセットはセマンティックレイヤーで、基になるオブジェクト、結合、ディメンション、メジャーを持ちます。ウィジェットはそれらを名前で選ぶので、「売上」は、それを使うすべてのダッシュボードとレポートで同じ意味になります。
// One dashboard, bound to the `sales` dataset defined below.
const salesDashboard = {
name: 'sales_overview',
label: 'Sales Overview',
description: 'Key sales metrics and pipeline analysis',
refreshIntervalSeconds: 300, // auto-refresh every 5 minutes
dateRange: {
field: 'close_date',
defaultRange: 'this_quarter',
allowCustomRange: true,
},
widgets: [
{ id: 'total_revenue', title: 'Total Revenue', type: 'metric',
dataset: 'sales', values: ['revenue'],
layout: { x: 0, y: 0, w: 3, h: 2 } },
{ id: 'revenue_by_region', title: 'Revenue by Region', type: 'bar',
dataset: 'sales', dimensions: ['region'], values: ['revenue'],
layout: { x: 3, y: 0, w: 6, h: 4 } },
{ id: 'deals_by_month', title: 'Deals by Month', type: 'pie',
dataset: 'sales', dimensions: ['close_month'], values: ['deal_count'],
layout: { x: 9, y: 0, w: 3, h: 4 } },
],
}ダッシュボードのプロパティ
| プロパティ | 型 | 必須 | 説明 |
|---|---|---|---|
name | string | はい | マシン名(snake_case) |
label | string | はい | 表示ラベル |
description | string | — | ダッシュボードの説明 |
widgets | DashboardWidget[] | はい | チャートと指標のウィジェット |
refreshIntervalSeconds | number | — | 自動更新の間隔(秒) |
dateRange | object | — | グローバルな日付範囲のフィルター |
globalFilters | GlobalFilter[] | — | 対話的なフィルターコントロール |
まずデータセット
データセットを一度定義し、すべてのウィジェットをそれにバインドします。
import { defineDataset } from '@objectstack/spec/ui'
export const salesDataset = defineDataset({
name: 'sales',
label: 'Sales',
object: 'opportunity',
include: ['account'],
dimensions: [
{ name: 'region', field: 'account.region', type: 'string' },
{ name: 'close_month', field: 'close_date', type: 'date', dateGranularity: 'month' },
],
measures: [
{ name: 'revenue', field: 'amount', aggregate: 'sum' },
{ name: 'deal_count', aggregate: 'count' },
],
})集計はウィジェットではなく、データセットのメジャー(aggregate)に置かれます:count、sum、avg、min、max、count_distinct、array_agg、string_agg。ウィジェットの dimensions と values は、バインドしたデータセットで宣言された名前を参照しなければなりません。
実行時、データセットのクエリは分析サービスを通じて実行され、基になるオブジェクトと結合したオブジェクトに、呼び出し元の行レベルセキュリティの範囲が自動的に適用されます。ダッシュボードが、ユーザーの権限では見られないレコードを見せることはありません。
16.0 以降、ウィジェットのスキーマは厳格です。宣言されていないトップレベルのキー(入力ミス、ハルシネーションによるキー、削除されたインラインクエリのキー(
object+categoryField+valueField+aggregate、ピボットのrowField/columnField))は、問題のキーを名指しするパースエラーになり、データセットの形を示します。何もレンダリングしないウィジェットへと黙って取り除かれることは、もうありません。データセットを定義してウィジェットをそれにバインドしてください。optionsは、レンダラー固有の追加設定のための自由形式の逃げ道として残っています。
ウィジェット
| プロパティ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | はい | 一意なウィジェット ID(snake_case) |
dataset | string | はい | バインドするデータセットの名前 |
values | string[] | はい | メジャーの名前(少なくとも 1 つ) |
dimensions | string[] | — | ディメンションの名前:X / グループ / 分割 |
type | ChartType | — | 可視化の種類(デフォルト metric) |
title / description | string | — | 表示用のタイトルとサブタイトル |
filter | FilterCondition | — | 表示範囲のフィルター |
layout | object | — | グリッド上の位置(省略時は自動配置) |
colorVariant | enum | — | KPI / カードのアクセントカラー |
compareTo | enum | object | — | 期間比較のウィンドウ |
filterBindings | object | — | ウィジェットごとのグローバルフィルターの対応付け(下記) |
チャートの種類
| 種類 | 最適な用途 |
|---|---|
metric (デフォルト) | 単一の数値の KPI:売上、件数、割合 |
bar / horizontal-bar / column | カテゴリーの比較 |
line | 時間の経過による傾向 |
pie / donut | 分布 |
area | 時間の経過による量 |
scatter | 相関 |
radar | 多次元の比較 |
funnel | コンバージョンの段階 |
gauge / solid-gauge / bullet / kpi | 目標に対する進捗 |
treemap / sankey | 階層の比率 / 流れ |
table | 詳細なレコード:ドリルスルー |
pivot | クロス集計:ドリルスルー |
レイアウト
ウィジェットは 12 列のグリッドに配置されます。
// Keys of a dashboard widget; its other keys are omitted.
layout: {
x: 0, // column position (0-11)
y: 0, // row position
w: 6, // width in columns (1-12)
h: 4, // height in rows
}ドリルダウン
table と pivot のウィジェットはドリルスルーできます。集計された行やセルをクリックすると、そのグループの背後にある元のレコードを一覧するサイドドロワーが開きます。データセットは生のグループキーを保持しているので、ドロワーのフィルターは正確なレコードに一致します。ラベルから ID を推測することはありません。ドロワー内の任意の行をクリックすると、そのレコードの詳細が開きます。グループ → レコード一覧 → レコードという一連の流れです。
ドロワーには "Open in list →" という逃げ道もあり、同じドリルのフィルターで範囲を絞ったまま、のぞき見をオブジェクトの完全なリストページ(並べ替え、一括選択、エクスポート、共有できる URL)に格上げします。
チャートのウィジェットも同じようにドリルできます。棒、点、扇形をクリックすると、ドロワーにそのバケットのレコードが一覧されます。日付のディメンションなら、そのバケットの日付範囲ぴったりです。データセットが基になるオブジェクトを公開し、ウィジェットが少なくとも 1 つのディメンションでグループ化していれば、ドリルスルーは自動的に働き、ウィジェットごとの設定は不要です。metric のタイルは集計値だけを表示します。レポートも同じようにドリルスルーできます。
グローバルな日付範囲とフィルター
グローバルな時間のフィルターはすべてのウィジェットに適用されます。
// Keys of a dashboard; its other keys are omitted.
dateRange: { field: 'created_at', defaultRange: 'this_month', allowCustomRange: true }プリセットの範囲:today、yesterday、this_week、last_week、this_month、last_month、this_quarter、last_quarter、this_year、last_year、last_7_days、last_30_days、last_90_days、custom。
対話的なグローバルフィルターも同じように働きます。
// Keys of a dashboard; its other keys are omitted.
globalFilters: [
{ name: 'region', field: 'region', label: 'Region', type: 'select' },
{ field: 'owner', label: 'Sales Rep', type: 'lookup' },
]各フィルターの name(デフォルトは field)がその安定した識別子です。ウィジェットが filterBindings で参照するキーであり、ウィジェットの式の中で page.<name> として読めるダッシュボードレベルの変数です。dateRange という名前は組み込みの日付範囲のために予約されています。
ウィジェットごとのフィルターのバインディング
デフォルトでは、フィルターはすべてのウィジェットで自身の field に適用されます。ウィジェットがその概念を別のフィールドに保持している場合、またはフィルターを無視すべき場合は、filterBindings を宣言します。
// Keys of a dashboard; each widget's dataset, values and title are omitted (`/* … */`).
widgets: [
// Default binding: dateRange → created_at, region → region.
{ id: 'invoices_by_status', /* … */ },
// This widget's fields differ — map each filter explicitly.
{ id: 'accounts_signed',
filterBindings: { dateRange: 'signed_at', region: 'sales_region' }, /* … */ },
// Opt out of a filter with `false`.
{ id: 'total_invoices', filterBindings: { region: false }, /* … */ },
]優先順位:明示的な
filterBindingsのエントリ(文字列による上書き、またはfalseによるオプトアウト)→ フィルターの旧来のtargetWidgets許可リスト → フィルター自身のfield。
ダッシュボードを表示する
アプリに dashboard のナビゲーションエントリを追加します。
// One navigation item of an app.
{ id: 'nav_analytics', type: 'dashboard', label: 'Analytics',
dashboardName: 'sales_overview', icon: 'bar-chart' }あるいは AI Builder に説明します(「地域別の売上と月次の商談の推移を含む営業概要ダッシュボード」)。そして承認する前に、生成されたデータセット + ダッシュボードのメタデータを確認します。