@mogura/moguchart-core 0.6.0 → 0.8.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ヶ月あたりの幅)や表示期間の調整が可能
@@ -12,6 +12,7 @@ export declare class GanttBarElement extends LitElement {
12
12
  multiDragSameRow: boolean;
13
13
  connectorDropTarget: boolean;
14
14
  isExporting: boolean;
15
+ isCriticalPath: boolean;
15
16
  private _currentDragCursor;
16
17
  private _dragAnimationFrame;
17
18
  private _wasDragging;
@@ -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>;
@@ -38,6 +38,8 @@ export declare class GanttChartElement extends LitElement {
38
38
  private isExporting;
39
39
  private focusedTaskId;
40
40
  private focusedRowId;
41
+ private zoomPxPerDay;
42
+ private zoomPxPerMonth;
41
43
  private _layoutCache;
42
44
  private resizeObserver;
43
45
  private _cachedSelectedTaskIds;
@@ -45,7 +47,18 @@ export declare class GanttChartElement extends LitElement {
45
47
  private _cachedCurrentOption;
46
48
  private _lastOptionRef;
47
49
  private _lastLabelWidth;
50
+ private _lastZoomPxPerDay;
51
+ private _lastZoomPxPerMonth;
52
+ private _scrollContainer;
48
53
  private get displayRows();
54
+ /**
55
+ * 現在有効な pxPerDay(ズームオーバーライドがあればそちらを優先)
56
+ */
57
+ private get effectivePxPerDay();
58
+ /**
59
+ * 現在有効な pxPerMonth(ズームオーバーライドがあればそちらを優先)
60
+ */
61
+ private get effectivePxPerMonth();
49
62
  static styles: import("lit").CSSResult;
50
63
  protected firstUpdated(): void;
51
64
  connectedCallback(): void;
@@ -99,6 +112,15 @@ export declare class GanttChartElement extends LitElement {
99
112
  rowId: string;
100
113
  date: Date;
101
114
  } | null;
115
+ /**
116
+ * 各行のY座標(カレンダーヘッダーを含まない、行領域の上端からの相対位置)
117
+ * のレイアウト情報を取得します。
118
+ */
119
+ getRowPositions(): {
120
+ top: number;
121
+ height: number;
122
+ bottom: number;
123
+ }[];
102
124
  /**
103
125
  * html2canvas を使用してガントチャートを画像としてエクスポートする。
104
126
  * (Shadow DOMネイティブ対応版 html2canvas-pro を使用)
@@ -106,6 +128,23 @@ export declare class GanttChartElement extends LitElement {
106
128
  * @param options エクスポートオプション。
107
129
  */
108
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;
109
148
  private clearSelection;
110
149
  private handleKeyDown;
111
150
  /**
@@ -30,6 +30,7 @@ export declare class GanttRowElement extends LitElement {
30
30
  selectedTaskIds: string[];
31
31
  focusedTaskId: string | null;
32
32
  isExporting: boolean;
33
+ criticalPathTaskIds: string[];
33
34
  private _cachedMonthGridLines;
34
35
  private _cachedMonthGridStartTime;
35
36
  private _cachedMonthGridEndTime;
@@ -40,6 +41,10 @@ export declare class GanttRowElement extends LitElement {
40
41
  * マーカーのSVGパスを生成する
41
42
  */
42
43
  private getMarkerPath;
44
+ /**
45
+ * マーカーのフォントサイズ名をpx値に変換する
46
+ */
47
+ private resolveMarkerFontSize;
43
48
  /**
44
49
  * マーカーの表示幅を推定する(アイコン+ラベル)
45
50
  */
@@ -57,6 +62,10 @@ export declare class GanttRowElement extends LitElement {
57
62
  private handleHeaderClick;
58
63
  private handleHeaderContextMenu;
59
64
  private handleHeaderDblClick;
65
+ private _rowHeaderTooltipEl;
66
+ private _rowHeaderTooltipTimer;
67
+ private handleHeaderMouseEnter;
68
+ private handleHeaderMouseLeave;
60
69
  protected updated(changedProperties: PropertyValues): void;
61
70
  render(): import("lit").TemplateResult<1>;
62
71
  }
@@ -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>;
@@ -20,6 +20,10 @@ export type MarkerType = 'triangle-up' | 'triangle-down' | 'triangle-left' | 'tr
20
20
  * マーカーのアンカー位置
21
21
  */
22
22
  export type AnchorType = 'start' | 'end' | 'center';
23
+ /**
24
+ * マーカーのフォントサイズ
25
+ */
26
+ export type MarkerFontSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
23
27
  /**
24
28
  * マーカーの設定
25
29
  */
@@ -36,6 +40,8 @@ export interface GanttMarker {
36
40
  type: MarkerType;
37
41
  /** マーカーの色 (CSS color string) */
38
42
  color?: string;
43
+ /** マーカーのラベルのフォントサイズ ('xs'=極小, 'sm'=小, 'md'=中, 'lg'=大, 'xl'=特大) */
44
+ fontSize?: MarkerFontSize;
39
45
  /** マーカーのカスタムスタイル (CSS文字列) */
40
46
  style?: string;
41
47
  }
@@ -82,6 +88,8 @@ export interface GanttRow {
82
88
  tasks: GanttTask[];
83
89
  /** マーカーの配列 */
84
90
  markers?: GanttMarker[];
91
+ /** 現在選択中(編集中)のマーカーID */
92
+ selectedMarkerId?: string;
85
93
  /** 行を表示するかどうか (デフォルト: true) */
86
94
  visible?: boolean;
87
95
  }
@@ -285,6 +293,8 @@ export interface GanttChartOptionCustomRendering {
285
293
  calendarHourContent?: (context: CalendarHourCellContext) => string | unknown;
286
294
  /** ガントチャート部の背景セルをレンダリングする関数。各日のセルごとに呼ばれ、HTML文字列またはTemplateResultを返す */
287
295
  chartBackground?: (context: ChartBackgroundCellContext) => string | unknown;
296
+ /** 行ヘッダーのツールチップコンテンツをレンダリングする関数。マウスホバー時に呼ばれる */
297
+ rowHeaderTooltip?: (row: GanttRow) => string | HTMLElement | unknown;
288
298
  }
289
299
  /**
290
300
  * チャート背景右クリックイベントの詳細データ
@@ -316,6 +326,10 @@ export interface GanttChartOptionDependency {
316
326
  lineStyle?: DependencyLineStyle;
317
327
  /** orthogonalスタイル時の角丸半径 (px)。デフォルト: 8 */
318
328
  cornerRadius?: number;
329
+ /** 接続ポイント(丸印)を表示するかどうか (デフォルト: true) */
330
+ showConnectors?: boolean;
331
+ /** クリティカルパスを表示するかどうか (デフォルト: false) */
332
+ showCriticalPath?: boolean;
319
333
  }
320
334
  /**
321
335
  * ガントチャート全体のオプション設定
@@ -358,6 +372,17 @@ export interface GanttChartOption {
358
372
  /** Shift+矢印キーでのタスク移動量(分)。省略時は snapDuration を使用 */
359
373
  moveStep?: number;
360
374
  };
375
+ /** ズーム機能の設定 */
376
+ zoom?: {
377
+ /** ズーム機能を有効にするか (デフォルト: false) */
378
+ enabled?: boolean;
379
+ /** 最小 pxPerDay (デフォルト: 2)。pxPerMonth モードの場合は最小 pxPerMonth */
380
+ min?: number;
381
+ /** 最大 pxPerDay (デフォルト: 200)。pxPerMonth モードの場合は最大 pxPerMonth */
382
+ max?: number;
383
+ /** ホイール1回あたりのズーム倍率 (デフォルト: 1.2) */
384
+ step?: number;
385
+ };
361
386
  }
