@mogura/moguchart-react 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +165 -32
- package/README.md +166 -33
- package/dist/index.d.ts +4 -1
- package/dist/moguchart-react.mjs +4 -1
- package/dist/moguchart-react.umd.js +1 -1
- package/package.json +3 -3
package/README.ja.md
CHANGED
|
@@ -11,7 +11,10 @@ Lit 公式の `@lit/react` をベースに設計されており、Web Components
|
|
|
11
11
|
- ⚛️ **ネイティブな React 開発体験**: JSX で直感的にプロパティ・イベントハンドラーを記述可能
|
|
12
12
|
- 🎯 **完全な型補完**: TypeScript による強力な型推論と自動補完
|
|
13
13
|
- 🔄 **ライフサイクル同期**: React の状態変更(State / Props)と Web Components のレンダリングを自動同期
|
|
14
|
-
- ⚡ **命令的メソッドへのアクセス**: `ref` を介して `chart.use()`, `chart.exportImage()`, `chart.selectTask()` などを直接呼び出し可能
|
|
14
|
+
- ⚡ **命令的メソッドへのアクセス**: `ref` を介して `chart.use()`, `chart.exportImage()`, `chart.exportExcel()`, `chart.selectTask()` などを直接呼び出し可能
|
|
15
|
+
- 🔌 **プラグイン連携**: `@mogura/moguchart-plugin-export` (PNG/PDF) や `@mogura/moguchart-plugin-excel` (Excel) などの公式プラグインをシームレスに利用可能
|
|
16
|
+
- 📈 **予実管理 (Baseline) 対応**: `task.baseline` と `option.baseline` による計画 vs 実績の同時可視化と遅延検知に対応
|
|
17
|
+
- 📋 **マルチカラムデータグリッド & インライン編集**: `option.grid` による複数列WBSテーブル表示・列幅リサイズ・セル直接編集(`onCellEdit`, `onColumnResize`)に対応
|
|
15
18
|
- 📦 **Re-export**: `@mogura/moguchart-core` の型定義や定数をすべて再エクスポートしているため、本パッケージのみのインストールで開発可能
|
|
16
19
|
|
|
17
20
|
---
|
|
@@ -126,16 +129,90 @@ export function GanttToolbar() {
|
|
|
126
129
|
<button onClick={() => chartRef.current?.zoomIn()}>ズームイン</button>
|
|
127
130
|
<button onClick={() => chartRef.current?.zoomOut()}>ズームアウト</button>
|
|
128
131
|
<button onClick={() => chartRef.current?.resetZoom()}>ズームリセット</button>
|
|
132
|
+
<button onClick={() => chartRef.current?.scrollToTask('task-1')}>タスクへ移動</button>
|
|
129
133
|
<GanttChart ref={chartRef} rows={[]} />
|
|
130
134
|
</div>
|
|
131
135
|
)
|
|
132
136
|
}
|
|
133
137
|
```
|
|
134
138
|
|
|
139
|
+
### 利用可能な主なメソッド・プロパティ
|
|
140
|
+
|
|
141
|
+
`ref.current` 経由で以下のメソッドを直接呼び出すことができます:
|
|
142
|
+
|
|
143
|
+
- **操作履歴 (Undo / Redo)**: `undo()`, `redo()`, `clearHistory()`, `recordCommand(cmd)`, `canUndo`, `canRedo`
|
|
144
|
+
- **ズーム操作**: `zoomIn()`, `zoomOut()`, `zoomToPercent(percent)`, `zoomToScale(scale)`, `resetZoom()`, `zoomToFit()`, `getZoomPercent()`, `getZoomScale()`
|
|
145
|
+
- **スクロール・選択**: `scrollToTask(taskId)`, `scrollToPosition(pos)`, `resetScroll()`, `selectTask(taskId)`
|
|
146
|
+
- **WBS・折りたたみ**: `toggleRowCollapse(rowId, collapsed?)`, `collapseAll()`, `expandAll()`, `getRowPositions()`
|
|
147
|
+
- **グリッド・インラインセル編集**: `startCellEdit(rowId, columnId)`, `commitCellEdit(overrideValue?)`, `cancelCellEdit()`
|
|
148
|
+
- **依存関係操作**: `triggerDependencyDelete(sourceTaskId, targetTaskId)`, `selectDependency(...)`, `clearDependencySelection()`
|
|
149
|
+
- **画像・PDFエクスポート**: `exportImage(format, options)`(`@mogura/moguchart-plugin-export` 導入時)
|
|
150
|
+
- **Excelエクスポート**: `exportExcel(options)`(`@mogura/moguchart-plugin-excel` 導入時)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 予実管理(Baseline / 計画 vs 実績の可視化)
|
|
155
|
+
|
|
156
|
+
タスクに当初計画(`baseline`)を定義し、`option.baseline` を設定することで、計画日程と現在の実績日程を同一レーン上に同時描画・比較できます。遅延タスク(`task.end > baseline.end`)は視覚的にハイライトされ、ツールチップに遅延日数などが自動表示されます。
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import React, { useState } from 'react'
|
|
160
|
+
import {
|
|
161
|
+
GanttChart,
|
|
162
|
+
type GanttRow,
|
|
163
|
+
type GanttChartOption,
|
|
164
|
+
} from '@mogura/moguchart-react'
|
|
165
|
+
|
|
166
|
+
export function BaselineGanttView() {
|
|
167
|
+
const [rows] = useState<GanttRow[]>([
|
|
168
|
+
{
|
|
169
|
+
id: 'row-1',
|
|
170
|
+
name: '開発フェーズ',
|
|
171
|
+
tasks: [
|
|
172
|
+
{
|
|
173
|
+
id: 'task-1',
|
|
174
|
+
name: 'コア機能実装',
|
|
175
|
+
start: new Date('2026-04-05'),
|
|
176
|
+
end: new Date('2026-04-18'), // 当初予定より遅延
|
|
177
|
+
progress: 60,
|
|
178
|
+
baseline: {
|
|
179
|
+
start: new Date('2026-04-01'),
|
|
180
|
+
end: new Date('2026-04-12'),
|
|
181
|
+
progress: 100,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
])
|
|
187
|
+
|
|
188
|
+
const option: GanttChartOption = {
|
|
189
|
+
calendar: {
|
|
190
|
+
start: new Date('2026-04-01'),
|
|
191
|
+
end: new Date('2026-04-30'),
|
|
192
|
+
pxPerDay: 40,
|
|
193
|
+
},
|
|
194
|
+
baseline: {
|
|
195
|
+
enabled: true, // ベースライン表示を有効化
|
|
196
|
+
position: 'bottom', // 'bottom' (下部) | 'top' (上部) | 'overlay' (重ねて表示)
|
|
197
|
+
highlightDelay: true, // 遅延タスクをハイライト強調
|
|
198
|
+
delayColor: '#EF4444', // 遅延強調アクセント色
|
|
199
|
+
},
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<div style={{ width: '100%', height: '500px' }}>
|
|
204
|
+
<GanttChart rows={rows} option={option} />
|
|
205
|
+
</div>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
135
210
|
---
|
|
136
211
|
|
|
137
212
|
## プラグイン(エクスポート機能)との連携
|
|
138
213
|
|
|
214
|
+
### PNG / PDF エクスポート (`@mogura/moguchart-plugin-export`)
|
|
215
|
+
|
|
139
216
|
PNG や PDF のエクスポートを行う場合は、`@mogura/moguchart-plugin-export` を組み合わせます。
|
|
140
217
|
|
|
141
218
|
```tsx
|
|
@@ -164,9 +241,60 @@ export function ExportableGantt() {
|
|
|
164
241
|
}
|
|
165
242
|
}
|
|
166
243
|
|
|
244
|
+
const handleExportPdf = async () => {
|
|
245
|
+
if (chartRef.current) {
|
|
246
|
+
await chartRef.current.exportImage('pdf', {
|
|
247
|
+
filename: 'my-schedule',
|
|
248
|
+
download: true,
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
167
253
|
return (
|
|
168
254
|
<div>
|
|
169
255
|
<button onClick={handleExportPng}>PNGダウンロード</button>
|
|
256
|
+
<button onClick={handleExportPdf}>PDFダウンロード</button>
|
|
257
|
+
<GanttChart ref={chartRef} rows={[]} option={option} />
|
|
258
|
+
</div>
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Excel (.xlsx) タイムライン工程表エクスポート (`@mogura/moguchart-plugin-excel`)
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import React, { useRef } from 'react'
|
|
267
|
+
import { GanttChart, type GanttChartElement, type GanttChartOption } from '@mogura/moguchart-react'
|
|
268
|
+
import { excelPlugin } from '@mogura/moguchart-plugin-excel'
|
|
269
|
+
|
|
270
|
+
export function ExcelExportGantt() {
|
|
271
|
+
const chartRef = useRef<GanttChartElement>(null)
|
|
272
|
+
|
|
273
|
+
const option: GanttChartOption = {
|
|
274
|
+
calendar: {
|
|
275
|
+
start: new Date('2026-04-01'),
|
|
276
|
+
end: new Date('2026-04-30'),
|
|
277
|
+
},
|
|
278
|
+
plugins: [excelPlugin({
|
|
279
|
+
defaultFilename: 'プロジェクト工程表.xlsx',
|
|
280
|
+
defaultSheetName: '工程表',
|
|
281
|
+
themeColor: '#3B82F6',
|
|
282
|
+
})],
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const handleExportExcel = async () => {
|
|
286
|
+
if (chartRef.current) {
|
|
287
|
+
await chartRef.current.exportExcel({
|
|
288
|
+
filename: '工程表_最新.xlsx',
|
|
289
|
+
locale: 'ja', // 'ja' | 'en' | 'zh'
|
|
290
|
+
download: true,
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<div>
|
|
297
|
+
<button onClick={handleExportExcel}>Excel工程表ダウンロード</button>
|
|
170
298
|
<GanttChart ref={chartRef} rows={[]} option={option} />
|
|
171
299
|
</div>
|
|
172
300
|
)
|
|
@@ -177,37 +305,42 @@ export function ExportableGantt() {
|
|
|
177
305
|
|
|
178
306
|
## サポートされているイベント
|
|
179
307
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
|
183
|
-
|
|
184
|
-
| `
|
|
185
|
-
| `
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
205
|
-
| `
|
|
206
|
-
| `
|
|
207
|
-
| `
|
|
208
|
-
| `
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
308
|
+
React では標準のイベント Props としてキャメルケース(`onTaskUpdate` 等)で購読できます:
|
|
309
|
+
|
|
310
|
+
| Prop 名 | 説明 | イベント引数型 |
|
|
311
|
+
|---|---|---|
|
|
312
|
+
| `onTaskUpdate` | タスクのドラッグ移動やリサイズ完了時 | `CustomEvent<TaskUpdateEventDetail>` |
|
|
313
|
+
| `onTaskClick` | タスククリック時 | `CustomEvent<TaskClickEventDetail>` |
|
|
314
|
+
| `onTaskDblClick` | タスクダブルクリック時 | `CustomEvent<TaskClickEventDetail>` |
|
|
315
|
+
| `onTaskContextMenu` | タスク右クリック(コンテキストメニュー)時 | `CustomEvent<TaskContextMenuEventDetail>` |
|
|
316
|
+
| `onTaskDelete` | タスク削除時 | `CustomEvent<TaskDeleteEventDetail>` |
|
|
317
|
+
| `onTaskDrop` | タスクを行間等にドロップした時 | `CustomEvent<TaskDropEventDetail>` |
|
|
318
|
+
| `onTaskProgressChange` | 進捗率変更時 | `CustomEvent<TaskProgressChangeEventDetail>` |
|
|
319
|
+
| `onBarHover` | タスクバーホバー時 | `CustomEvent<BarHoverEventDetail>` |
|
|
320
|
+
| `onBarSelectionChange` | タスク選択状態の変更時 | `CustomEvent<BarSelectionChangeEventDetail>` |
|
|
321
|
+
| `onRowHeaderClick` | 行ヘッダークリック時 | `CustomEvent<RowHeaderClickEventDetail>` |
|
|
322
|
+
| `onRowHeaderDblClick` | 行ヘッダーダブルクリック時(`contentTarget` で行名要素を参照可能) | `CustomEvent<RowHeaderDblClickEventDetail>` |
|
|
323
|
+
| `onRowHeaderContextMenu` | 行ヘッダー右クリック時 | `CustomEvent<RowHeaderContextMenuEventDetail>` |
|
|
324
|
+
| `onRowHeaderResize` | 行ヘッダーリサイズ時 | `CustomEvent<RowHeaderResizeEventDetail>` |
|
|
325
|
+
| `onColumnResize` | マルチカラムグリッドの列幅リサイズ時 | `CustomEvent<ColumnResizeEventDetail>` |
|
|
326
|
+
| `onCellEdit` | マルチカラムグリッドのインラインセル編集確定時 | `CustomEvent<CellEditEventDetail>` |
|
|
327
|
+
| `onRowsChange` | 行データ変更時 | `CustomEvent<RowsChangeEventDetail>` |
|
|
328
|
+
| `onRowReordered` | 行の並び順変更時 | `CustomEvent<RowReorderEventDetail>` |
|
|
329
|
+
| `onRowSelectionChange` | 行選択状態の変更時 | `CustomEvent<RowSelectionChangeEventDetail>` |
|
|
330
|
+
| `onRowToggleCollapse` | 行の開閉時(WBS) | `CustomEvent<RowToggleCollapseEventDetail>` |
|
|
331
|
+
| `onDependencyCreate` | 依存関係(リンク)作成時 | `CustomEvent<DependencyCreateEventDetail>` |
|
|
332
|
+
| `onDependencyClick` | 依存関係クリック時 | `CustomEvent<DependencyClickEventDetail>` |
|
|
333
|
+
| `onDependencySelect` | 依存関係の選択状態変更時(ハイライト・削除ボタン表示) | `CustomEvent<DependencySelectEventDetail>` |
|
|
334
|
+
| `onDependencyDelete` | 依存関係削除時 | `CustomEvent<DependencyDeleteEventDetail>` |
|
|
335
|
+
| `onMarkerDblClick` | マーカーダブルクリック時 | `CustomEvent<MarkerDblClickEventDetail>` |
|
|
336
|
+
| `onMarkerContextMenu` | マーカー右クリック時 | `CustomEvent<MarkerContextMenuEventDetail>` |
|
|
337
|
+
| `onZoomChange` | ズーム倍率変更時 | `CustomEvent<ZoomChangeEventDetail>` |
|
|
338
|
+
| `onCommand` | 操作コマンド実行時(Undo / Redo 対象の操作完了時) | `CustomEvent<CommandEventDetail>` |
|
|
339
|
+
| `onHistoryChange` | 履歴スタック変更時(Undo / Redo 可否状態の更新時) | `CustomEvent<HistoryChangeEventDetail>` |
|
|
340
|
+
| `onMinimapMove` | ミニマップスクロール時 | `CustomEvent<MinimapMoveEventDetail>` |
|
|
341
|
+
| `onMinimapResize` | ミニマップリサイズ時 | `CustomEvent<MinimapResizeEventDetail>` |
|
|
342
|
+
| `onMinimapCollapse` | ミニマップ折りたたみ時 | `CustomEvent<MinimapCollapseEventDetail>` |
|
|
343
|
+
| `onChartContextMenu` | チャート背景右クリック時 | `CustomEvent<ChartContextMenuEventDetail>` |
|
|
211
344
|
|
|
212
345
|
---
|
|
213
346
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,10 @@ Built on top of Lit's official `@lit/react`, it combines the high performance an
|
|
|
13
13
|
- ⚛️ **Native React Experience**: Declarative JSX props and event handlers
|
|
14
14
|
- 🎯 **Full Type Safety**: Complete TypeScript auto-completion for props and events
|
|
15
15
|
- 🔄 **Lifecycle Synchronization**: Automatic synchronization between React state/props and Web Component rendering
|
|
16
|
-
- ⚡ **Imperative API Access**: Directly access methods like `chart.use()`, `chart.exportImage()`, `chart.selectTask()` via `ref`
|
|
16
|
+
- ⚡ **Imperative API Access**: Directly access methods like `chart.use()`, `chart.exportImage()`, `chart.exportExcel()`, `chart.selectTask()` via `ref`
|
|
17
|
+
- 🔌 **Plugin Support**: Seamless integration with `@mogura/moguchart-plugin-export` (PNG/PDF) and `@mogura/moguchart-plugin-excel` (Excel)
|
|
18
|
+
- 📈 **Baseline & Delay Tracking**: Compare planned schedules (`task.baseline`) against actual timelines with automatic delay highlighting and variance tooltips
|
|
19
|
+
- 📋 **Multi-Column Data Grid & Inline Editing**: WBS data table (`option.grid`) with column resizing and inline cell editing (`onCellEdit`, `onColumnResize`)
|
|
17
20
|
- 📦 **Re-exported Types**: Core types, constants, and utilities are all re-exported from this package
|
|
18
21
|
|
|
19
22
|
---
|
|
@@ -128,15 +131,89 @@ export function GanttToolbar() {
|
|
|
128
131
|
<button onClick={() => chartRef.current?.zoomIn()}>Zoom In</button>
|
|
129
132
|
<button onClick={() => chartRef.current?.zoomOut()}>Zoom Out</button>
|
|
130
133
|
<button onClick={() => chartRef.current?.resetZoom()}>Reset Zoom</button>
|
|
134
|
+
<button onClick={() => chartRef.current?.scrollToTask('task-1')}>Scroll to Task</button>
|
|
131
135
|
<GanttChart ref={chartRef} rows={[]} />
|
|
132
136
|
</div>
|
|
133
137
|
)
|
|
134
138
|
}
|
|
135
139
|
```
|
|
136
140
|
|
|
141
|
+
### Available Methods & Properties
|
|
142
|
+
|
|
143
|
+
The following methods can be invoked directly on `ref.current`:
|
|
144
|
+
|
|
145
|
+
- **Operation History (Undo / Redo)**: `undo()`, `redo()`, `clearHistory()`, `recordCommand(cmd)`, `canUndo`, `canRedo`
|
|
146
|
+
- **Zoom Operations**: `zoomIn()`, `zoomOut()`, `zoomToPercent(percent)`, `zoomToScale(scale)`, `resetZoom()`, `zoomToFit()`, `getZoomPercent()`, `getZoomScale()`
|
|
147
|
+
- **Scroll & Selection**: `scrollToTask(taskId)`, `scrollToPosition(pos)`, `resetScroll()`, `selectTask(taskId)`
|
|
148
|
+
- **WBS & Collapse**: `toggleRowCollapse(rowId, collapsed?)`, `collapseAll()`, `expandAll()`, `getRowPositions()`
|
|
149
|
+
- **Grid & Inline Cell Editing**: `startCellEdit(rowId, columnId)`, `commitCellEdit(overrideValue?)`, `cancelCellEdit()`
|
|
150
|
+
- **Dependency Operations**: `triggerDependencyDelete(sourceTaskId, targetTaskId)`, `selectDependency(...)`, `clearDependencySelection()`
|
|
151
|
+
- **Image & PDF Export**: `exportImage(format, options)` (with `@mogura/moguchart-plugin-export`)
|
|
152
|
+
- **Excel Export**: `exportExcel(options)` (with `@mogura/moguchart-plugin-excel`)
|
|
153
|
+
|
|
137
154
|
---
|
|
138
155
|
|
|
139
|
-
##
|
|
156
|
+
## Baseline & Schedule Variance Tracking (Plan vs. Actual)
|
|
157
|
+
|
|
158
|
+
Provide a baseline schedule on tasks (`task.baseline`) and configure `option.baseline` to visually compare planned timelines against current actual progress. Delayed tasks (`task.end > baseline.end`) are automatically highlighted with accent indicator lines and detailed variance tooltips.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import React, { useState } from 'react'
|
|
162
|
+
import {
|
|
163
|
+
GanttChart,
|
|
164
|
+
type GanttRow,
|
|
165
|
+
type GanttChartOption,
|
|
166
|
+
} from '@mogura/moguchart-react'
|
|
167
|
+
|
|
168
|
+
export function BaselineGanttView() {
|
|
169
|
+
const [rows] = useState<GanttRow[]>([
|
|
170
|
+
{
|
|
171
|
+
id: 'row-1',
|
|
172
|
+
name: 'Development Phase',
|
|
173
|
+
tasks: [
|
|
174
|
+
{
|
|
175
|
+
id: 'task-1',
|
|
176
|
+
name: 'Core Features',
|
|
177
|
+
start: new Date('2026-04-05'),
|
|
178
|
+
end: new Date('2026-04-18'), // Delayed beyond original plan
|
|
179
|
+
progress: 60,
|
|
180
|
+
baseline: {
|
|
181
|
+
start: new Date('2026-04-01'),
|
|
182
|
+
end: new Date('2026-04-12'),
|
|
183
|
+
progress: 100,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
])
|
|
189
|
+
|
|
190
|
+
const option: GanttChartOption = {
|
|
191
|
+
calendar: {
|
|
192
|
+
start: new Date('2026-04-01'),
|
|
193
|
+
end: new Date('2026-04-30'),
|
|
194
|
+
pxPerDay: 40,
|
|
195
|
+
},
|
|
196
|
+
baseline: {
|
|
197
|
+
enabled: true, // Enable baseline rendering
|
|
198
|
+
position: 'bottom', // 'bottom' | 'top' | 'overlay'
|
|
199
|
+
highlightDelay: true, // Visually highlight delayed tasks
|
|
200
|
+
delayColor: '#EF4444', // Custom accent color for delay indicators
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<div style={{ width: '100%', height: '500px' }}>
|
|
206
|
+
<GanttChart rows={rows} option={option} />
|
|
207
|
+
</div>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Using with Plugins (Export, Excel, etc.)
|
|
215
|
+
|
|
216
|
+
### PNG / PDF Export (`@mogura/moguchart-plugin-export`)
|
|
140
217
|
|
|
141
218
|
To export charts as PNG or PDF, pair with `@mogura/moguchart-plugin-export`:
|
|
142
219
|
|
|
@@ -166,9 +243,60 @@ export function ExportableGantt() {
|
|
|
166
243
|
}
|
|
167
244
|
}
|
|
168
245
|
|
|
246
|
+
const handleExportPdf = async () => {
|
|
247
|
+
if (chartRef.current) {
|
|
248
|
+
await chartRef.current.exportImage('pdf', {
|
|
249
|
+
filename: 'my-schedule',
|
|
250
|
+
download: true,
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
169
255
|
return (
|
|
170
256
|
<div>
|
|
171
257
|
<button onClick={handleExportPng}>Download PNG</button>
|
|
258
|
+
<button onClick={handleExportPdf}>Download PDF</button>
|
|
259
|
+
<GanttChart ref={chartRef} rows={[]} option={option} />
|
|
260
|
+
</div>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Excel (.xlsx) Timeline Spreadsheet Export (`@mogura/moguchart-plugin-excel`)
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
import React, { useRef } from 'react'
|
|
269
|
+
import { GanttChart, type GanttChartElement, type GanttChartOption } from '@mogura/moguchart-react'
|
|
270
|
+
import { excelPlugin } from '@mogura/moguchart-plugin-excel'
|
|
271
|
+
|
|
272
|
+
export function ExcelExportGantt() {
|
|
273
|
+
const chartRef = useRef<GanttChartElement>(null)
|
|
274
|
+
|
|
275
|
+
const option: GanttChartOption = {
|
|
276
|
+
calendar: {
|
|
277
|
+
start: new Date('2026-04-01'),
|
|
278
|
+
end: new Date('2026-04-30'),
|
|
279
|
+
},
|
|
280
|
+
plugins: [excelPlugin({
|
|
281
|
+
defaultFilename: 'project-schedule.xlsx',
|
|
282
|
+
defaultSheetName: 'Schedule',
|
|
283
|
+
themeColor: '#3B82F6',
|
|
284
|
+
})],
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const handleExportExcel = async () => {
|
|
288
|
+
if (chartRef.current) {
|
|
289
|
+
await chartRef.current.exportExcel({
|
|
290
|
+
filename: 'schedule-latest.xlsx',
|
|
291
|
+
locale: 'en', // 'en' | 'ja' | 'zh'
|
|
292
|
+
download: true,
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<div>
|
|
299
|
+
<button onClick={handleExportExcel}>Download Excel Schedule</button>
|
|
172
300
|
<GanttChart ref={chartRef} rows={[]} option={option} />
|
|
173
301
|
</div>
|
|
174
302
|
)
|
|
@@ -179,37 +307,42 @@ export function ExportableGantt() {
|
|
|
179
307
|
|
|
180
308
|
## Supported Events
|
|
181
309
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
|
185
|
-
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
205
|
-
| `
|
|
206
|
-
| `
|
|
207
|
-
| `
|
|
208
|
-
| `
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
310
|
+
Events dispatched by `@mogura/moguchart-core` can be listened to via standard camelCase React props:
|
|
311
|
+
|
|
312
|
+
| Prop | Description | Event Argument Type |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `onTaskUpdate` | Fired when a task is moved or resized | `CustomEvent<TaskUpdateEventDetail>` |
|
|
315
|
+
| `onTaskClick` | Fired when a task is clicked | `CustomEvent<TaskClickEventDetail>` |
|
|
316
|
+
| `onTaskDblClick` | Fired when a task is double-clicked | `CustomEvent<TaskClickEventDetail>` |
|
|
317
|
+
| `onTaskContextMenu` | Fired on task right-click | `CustomEvent<TaskContextMenuEventDetail>` |
|
|
318
|
+
| `onTaskDelete` | Fired when a task is deleted | `CustomEvent<TaskDeleteEventDetail>` |
|
|
319
|
+
| `onTaskDrop` | Fired when a task is dropped | `CustomEvent<TaskDropEventDetail>` |
|
|
320
|
+
| `onTaskProgressChange` | Fired when task progress percentage changes | `CustomEvent<TaskProgressChangeEventDetail>` |
|
|
321
|
+
| `onBarHover` | Fired when a task bar is hovered | `CustomEvent<BarHoverEventDetail>` |
|
|
322
|
+
| `onBarSelectionChange` | Fired when task bar selection changes | `CustomEvent<BarSelectionChangeEventDetail>` |
|
|
323
|
+
| `onRowHeaderClick` | Fired when a row header is clicked | `CustomEvent<RowHeaderClickEventDetail>` |
|
|
324
|
+
| `onRowHeaderDblClick` | Fired when a row header is double-clicked (`contentTarget` exposes row name container) | `CustomEvent<RowHeaderDblClickEventDetail>` |
|
|
325
|
+
| `onRowHeaderContextMenu` | Fired on row header right-click | `CustomEvent<RowHeaderContextMenuEventDetail>` |
|
|
326
|
+
| `onRowHeaderResize` | Fired when a row header is resized | `CustomEvent<RowHeaderResizeEventDetail>` |
|
|
327
|
+
| `onColumnResize` | Fired when a grid column is resized | `CustomEvent<ColumnResizeEventDetail>` |
|
|
328
|
+
| `onCellEdit` | Fired when an inline grid cell edit is committed | `CustomEvent<CellEditEventDetail>` |
|
|
329
|
+
| `onRowsChange` | Fired when row data changes | `CustomEvent<RowsChangeEventDetail>` |
|
|
330
|
+
| `onRowReordered` | Fired when rows are reordered | `CustomEvent<RowReorderEventDetail>` |
|
|
331
|
+
| `onRowSelectionChange` | Fired when row selection changes | `CustomEvent<RowSelectionChangeEventDetail>` |
|
|
332
|
+
| `onRowToggleCollapse` | Fired when a row is expanded or collapsed (WBS) | `CustomEvent<RowToggleCollapseEventDetail>` |
|
|
333
|
+
| `onDependencyCreate` | Fired when a dependency link is created | `CustomEvent<DependencyCreateEventDetail>` |
|
|
334
|
+
| `onDependencyClick` | Fired when a dependency link is clicked | `CustomEvent<DependencyClickEventDetail>` |
|
|
335
|
+
| `onDependencySelect` | Fired when dependency selection changes (highlight / delete button shown) | `CustomEvent<DependencySelectEventDetail>` |
|
|
336
|
+
| `onDependencyDelete` | Fired when a dependency link is deleted | `CustomEvent<DependencyDeleteEventDetail>` |
|
|
337
|
+
| `onMarkerDblClick` | Fired when a marker is double-clicked | `CustomEvent<MarkerDblClickEventDetail>` |
|
|
338
|
+
| `onMarkerContextMenu` | Fired on marker right-click | `CustomEvent<MarkerContextMenuEventDetail>` |
|
|
339
|
+
| `onZoomChange` | Fired when zoom scale changes | `CustomEvent<ZoomChangeEventDetail>` |
|
|
340
|
+
| `onCommand` | Fired when a command is executed (tracked for Undo/Redo) | `CustomEvent<CommandEventDetail>` |
|
|
341
|
+
| `onHistoryChange` | Fired when history stack changes (`canUndo`/`canRedo` updated) | `CustomEvent<HistoryChangeEventDetail>` |
|
|
342
|
+
| `onMinimapMove` | Fired when minimap viewport scrolls | `CustomEvent<MinimapMoveEventDetail>` |
|
|
343
|
+
| `onMinimapResize` | Minimap is resized | `CustomEvent<MinimapResizeEventDetail>` |
|
|
344
|
+
| `onMinimapCollapse` | Minimap is collapsed or expanded | `CustomEvent<MinimapCollapseEventDetail>` |
|
|
345
|
+
| `onChartContextMenu` | Fired on chart background right-click | `CustomEvent<ChartContextMenuEventDetail>` |
|
|
213
346
|
|
|
214
347
|
---
|
|
215
348
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type EventName } from '@lit/react';
|
|
3
|
-
import { GanttChartElement, type ChartContextMenuEventDetail, type MinimapMoveEventDetail, type MinimapResizeEventDetail, type MinimapCollapseEventDetail, type TaskUpdateEventDetail, type BarHoverEventDetail, type TaskClickEventDetail, type TaskContextMenuEventDetail, type TaskDropEventDetail, type RowReorderEventDetail, type RowHeaderResizeEventDetail, type RowSelectionChangeEventDetail, type BarSelectionChangeEventDetail, type RowHeaderClickEventDetail, type RowHeaderDblClickEventDetail, type RowHeaderContextMenuEventDetail, type RowToggleCollapseEventDetail, type DependencyCreateEventDetail, type DependencyClickEventDetail, type DependencyDeleteEventDetail, type DependencySelectEventDetail, type MarkerDblClickEventDetail, type MarkerContextMenuEventDetail, type TaskDeleteEventDetail, type ZoomChangeEventDetail, type TaskProgressChangeEventDetail, type CommandEventDetail, type HistoryChangeEventDetail } from '@mogura/moguchart-core';
|
|
3
|
+
import { GanttChartElement, type ChartContextMenuEventDetail, type MinimapMoveEventDetail, type MinimapResizeEventDetail, type MinimapCollapseEventDetail, type TaskUpdateEventDetail, type BarHoverEventDetail, type TaskClickEventDetail, type TaskContextMenuEventDetail, type TaskDropEventDetail, type RowReorderEventDetail, type RowHeaderResizeEventDetail, type RowSelectionChangeEventDetail, type BarSelectionChangeEventDetail, type RowHeaderClickEventDetail, type RowHeaderDblClickEventDetail, type RowHeaderContextMenuEventDetail, type RowToggleCollapseEventDetail, type DependencyCreateEventDetail, type DependencyClickEventDetail, type DependencyDeleteEventDetail, type DependencySelectEventDetail, type MarkerDblClickEventDetail, type MarkerContextMenuEventDetail, type TaskDeleteEventDetail, type ZoomChangeEventDetail, type TaskProgressChangeEventDetail, type CommandEventDetail, type HistoryChangeEventDetail, type ColumnResizeEventDetail, type CellEditEventDetail, type RowsChangeEventDetail } from '@mogura/moguchart-core';
|
|
4
4
|
/**
|
|
5
5
|
* @mogura/moguchart-core の GanttChartElement をラップした React コンポーネント。
|
|
6
6
|
* Web Components のライフサイクルと完全同期し、React のプロパティやイベントハンドラー、ref をサポートします。
|
|
@@ -35,6 +35,9 @@ export declare const GanttChart: import("@lit/react").ReactWebComponent<GanttCha
|
|
|
35
35
|
onTaskProgressChange: EventName<CustomEvent<TaskProgressChangeEventDetail>>;
|
|
36
36
|
onCommand: EventName<CustomEvent<CommandEventDetail>>;
|
|
37
37
|
onHistoryChange: EventName<CustomEvent<HistoryChangeEventDetail>>;
|
|
38
|
+
onColumnResize: EventName<CustomEvent<ColumnResizeEventDetail>>;
|
|
39
|
+
onCellEdit: EventName<CustomEvent<CellEditEventDetail>>;
|
|
40
|
+
onRowsChange: EventName<CustomEvent<RowsChangeEventDetail>>;
|
|
38
41
|
}>;
|
|
39
42
|
/** GanttChart コンポーネントの Props 型定義 */
|
|
40
43
|
export type GanttChartProps = React.ComponentProps<typeof GanttChart>;
|
package/dist/moguchart-react.mjs
CHANGED
|
@@ -36,7 +36,10 @@ var r = t({
|
|
|
36
36
|
onZoomChange: "zoom-change",
|
|
37
37
|
onTaskProgressChange: "task-progress-change",
|
|
38
38
|
onCommand: "command",
|
|
39
|
-
onHistoryChange: "history-change"
|
|
39
|
+
onHistoryChange: "history-change",
|
|
40
|
+
onColumnResize: "column-resize",
|
|
41
|
+
onCellEdit: "cell-edit",
|
|
42
|
+
onRowsChange: "rows-change"
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@lit/react"),require("@mogura/moguchart-core")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@lit/react`,`@mogura/moguchart-core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MoguchartReact={},e.React,e.LitReact,e.MoguchartCore))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:i(c(e)),u(t||!e||!e.__esModule||!l.call(e,`default`)?a(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1),e.GanttChart=(0,n.createComponent)({tagName:`gantt-chart`,elementClass:r.GanttChartElement,react:t.default,events:{onChartContextMenu:`chart-contextmenu`,onMinimapMove:`minimap-move`,onMinimapResize:`minimap-resize`,onMinimapCollapse:`minimap-collapse`,onTaskUpdate:`task-update`,onBarHover:`bar-hover`,onTaskClick:`task-click`,onTaskDblClick:`task-dblclick`,onTaskContextMenu:`task-contextmenu`,onTaskDrop:`task-drop`,onRowReordered:`row-reordered`,onRowHeaderResize:`row-header-resize`,onRowSelectionChange:`row-selection-change`,onBarSelectionChange:`bar-selection-change`,onRowHeaderClick:`row-header-click`,onRowHeaderDblClick:`row-header-dblclick`,onRowHeaderContextMenu:`row-header-contextmenu`,onRowToggleCollapse:`row-toggle-collapse`,onDependencyCreate:`dependency-create`,onDependencyClick:`dependency-click`,onDependencyDelete:`dependency-delete`,onDependencySelect:`dependency-select`,onMarkerDblClick:`marker-dblclick`,onMarkerContextMenu:`marker-contextmenu`,onTaskDelete:`task-delete`,onZoomChange:`zoom-change`,onTaskProgressChange:`task-progress-change`,onCommand:`command`,onHistoryChange:`history-change`}}),Object.keys(r).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@lit/react"),require("@mogura/moguchart-core")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@lit/react`,`@mogura/moguchart-core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MoguchartReact={},e.React,e.LitReact,e.MoguchartCore))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:i(c(e)),u(t||!e||!e.__esModule||!l.call(e,`default`)?a(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1),e.GanttChart=(0,n.createComponent)({tagName:`gantt-chart`,elementClass:r.GanttChartElement,react:t.default,events:{onChartContextMenu:`chart-contextmenu`,onMinimapMove:`minimap-move`,onMinimapResize:`minimap-resize`,onMinimapCollapse:`minimap-collapse`,onTaskUpdate:`task-update`,onBarHover:`bar-hover`,onTaskClick:`task-click`,onTaskDblClick:`task-dblclick`,onTaskContextMenu:`task-contextmenu`,onTaskDrop:`task-drop`,onRowReordered:`row-reordered`,onRowHeaderResize:`row-header-resize`,onRowSelectionChange:`row-selection-change`,onBarSelectionChange:`bar-selection-change`,onRowHeaderClick:`row-header-click`,onRowHeaderDblClick:`row-header-dblclick`,onRowHeaderContextMenu:`row-header-contextmenu`,onRowToggleCollapse:`row-toggle-collapse`,onDependencyCreate:`dependency-create`,onDependencyClick:`dependency-click`,onDependencyDelete:`dependency-delete`,onDependencySelect:`dependency-select`,onMarkerDblClick:`marker-dblclick`,onMarkerContextMenu:`marker-contextmenu`,onTaskDelete:`task-delete`,onZoomChange:`zoom-change`,onTaskProgressChange:`task-progress-change`,onCommand:`command`,onHistoryChange:`history-change`,onColumnResize:`column-resize`,onCellEdit:`cell-edit`,onRowsChange:`rows-change`}}),Object.keys(r).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mogura/moguchart-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"description": "React wrapper for @mogura/moguchart-core Gantt chart component",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Murakami Hiroyuki",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18.0.0 || ^19.0.0",
|
|
43
43
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
44
|
-
"@mogura/moguchart-core": "1.
|
|
44
|
+
"@mogura/moguchart-core": "1.5.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@lit/react": "^1.0.8"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
58
|
"vite": "^8.0.0",
|
|
59
59
|
"vitest": "^3.0.0",
|
|
60
|
-
"@mogura/moguchart-core": "1.
|
|
60
|
+
"@mogura/moguchart-core": "1.5.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "vite build && pnpm exec tsc -p tsconfig.build.json",
|