@mogura/moguchart-core 0.5.3 → 0.7.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.en.md CHANGED
@@ -18,7 +18,7 @@ A lightweight yet feature-rich Gantt chart Web Component built with Lit. Works w
18
18
  - Light/Dark/System theme switching + custom color themes
19
19
  - Task bar fill patterns (13 types including stripes, dots, checkerboard, etc.)
20
20
  - CSS styling
21
- - 🔗 **Dependency Visualization**: Curved lines with arrows showing task dependencies (S-curve support for reverse direction)
21
+ - 🔗 **Dependency Visualization**: Curved lines with arrows showing task dependencies (S-curve support for reverse direction). Automatic critical path detection and highlighting
22
22
  - 📅 **Flexible Calendar**:
23
23
  - Day / Week / Month view switching
24
24
  - Adjustable zoom level (pixels per day or per month) and display period
package/README.md CHANGED
@@ -20,7 +20,7 @@ Vue, React, Angular, Svelte など、どのフレームワークでも動作す
20
20
  - ライト/ダーク/システムテーマの切り替え+カスタムカラーテーマ
21
21
  - タスクバーの塗りつぶしパターン(ストライプ、ドット、チェッカーボードなど13種類)
22
22
  - CSSによるスタイリング
23
- - 🔗 **依存関係の表示**: タスク間の依存関係を矢印付き曲線で可視化(S字カーブ対応)
23
+ - 🔗 **依存関係の表示**: タスク間の依存関係を矢印付き曲線で可視化(S字カーブ対応)。クリティカルパス(最長チェーン)の自動検出+ハイライト表示
24
24
  - 📅 **柔軟なカレンダー**:
25
25
  - 日単位 / 週単位 / 月単位の表示切り替え
26
26
  - ズームレベル(1日・1ヶ月あたりの幅)や表示期間の調整が可能