362
387
  /**
363
388
  * タスク更新イベントの詳細データ
@@ -561,6 +586,8 @@ export interface ThemeColorPalette {
561
586
  thursday?: string;
562
587
  /** 金曜日の背景色 (オプション) */
563
588
  friday?: string;
589
+ /** クリティカルパスの色 (オプション) */
590
+ criticalPath?: string;
564
591
  }
565
592
  /**
566
593
  * テーマセット (light/dark)
@@ -601,6 +628,28 @@ export interface DependencyClickEventDetail {
601
628
  /** 元のマウスイベント */
602
629
  event: MouseEvent;
603
630
  }
631
+ /**
632
+ * マーカーダブルクリックイベントの詳細データ
633
+ */
634
+ export interface MarkerDblClickEventDetail {
635
+ /** 対象のマーカー */
636
+ marker: GanttMarker;
637
+ /** マーカーが属する行ID */
638
+ rowId: string;
639
+ /** 元のマウスイベント */
640
+ event: MouseEvent;
641
+ }
642
+ /**
643
+ * マーカー右クリック(コンテキストメニュー)イベントの詳細データ
644
+ */
645
+ export interface MarkerContextMenuEventDetail {
646
+ /** 対象のマーカー */
647
+ marker: GanttMarker;
648
+ /** マーカーが属する行ID */
649
+ rowId: string;
650
+ /** 元のマウスイベント */
651
+ event: MouseEvent;
652
+ }
604
653
  /**
605
654
  * タスク削除イベントの詳細データ
606
655
  */
@@ -610,3 +659,12 @@ export interface TaskDeleteEventDetail {
610
659
  /** 元のキーボードイベント */
611
660
  event: KeyboardEvent;
612
661
  }
662
+ /**
663
+ * ズーム変更イベントの詳細データ
664
+ */
665
+ export interface ZoomChangeEventDetail {
666
+ /** ズーム後の pxPerDay */
667
+ pxPerDay: number;
668
+ /** ズーム後の pxPerMonth(月単位モード時のみ) */
669
+ pxPerMonth?: number;
670
+ }
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';