API 參考
Chart
以提供的數值呈現精確比較或趨勢。
presentation.tsx
<Chart id="trend" x={9} y={26} w={82} h={54} type="line" data='[{"label":"Q1","value":42},{"label":"Q2","value":58}]' showAxes="true" showLabels="true" ariaLabel="季度採用率" />屬性參考
屬性值應保持字面且可序列化,才能由 Canvas、Inspector、驗證與匯出流程可靠處理。
| API | 屬性 | 型別/值 | 必要 | 說明 |
|---|---|---|---|---|
| 所有原生圖層共用 props | id | string | 是 | 穩定且唯一的圖層識別字。每個可見的原生圖層都必須提供。 |
| x | number | 是 | 相對於投影片畫布左側的位置百分比。 | |
| y | number | 是 | 相對於投影片畫布頂端的位置百分比。 | |
| w | number | 是 | 圖層寬度,單位為畫布百分比。 | |
| h | number | 是 | 圖層高度,單位為畫布百分比。 | |
| groupId | string | — | 在不加入 wrapper 元素的情況下,將原生子圖層編組。 | |
| groupName | string | — | 在 Workbench 顯示的群組名稱。 | |
| sharedId | string | — | 連接相鄰 Morph 投影片中的同型圖層;在同一張投影片內必須唯一。 | |
| rotation | number | — | 順時針旋轉角度。 | |
| opacity | number | — | 圖層不透明度,範圍為 0 到 1。 | |
| motion | JSON string | — | 版本化的宣告式動作序列 JSON 字串;仍須保留完整的靜態最終畫面。 | |
| interaction | JSON string | — | 版本化的點擊互動 JSON 字串,可用於投影片導覽或連結。 | |
| Chart | type | bar | line | area | pie | donut | scatter | 是 | 圖表呈現類型。 |
| data | JSON string | 是 | 1 到 24 筆資料;每筆都要有有限數值 value,亦可包含 label、x、size、color。 | |
| chartDataByType | JSON string | — | 選用;以圖表類型為 key 的資料集。 | |
| chartPreset | executive | minimal | vivid | — | 視覺 preset。 | |
| chartTheme | light | dark-gold | — | 圖表專用主題。 | |
| palette | aurora | editorial | gilded | ocean | sunset | — | 命名色盤。 | |
| colorMode | palette | single | emphasis | gradient | — | 顏色分配策略。 | |
| emphasisIndex | number | — | 由 color mode 強調的資料索引。 | |
| annotationIndex / annotationText / annotationColor | number | string | — | 選用的註解目標、文字與顏色。 | |
| barGap | compact | balanced | airy | — | 長條圖的間距。 | |
| barRadius / areaOpacity / donutHole | number | — | 長條圓角、面積圖填色不透明度或甜甜圈孔徑。 | |
| lineSmooth | boolean | — | 平滑折線或面積圖路徑。 | |
| showAxes / showGrid / showLabels | boolean | — | 顯示座標軸、格線或標籤。 | |
| labelMode / labelColor | all | value | category | none | color | — | 標籤顯示模式與顏色。 | |
| numberFormat | auto | integer | decimal | percent | currency | compact | — | 數值格式。 | |
| decimals / currency | number | string | — | 小數位數與幣別代碼或符號。 | |
| sort | input | ascending | descending | — | 資料排序方式。 | |
| referenceValue / referenceLabel / referenceColor | number | string | — | 選用的參考線數值、標籤與顏色。 | |
| chartMotion | auto | grow | draw | sweep | pop | none | — | 圖表進場動態。 |
必要語法
使用 id、x、y、w、h、type 與 data;data 是包含 label 與 value 的 JSON 字串,提供的數值會被完整保留。
讓資料可理解
使用附近的 Text 說明單位、期間與來源;showAxes、showLabels、palette 與 chartMotion 都是可在需要時加入的簡報 props。