@@ -7,12 +7,16 @@ export declare class GanttBarElement extends LitElement {
7
7
  selected: boolean;
8
8
  focused: boolean;
9
9
  multiDragDx: number;
10
+ multiDragDy: number;
10
11
  multiDragActive: boolean;
12
+ multiDragSameRow: boolean;
11
13
  connectorDropTarget: boolean;
12
14
  isExporting: boolean;
15
+ isCriticalPath: boolean;
13
16
  private _currentDragCursor;
14
17
  private _dragAnimationFrame;
15
18
  private _wasDragging;
19
+ private _connectorEdgeThreshold;
16
20
  static styles: import("lit").CSSResult;
17
21
  private getX;
18
22
  private setupDragEvents;
@@ -23,6 +27,7 @@ export declare class GanttBarElement extends LitElement {
23
27
  private handleKeyDown;
24
28
  private handleKeyUp;
25
29
  private updateCursor;
30
+ private onMouseMoveOnBar;
26
31
  private onMouseEnter;
27
32
  private onMouseLeave;
28
33
  private onDblClick;
@@ -4,6 +4,7 @@ export declare class GanttCalendarElement extends LitElement {
4
4
  option: GanttChartOption;
5
5
  theme: 'light' | 'dark';
6
6
  currentTime: Date;
7
+ isExporting: boolean;
7
8
  hoveredMilestoneId: string | null;
8
9
  cornerContent?: () => string | unknown;
9
10
  calendarMonthContent?: (context: CalendarMonthCellContext) => string | unknown;
@@ -4,6 +4,7 @@
4
4
  * Shadow DOM の cloneNode では内部コンテンツがコピーされないため、
5
5
  * rows / option / theme などのデータから SVG を直接描画します。
6
6
  */
7
+ import type { GanttChartElement } from './gantt-chart';
7
8
  export interface ExportImageOptions {
8
9
  /** ダウンロード時のファイル名(拡張子なし)。省略時は 'gantt-chart' */
9
10
  filename?: string;
@@ -17,4 +18,4 @@ export interface ExportImageOptions {
17
18
  /**
18
19
  * html2canvas-pro を使用してエクスポートする(Shadow DOMネイティブ対応版)
19
20
  */
20
- export declare function exportGanttWithHtml2Canvas(chartElement: HTMLElement, format?: 'png' | 'pdf', options?: ExportImageOptions): Promise<string | Blob>;
21
+ export declare function exportGanttWithHtml2Canvas(chartElement: GanttChartElement, format?: 'png' | 'pdf', options?: ExportImageOptions): Promise<string | Blob>;
@@ -18,6 +18,8 @@ export declare class GanttChartElement extends LitElement {
18
18
  private draggingTask;
19
19
  private draggingTaskIds;
20
20
  private multiDragDx;
21
+ private multiDragDy;
22
+ private multiDragSameRow;
21
23
  private viewportHeight;
22
24
  private dragOverlayInfo;
23
25
  private calendarHeight;
@@ -36,6 +38,8 @@ export declare class GanttChartElement extends LitElement {
36
38
  private isExporting;
37
39
  private focusedTaskId;
38
40
  private focusedRowId;
41
+ private zoomPxPerDay;
42
+ private zoomPxPerMonth;
39
43
  private _layoutCache;
40
44
  private resizeObserver;
41
45
  private _cachedSelectedTaskIds;
@@ -43,7 +47,18 @@ export declare class GanttChartElement extends LitElement {
43
47
  private _cachedCurrentOption;
44
48
  private _lastOptionRef;
45
49
  private _lastLabelWidth;
50
+ private _lastZoomPxPerDay;
51
+ private _lastZoomPxPerMonth;
52
+ private _scrollContainer;
46
53
  private get displayRows();
54
+ /**
55
+ * 現在有効な pxPerDay(ズームオーバーライドがあればそちらを優先)
56
+ */
57
+ private get effectivePxPerDay();
58
+ /**
59
+ * 現在有効な pxPerMonth(ズームオーバーライドがあればそちらを優先)
60
+ */
61
+ private get effectivePxPerMonth();
47
62
  static styles: import("lit").CSSResult;
48
63
  protected firstUpdated(): void;
49
64
  connectedCallback(): void;
@@ -72,6 +87,11 @@ export declare class GanttChartElement extends LitElement {
72
87
  * ドラッグ中のバーが選択中バーに含まれ、選択数が2以上の場合にtrue。
73
88
  */
74
89
  private isMultiDrag;
90
+ /**
91
+ * 選択中の全タスクが同じ行に属しているかを判定する。
92
+ * 同じ行なら縦方向(行間)の移動を許可する。
93
+ */
94
+ private isMultiDragSameRow;
75
95
  private handleTaskUpdate;
76
96
  private handleBarMouseEnter;
77
97
  private handleBarMouseLeave;
@@ -92,6 +112,15 @@ export declare class GanttChartElement extends LitElement {
92
112
  rowId: string;
93
113
  date: Date;
94
114
  } | null;
115
+ /**
116
+ * 各行のY座標(カレンダーヘッダーを含まない、行領域の上端からの相対位置)
117
+ * のレイアウト情報を取得します。
118
+ */
119
+ getRowPositions(): {
120
+ top: number;
121
+ height: number;
122
+ bottom: number;
123
+ }[];
95
124
  /**
96
125
  * html2canvas を使用してガントチャートを画像としてエクスポートする。
97
126
  * (Shadow DOMネイティブ対応版 html2canvas-pro を使用)
@@ -99,6 +128,23 @@ export declare class GanttChartElement extends LitElement {
99
128
  * @param options エクスポートオプション。
100
129
  */
101
130
  exportImage(format?: 'png' | 'pdf', options?: ExportImageOptions): Promise<string | Blob>;
131
+ /**
132
+ * Ctrl/Cmd + マウスホイールによるズーム処理
133
+ */
134
+ private handleWheel;
135
+ /**
136
+ * 指定した pxPerDay(または pxPerMonth)にズームを設定する。
137
+ * @param value ズーム先の pxPerDay(月単位モード時は pxPerMonth)
138
+ */
139
+ zoomTo(value: number): void;
140
+ /**
141
+ * 全タスクが表示領域に収まるようにズームレベルを自動調整する。
142
+ */
143
+ zoomToFit(): void;
144
+ /**
145
+ * ズームをリセットし、option で設定された元のスケールに戻す。
146
+ */
147
+ resetZoom(): void;
102
148
  private clearSelection;
103
149
  private handleKeyDown;
104
150
  /**
@@ -17,6 +17,8 @@ export declare class GanttRowElement extends LitElement {
17
17
  } | null;
18
18
  draggingTaskIds: string[];
19
19
  multiDragDx: number;
20
+ multiDragDy: number;
21
+ multiDragSameRow: boolean;
20
22
  externalDragTask: {
21
23
  task: GanttTask;
22
24
  currentStart: Date;
@@ -28,6 +30,7 @@ export declare class GanttRowElement extends LitElement {
28
30
  selectedTaskIds: string[];
29
31
  focusedTaskId: string | null;
30
32
  isExporting: boolean;
33
+ criticalPathTaskIds: string[];
31
34
  private _cachedMonthGridLines;
32
35
  private _cachedMonthGridStartTime;
33
36
  private _cachedMonthGridEndTime;
@@ -38,6 +41,18 @@ export declare class GanttRowElement extends LitElement {
38
41
  * マーカーのSVGパスを生成する
39
42
  */
40
43
  private getMarkerPath;
44
+ /**
45
+ * マーカーの表示幅を推定する(アイコン+ラベル)
46
+ */
47
+ private estimateMarkerWidth;
48
+ /**
49
+ * マーカーのX方向の占有範囲を計算する
50
+ */
51
+ private getMarkerXRange;
52
+ /**
53
+ * マーカー群のレーン(段)を計算して重なりを回避する
54
+ */
55
+ private calculateMarkerLanes;
41
56
  static styles: import("lit").CSSResult;
42
57
  private handleDragStart;
43
58
  private handleHeaderClick;
@@ -0,0 +1,18 @@
1
+ import type { GanttRow } from './types';
2
+ /**
3
+ * 依存関係グラフからクリティカルパス上のタスクIDの集合を計算する。
4
+ *
5
+ * 手動スケジュールのガントチャート向けに最適化:
6
+ * - 依存関係グラフの中で最長のチェーン(最終タスクの終了時刻が最も遅いパス)を検出する
7
+ * - 依存関係に参加していない独立タスクはクリティカルパス計算から除外する
8
+ *
9
+ * アルゴリズム:
10
+ * 1. 全タスクを走査し依存関係グラフを構築
11
+ * 2. 依存関係に参加しているタスクのみを抽出
12
+ * 3. トポロジカルソート順に前方パス(最早終了時刻 EF)を計算
13
+ * 4. 最終タスクから逆方向にバックトラックし、最長パスを構成するタスクを収集
14
+ *
15
+ * @param rows ガントチャートの全行データ
16
+ * @returns クリティカルパス上のタスクID集合
17
+ */
18
+ export declare function computeCriticalPath(rows: GanttRow[]): Set<string>;
@@ -316,6 +316,10 @@ export interface GanttChartOptionDependency {
316
316
  lineStyle?: DependencyLineStyle;
317
317
  /** orthogonalスタイル時の角丸半径 (px)。デフォルト: 8 */
318
318
  cornerRadius?: number;
319
+ /** 接続ポイント(丸印)を表示するかどうか (デフォルト: true) */
320
+ showConnectors?: boolean;
321
+ /** クリティカルパスを表示するかどうか (デフォルト: false) */
322
+ showCriticalPath?: boolean;
319
323
  }
320
324
  /**
321
325
  * ガントチャート全体のオプション設定
@@ -358,6 +362,17 @@ export interface GanttChartOption {
358
362
  /** Shift+矢印キーでのタスク移動量(分)。省略時は snapDuration を使用 */
359
363
  moveStep?: number;
360
364
  };
365
+ /** ズーム機能の設定 */
366
+ zoom?: {
367
+ /** ズーム機能を有効にするか (デフォルト: false) */
368
+ enabled?: boolean;
369
+ /** 最小 pxPerDay (デフォルト: 2)。pxPerMonth モードの場合は最小 pxPerMonth */
370
+ min?: number;
371
+ /** 最大 pxPerDay (デフォルト: 200)。pxPerMonth モードの場合は最大 pxPerMonth */
372
+ max?: number;
373
+ /** ホイール1回あたりのズーム倍率 (デフォルト: 1.2) */
374
+ step?: number;
375
+ };
361
376
  }
362
377
  /**
363
378
  * タスク更新イベントの詳細データ
@@ -561,6 +576,8 @@ export interface ThemeColorPalette {
561
576
  thursday?: string;
562
577
  /** 金曜日の背景色 (オプション) */
563
578
  friday?: string;
579
+ /** クリティカルパスの色 (オプション) */
580
+ criticalPath?: string;
564
581
  }
565
582
  /**
566
583
  * テーマセット (light/dark)
@@ -610,3 +627,12 @@ export interface TaskDeleteEventDetail {
610
627
  /** 元のキーボードイベント */
611
628
  event: KeyboardEvent;
612
629
  }
630
+ /**
631
+ * ズーム変更イベントの詳細データ
632
+ */
633
+ export interface ZoomChangeEventDetail {
634
+ /** ズーム後の pxPerDay */
635
+ pxPerDay: number;
636
+ /** ズーム後の pxPerMonth(月単位モード時のみ) */
637
+ pxPerMonth?: number;
638
+ }
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './components/gantt-row';
5
5
  export * from './core/types';
6
6
  export * from './core/patterns';
7
7
  export * from './core/i18n';
8
+ export { computeCriticalPath } from './core/critical-path';