@operato/gantt 2.0.0-alpha.154

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.
Files changed (46) hide show
  1. package/.editorconfig +29 -0
  2. package/.storybook/main.js +3 -0
  3. package/.storybook/server.mjs +8 -0
  4. package/CHANGELOG.md +13 -0
  5. package/README.md +0 -0
  6. package/assets/images/icon-editor-gradient-direction.png +0 -0
  7. package/assets/images/icon-properties-label.png +0 -0
  8. package/assets/images/icon-properties-line-type.png +0 -0
  9. package/assets/images/icon-properties-table.png +0 -0
  10. package/assets/images/no-image.png +0 -0
  11. package/demo/index.html +22 -0
  12. package/dist/src/gantt.d.ts +28 -0
  13. package/dist/src/gantt.js +178 -0
  14. package/dist/src/gantt.js.map +1 -0
  15. package/dist/src/index.d.ts +0 -0
  16. package/dist/src/index.js +2 -0
  17. package/dist/src/index.js.map +1 -0
  18. package/dist/src/lite-gantt.d.ts +27 -0
  19. package/dist/src/lite-gantt.js +146 -0
  20. package/dist/src/lite-gantt.js.map +1 -0
  21. package/dist/src/types.d.ts +14 -0
  22. package/dist/src/types.js +2 -0
  23. package/dist/src/types.js.map +1 -0
  24. package/dist/stories/ox-gantt.stories.d.ts +22 -0
  25. package/dist/stories/ox-gantt.stories.js +74 -0
  26. package/dist/stories/ox-gantt.stories.js.map +1 -0
  27. package/dist/stories/ox-lite-gantt.stories.d.ts +22 -0
  28. package/dist/stories/ox-lite-gantt.stories.js +74 -0
  29. package/dist/stories/ox-lite-gantt.stories.js.map +1 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -0
  31. package/package.json +77 -0
  32. package/src/gantt.ts +191 -0
  33. package/src/index.ts +0 -0
  34. package/src/lite-gantt.ts +152 -0
  35. package/src/renderer.txt +775 -0
  36. package/src/types.ts +16 -0
  37. package/stories/ox-gantt.stories.ts +89 -0
  38. package/stories/ox-lite-gantt.stories.ts +89 -0
  39. package/translations/en.json +1 -0
  40. package/translations/ja.json +1 -0
  41. package/translations/ko.json +1 -0
  42. package/translations/ms.json +1 -0
  43. package/translations/zh.json +1 -0
  44. package/tsconfig.json +24 -0
  45. package/web-dev-server.config.mjs +27 -0
  46. package/web-test-runner.config.mjs +41 -0
package/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.json]
24
+ indent_size = 2
25
+
26
+ [*.{html,js,md}]
27
+ block_comment_start = /**
28
+ block_comment = *
29
+ block_comment_end = */
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ stories: ['../dist/stories/**/*.stories.{js,md,mdx}']
3
+ }
@@ -0,0 +1,8 @@
1
+ import { storybookPlugin } from '@web/dev-server-storybook'
2
+ import baseConfig from '../web-dev-server.config.mjs'
3
+
4
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
+ ...baseConfig,
6
+ open: '/',
7
+ plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins]
8
+ })
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [2.0.0-alpha.154](https://github.com/hatiolab/operato/compare/v2.0.0-alpha.153...v2.0.0-alpha.154) (2024-06-01)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * gantt-chart ([2ab8768](https://github.com/hatiolab/operato/commit/2ab87681074cc40857879b9380b3ede5594e5145))
12
+ * start gantt module ([efbdd30](https://github.com/hatiolab/operato/commit/efbdd30c33824d1a10f4d5c4fa5252a0a168e283))
13
+ * stories template for gantt ([4dfb297](https://github.com/hatiolab/operato/commit/4dfb2976e7dd9c9b440683b28a9269606f809528))
package/README.md ADDED
File without changes
Binary file
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1" />
6
+ <style>
7
+ body {
8
+ background: #fafafa;
9
+ }
10
+
11
+ a {
12
+ display: block;
13
+ }
14
+ </style>
15
+ <link href="/themes/app-theme.css" rel="stylesheet" />
16
+ <link href="/themes/input-theme.css" rel="stylesheet" />
17
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
18
+ </head>
19
+ <body>
20
+ <a href="./index-select.html">select</a>
21
+ </body>
22
+ </html>
@@ -0,0 +1,28 @@
1
+ import { LitElement } from 'lit';
2
+ import * as d3 from 'd3';
3
+ export declare class OxGanttChart extends LitElement {
4
+ width: number;
5
+ height: number;
6
+ plots: Array<any>;
7
+ precision?: number;
8
+ tooltip: HTMLDivElement;
9
+ chart: SVGSVGElement;
10
+ protected svg?: d3.Selection<SVGGElement, unknown, null, undefined>;
11
+ private resizeObserver?;
12
+ static styles: import("lit").CSSResult[];
13
+ render(): import("lit-html").TemplateResult<1>;
14
+ connectedCallback(): void;
15
+ disconnectedCallback(): void;
16
+ protected initializeResizeObserver(): void;
17
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
18
+ protected initializeChart(): void;
19
+ protected drawChart(): void;
20
+ private addMouseHandlers;
21
+ protected onMouseOver(event: MouseEvent): void;
22
+ protected onMouseMove(event: MouseEvent): void;
23
+ protected onMouseOut(event: MouseEvent): void;
24
+ protected tooltipContent(data: any): string;
25
+ protected showTooltip(content: string, x: number, y: number): void;
26
+ protected hideTooltip(): void;
27
+ protected plotData(): void;
28
+ }
@@ -0,0 +1,178 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, css, html } from 'lit';
3
+ import { customElement, property, query } from 'lit/decorators.js';
4
+ import * as d3 from 'd3';
5
+ let OxGanttChart = class OxGanttChart extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.width = 0;
9
+ this.height = 0;
10
+ this.plots = [];
11
+ this.precision = 2;
12
+ }
13
+ static { this.styles = [
14
+ css `
15
+ :host {
16
+ display: flex;
17
+ }
18
+
19
+ svg {
20
+ flex: 1;
21
+ margin: 0;
22
+ padding: 0;
23
+ }
24
+
25
+ #tooltip {
26
+ position: absolute;
27
+ opacity: 0;
28
+ background-color: var(--gantt-chart-tooltip-background-color, white);
29
+ padding: var(--gantt-chart-tooltip-padding, 5px);
30
+ border: var(--gantt-chart-tooltip-border, 1px solid black);
31
+ border-radius: var(--gantt-chart-tooltip-border-radius, 5px);
32
+ box-shadow: var(--gantt-chart-tooltip-box-shadow, 2px 2px 5px rgba(0, 0, 0, 0.3));
33
+ pointer-events: var(--gantt-chart-tooltip-pointer-events, none);
34
+ font-size: var(--gantt-chart-tooltip-font-size, 12px);
35
+ font-family: var(--gantt-chart-tooltip-font-family, Arial, sans-serif);
36
+ transition: opacity 0.3s ease-in-out;
37
+ }
38
+
39
+ .data-point {
40
+ stroke: var(--gantt-chart-plot-stroke, black);
41
+ stroke-width: var(--gantt-chart-plot-stroke-width, 1px);
42
+ r: var(--gantt-chart-plot-r, 4);
43
+ }
44
+ `
45
+ ]; }
46
+ render() {
47
+ return html `
48
+ <svg id="chart"></svg>
49
+ <div id="tooltip"></div>
50
+ `;
51
+ }
52
+ connectedCallback() {
53
+ super.connectedCallback();
54
+ this.initializeResizeObserver();
55
+ }
56
+ disconnectedCallback() {
57
+ if (this.resizeObserver) {
58
+ this.resizeObserver.disconnect();
59
+ }
60
+ super.disconnectedCallback();
61
+ }
62
+ initializeResizeObserver() {
63
+ this.resizeObserver = new ResizeObserver(entries => {
64
+ for (const entry of entries) {
65
+ this.initializeChart();
66
+ this.drawChart();
67
+ }
68
+ });
69
+ this.resizeObserver.observe(this);
70
+ }
71
+ updated(changedProperties) {
72
+ super.updated(changedProperties);
73
+ if (changedProperties.has('plots') && this.plots.length > 0) {
74
+ this.initializeChart();
75
+ this.drawChart();
76
+ }
77
+ }
78
+ initializeChart() {
79
+ const chart = this.chart;
80
+ d3.select(chart).selectAll('g').remove();
81
+ this.svg = d3.select(chart).append('g');
82
+ this.addMouseHandlers();
83
+ }
84
+ drawChart() {
85
+ const tasks = [
86
+ { task: 'Task 1', startDate: new Date('2024-02-01'), endDate: new Date('2024-02-07') },
87
+ { task: 'Task 2', startDate: new Date('2024-02-05'), endDate: new Date('2024-02-15') },
88
+ { task: 'Task 3', startDate: new Date('2024-02-10'), endDate: new Date('2024-02-20') }
89
+ ];
90
+ const g = this.svg;
91
+ const x = d3
92
+ .scaleTime()
93
+ .domain([d3.min(tasks, d => d.startDate), d3.max(tasks, d => d.endDate)])
94
+ .range([0, this.width]);
95
+ const y = d3
96
+ .scaleBand()
97
+ .domain(tasks.map(d => d.task))
98
+ .range([0, this.height])
99
+ .padding(0.1);
100
+ g.selectAll('.task')
101
+ .data(tasks)
102
+ .enter()
103
+ .append('rect')
104
+ .attr('class', 'task')
105
+ .attr('x', d => x(d.startDate))
106
+ .attr('y', d => y(d.task))
107
+ .attr('width', d => x(d.endDate) - x(d.startDate))
108
+ .attr('height', y.bandwidth());
109
+ g.append('g')
110
+ .attr('transform', 'translate(0,' + this.height + ')')
111
+ .call(d3.axisBottom(x));
112
+ g.append('g').call(d3.axisLeft(y));
113
+ }
114
+ addMouseHandlers() {
115
+ d3.select(this.chart)
116
+ .on('mouseover', this.onMouseOver.bind(this))
117
+ .on('mousemove', this.onMouseMove.bind(this))
118
+ .on('mouseout', this.onMouseOut.bind(this));
119
+ }
120
+ onMouseOver(event) {
121
+ const target = d3.select(event.target);
122
+ if (target.classed('tooltip')) {
123
+ const data = target.datum();
124
+ this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY);
125
+ }
126
+ }
127
+ onMouseMove(event) {
128
+ const target = d3.select(event.target);
129
+ if (target.classed('tooltip')) {
130
+ const data = target.datum();
131
+ this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY);
132
+ }
133
+ }
134
+ onMouseOut(event) {
135
+ const target = d3.select(event.target);
136
+ if (target.classed('tooltip')) {
137
+ this.hideTooltip();
138
+ }
139
+ }
140
+ tooltipContent(data) {
141
+ return `Data: ${data}`;
142
+ }
143
+ showTooltip(content, x, y) {
144
+ this.tooltip.style.opacity = '1';
145
+ this.tooltip.style.left = `${x}px`;
146
+ this.tooltip.style.top = `${y}px`;
147
+ this.tooltip.innerHTML = content;
148
+ }
149
+ hideTooltip() {
150
+ this.tooltip.style.opacity = '0';
151
+ }
152
+ plotData() {
153
+ this.svg.selectAll('.plot').data(this.plots).enter().append('circle').attr('class', 'plot tooltip');
154
+ }
155
+ };
156
+ __decorate([
157
+ property({ type: Number })
158
+ ], OxGanttChart.prototype, "width", void 0);
159
+ __decorate([
160
+ property({ type: Number })
161
+ ], OxGanttChart.prototype, "height", void 0);
162
+ __decorate([
163
+ property({ type: Array })
164
+ ], OxGanttChart.prototype, "plots", void 0);
165
+ __decorate([
166
+ property({ type: Number })
167
+ ], OxGanttChart.prototype, "precision", void 0);
168
+ __decorate([
169
+ query('#tooltip')
170
+ ], OxGanttChart.prototype, "tooltip", void 0);
171
+ __decorate([
172
+ query('#chart')
173
+ ], OxGanttChart.prototype, "chart", void 0);
174
+ OxGanttChart = __decorate([
175
+ customElement('ox-gantt-chart')
176
+ ], OxGanttChart);
177
+ export { OxGanttChart };
178
+ //# sourceMappingURL=gantt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gantt.js","sourceRoot":"","sources":["../../src/gantt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA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,CAAS;QACzD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAA;QAChC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;QAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAA;IAClC,CAAC;IAES,WAAW;QACnB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAA;IAClC,CAAC;IAES,QAAQ;QAChB,IAAI,CAAC,GAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IACtG,CAAC;;AAvL2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAmB;AACnB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAuB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAuB;AAE/B;IAAlB,KAAK,CAAC,UAAU,CAAC;6CAAyB;AAC1B;IAAhB,KAAK,CAAC,QAAQ,CAAC;2CAAsB;AAR3B,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAyLxB","sourcesContent":["import { LitElement, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport * as d3 from 'd3'\n\n@customElement('ox-gantt-chart')\nexport class OxGanttChart extends LitElement {\n @property({ type: Number }) width: number = 0\n @property({ type: Number }) height: number = 0\n @property({ type: Array }) plots: Array<any> = []\n\n @property({ type: Number }) precision?: number = 2\n\n @query('#tooltip') tooltip!: HTMLDivElement\n @query('#chart') chart!: SVGSVGElement\n\n protected svg?: d3.Selection<SVGGElement, unknown, null, undefined>\n\n private resizeObserver?: ResizeObserver\n\n static styles = [\n css`\n :host {\n display: flex;\n }\n\n svg {\n flex: 1;\n margin: 0;\n padding: 0;\n }\n\n #tooltip {\n position: absolute;\n opacity: 0;\n background-color: var(--gantt-chart-tooltip-background-color, white);\n padding: var(--gantt-chart-tooltip-padding, 5px);\n border: var(--gantt-chart-tooltip-border, 1px solid black);\n border-radius: var(--gantt-chart-tooltip-border-radius, 5px);\n box-shadow: var(--gantt-chart-tooltip-box-shadow, 2px 2px 5px rgba(0, 0, 0, 0.3));\n pointer-events: var(--gantt-chart-tooltip-pointer-events, none);\n font-size: var(--gantt-chart-tooltip-font-size, 12px);\n font-family: var(--gantt-chart-tooltip-font-family, Arial, sans-serif);\n transition: opacity 0.3s ease-in-out;\n }\n\n .data-point {\n stroke: var(--gantt-chart-plot-stroke, black);\n stroke-width: var(--gantt-chart-plot-stroke-width, 1px);\n r: var(--gantt-chart-plot-r, 4);\n }\n `\n ]\n\n render() {\n return html`\n <svg id=\"chart\"></svg>\n <div id=\"tooltip\"></div>\n `\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n this.initializeResizeObserver()\n }\n\n disconnectedCallback(): void {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect()\n }\n super.disconnectedCallback()\n }\n\n protected initializeResizeObserver(): void {\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n this.initializeChart()\n this.drawChart()\n }\n })\n\n this.resizeObserver.observe(this)\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated(changedProperties)\n\n if (changedProperties.has('plots') && this.plots.length > 0) {\n this.initializeChart()\n this.drawChart()\n }\n }\n\n protected initializeChart(): void {\n const chart = this.chart\n\n d3.select(chart).selectAll('g').remove()\n\n this.svg = d3.select(chart).append('g')\n\n this.addMouseHandlers()\n }\n\n protected drawChart(): void {\n const tasks = [\n { task: 'Task 1', startDate: new Date('2024-02-01'), endDate: new Date('2024-02-07') },\n { task: 'Task 2', startDate: new Date('2024-02-05'), endDate: new Date('2024-02-15') },\n { task: 'Task 3', startDate: new Date('2024-02-10'), endDate: new Date('2024-02-20') }\n ]\n\n const g = this.svg!\n\n const x = d3\n .scaleTime()\n .domain([d3.min(tasks, d => d.startDate)!, d3.max(tasks, d => d.endDate)!])\n .range([0, this.width])\n\n const y = d3\n .scaleBand()\n .domain(tasks.map(d => d.task))\n .range([0, this.height])\n .padding(0.1)\n\n g.selectAll('.task')\n .data(tasks)\n .enter()\n .append('rect')\n .attr('class', 'task')\n .attr('x', d => x(d.startDate))\n .attr('y', d => y(d.task)!)\n .attr('width', d => x(d.endDate) - x(d.startDate))\n .attr('height', y.bandwidth())\n\n g.append('g')\n .attr('transform', 'translate(0,' + this.height + ')')\n .call(d3.axisBottom(x))\n\n g.append('g').call(d3.axisLeft(y))\n }\n\n private addMouseHandlers(): void {\n d3.select(this.chart)\n .on('mouseover', this.onMouseOver.bind(this))\n .on('mousemove', this.onMouseMove.bind(this))\n .on('mouseout', this.onMouseOut.bind(this))\n }\n\n protected onMouseOver(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n const data = target.datum()\n this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY)\n }\n }\n\n protected onMouseMove(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n const data = target.datum()\n this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY)\n }\n }\n\n protected onMouseOut(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n this.hideTooltip()\n }\n }\n\n protected tooltipContent(data: any): string {\n return `Data: ${data}`\n }\n\n protected showTooltip(content: string, x: number, y: number): void {\n this.tooltip.style.opacity = '1'\n this.tooltip.style.left = `${x}px`\n this.tooltip.style.top = `${y}px`\n this.tooltip.innerHTML = content\n }\n\n protected hideTooltip(): void {\n this.tooltip.style.opacity = '0'\n }\n\n protected plotData(): void {\n this.svg!.selectAll('.plot').data(this.plots).enter().append('circle').attr('class', 'plot tooltip')\n }\n}\n"]}
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -0,0 +1,27 @@
1
+ import { LitElement } from 'lit';
2
+ import * as d3 from 'd3';
3
+ export declare class OxLiteGanttChart extends LitElement {
4
+ width: number;
5
+ height: number;
6
+ plots: Array<any>;
7
+ precision?: number;
8
+ tooltip: HTMLDivElement;
9
+ chart: SVGSVGElement;
10
+ protected svg?: d3.Selection<SVGGElement, unknown, null, undefined>;
11
+ private resizeObserver?;
12
+ static styles: import("lit").CSSResult[];
13
+ render(): import("lit-html").TemplateResult<1>;
14
+ connectedCallback(): void;
15
+ disconnectedCallback(): void;
16
+ protected initializeResizeObserver(): void;
17
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
18
+ protected initializeChart(): void;
19
+ protected drawChart(): void;
20
+ private addMouseHandlers;
21
+ protected onMouseOver(event: MouseEvent): void;
22
+ protected onMouseMove(event: MouseEvent): void;
23
+ protected onMouseOut(event: MouseEvent): void;
24
+ protected tooltipContent(data: any): string;
25
+ protected showTooltip(content: string, x: number, y: number): void;
26
+ protected hideTooltip(): void;
27
+ }
@@ -0,0 +1,146 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, css, html } from 'lit';
3
+ import { customElement, property, query } from 'lit/decorators.js';
4
+ import * as d3 from 'd3';
5
+ let OxLiteGanttChart = class OxLiteGanttChart extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.width = 0;
9
+ this.height = 0;
10
+ this.plots = [];
11
+ this.precision = 2;
12
+ }
13
+ static { this.styles = [
14
+ css `
15
+ :host {
16
+ display: flex;
17
+ }
18
+
19
+ svg {
20
+ flex: 1;
21
+ margin: 0;
22
+ padding: 0;
23
+ }
24
+
25
+ #tooltip {
26
+ position: absolute;
27
+ opacity: 0;
28
+ background-color: var(--gantt-chart-tooltip-background-color, white);
29
+ padding: var(--gantt-chart-tooltip-padding, 5px);
30
+ border: var(--gantt-chart-tooltip-border, 1px solid black);
31
+ border-radius: var(--gantt-chart-tooltip-border-radius, 5px);
32
+ box-shadow: var(--gantt-chart-tooltip-box-shadow, 2px 2px 5px rgba(0, 0, 0, 0.3));
33
+ pointer-events: var(--gantt-chart-tooltip-pointer-events, none);
34
+ font-size: var(--gantt-chart-tooltip-font-size, 12px);
35
+ font-family: var(--gantt-chart-tooltip-font-family, Arial, sans-serif);
36
+ transition: opacity 0.3s ease-in-out;
37
+ }
38
+
39
+ .data-point {
40
+ stroke: var(--gantt-chart-plot-stroke, black);
41
+ stroke-width: var(--gantt-chart-plot-stroke-width, 1px);
42
+ r: var(--gantt-chart-plot-r, 4);
43
+ }
44
+ `
45
+ ]; }
46
+ render() {
47
+ return html `
48
+ <svg id="chart"></svg>
49
+ <div id="tooltip"></div>
50
+ `;
51
+ }
52
+ connectedCallback() {
53
+ super.connectedCallback();
54
+ this.initializeResizeObserver();
55
+ }
56
+ disconnectedCallback() {
57
+ if (this.resizeObserver) {
58
+ this.resizeObserver.disconnect();
59
+ }
60
+ super.disconnectedCallback();
61
+ }
62
+ initializeResizeObserver() {
63
+ this.resizeObserver = new ResizeObserver(entries => {
64
+ for (const entry of entries) {
65
+ this.initializeChart();
66
+ this.drawChart();
67
+ }
68
+ });
69
+ this.resizeObserver.observe(this);
70
+ }
71
+ updated(changedProperties) {
72
+ super.updated(changedProperties);
73
+ if (changedProperties.has('plots') && this.plots.length > 0) {
74
+ this.initializeChart();
75
+ this.drawChart();
76
+ }
77
+ }
78
+ initializeChart() {
79
+ const chart = this.chart;
80
+ d3.select(chart).selectAll('g').remove();
81
+ this.svg = d3.select(chart).append('g');
82
+ this.addMouseHandlers();
83
+ }
84
+ drawChart() { }
85
+ addMouseHandlers() {
86
+ d3.select(this.chart)
87
+ .on('mouseover', this.onMouseOver.bind(this))
88
+ .on('mousemove', this.onMouseMove.bind(this))
89
+ .on('mouseout', this.onMouseOut.bind(this));
90
+ }
91
+ onMouseOver(event) {
92
+ const target = d3.select(event.target);
93
+ if (target.classed('tooltip')) {
94
+ const data = target.datum();
95
+ this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY);
96
+ }
97
+ }
98
+ onMouseMove(event) {
99
+ const target = d3.select(event.target);
100
+ if (target.classed('tooltip')) {
101
+ const data = target.datum();
102
+ this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY);
103
+ }
104
+ }
105
+ onMouseOut(event) {
106
+ const target = d3.select(event.target);
107
+ if (target.classed('tooltip')) {
108
+ this.hideTooltip();
109
+ }
110
+ }
111
+ tooltipContent(data) {
112
+ return `Data: ${data}`;
113
+ }
114
+ showTooltip(content, x, y) {
115
+ this.tooltip.style.opacity = '1';
116
+ this.tooltip.style.left = `${x}px`;
117
+ this.tooltip.style.top = `${y}px`;
118
+ this.tooltip.innerHTML = content;
119
+ }
120
+ hideTooltip() {
121
+ this.tooltip.style.opacity = '0';
122
+ }
123
+ };
124
+ __decorate([
125
+ property({ type: Number })
126
+ ], OxLiteGanttChart.prototype, "width", void 0);
127
+ __decorate([
128
+ property({ type: Number })
129
+ ], OxLiteGanttChart.prototype, "height", void 0);
130
+ __decorate([
131
+ property({ type: Array })
132
+ ], OxLiteGanttChart.prototype, "plots", void 0);
133
+ __decorate([
134
+ property({ type: Number })
135
+ ], OxLiteGanttChart.prototype, "precision", void 0);
136
+ __decorate([
137
+ query('#tooltip')
138
+ ], OxLiteGanttChart.prototype, "tooltip", void 0);
139
+ __decorate([
140
+ query('#chart')
141
+ ], OxLiteGanttChart.prototype, "chart", void 0);
142
+ OxLiteGanttChart = __decorate([
143
+ customElement('ox-lite-gantt-chart')
144
+ ], OxLiteGanttChart);
145
+ export { OxLiteGanttChart };
146
+ //# sourceMappingURL=lite-gantt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lite-gantt.js","sourceRoot":"","sources":["../../src/lite-gantt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAGjB,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QACuB,UAAK,GAAW,CAAC,CAAA;QACjB,WAAM,GAAW,CAAC,CAAA;QACnB,UAAK,GAAe,EAAE,CAAA;QAErB,cAAS,GAAY,CAAC,CAAA;IA6IpD,CAAC;aApIQ,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BF;KACF,AAhCY,CAgCZ;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;KAGV,CAAA;IACH,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACjC,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAA;QAClC,CAAC;QACD,KAAK,CAAC,oBAAoB,EAAE,CAAA;IAC9B,CAAC;IAES,wBAAwB;QAChC,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;YACjD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,eAAe,EAAE,CAAA;gBACtB,IAAI,CAAC,SAAS,EAAE,CAAA;YAClB,CAAC;QACH,CAAC,CAAC,C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AAO,GAAG,GAAG,CAAA;IAClC,CAAC;;AAhJ2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAmB;AACnB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;+CAAuB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAuB;AAE/B;IAAlB,KAAK,CAAC,UAAU,CAAC;iDAAyB;AAC1B;IAAhB,KAAK,CAAC,QAAQ,CAAC;+CAAsB;AAR3B,gBAAgB;IAD5B,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAkJ5B","sourcesContent":["import { LitElement, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport * as d3 from 'd3'\n\n@customElement('ox-lite-gantt-chart')\nexport class OxLiteGanttChart extends LitElement {\n @property({ type: Number }) width: number = 0\n @property({ type: Number }) height: number = 0\n @property({ type: Array }) plots: Array<any> = []\n\n @property({ type: Number }) precision?: number = 2\n\n @query('#tooltip') tooltip!: HTMLDivElement\n @query('#chart') chart!: SVGSVGElement\n\n protected svg?: d3.Selection<SVGGElement, unknown, null, undefined>\n\n private resizeObserver?: ResizeObserver\n\n static styles = [\n css`\n :host {\n display: flex;\n }\n\n svg {\n flex: 1;\n margin: 0;\n padding: 0;\n }\n\n #tooltip {\n position: absolute;\n opacity: 0;\n background-color: var(--gantt-chart-tooltip-background-color, white);\n padding: var(--gantt-chart-tooltip-padding, 5px);\n border: var(--gantt-chart-tooltip-border, 1px solid black);\n border-radius: var(--gantt-chart-tooltip-border-radius, 5px);\n box-shadow: var(--gantt-chart-tooltip-box-shadow, 2px 2px 5px rgba(0, 0, 0, 0.3));\n pointer-events: var(--gantt-chart-tooltip-pointer-events, none);\n font-size: var(--gantt-chart-tooltip-font-size, 12px);\n font-family: var(--gantt-chart-tooltip-font-family, Arial, sans-serif);\n transition: opacity 0.3s ease-in-out;\n }\n\n .data-point {\n stroke: var(--gantt-chart-plot-stroke, black);\n stroke-width: var(--gantt-chart-plot-stroke-width, 1px);\n r: var(--gantt-chart-plot-r, 4);\n }\n `\n ]\n\n render() {\n return html`\n <svg id=\"chart\"></svg>\n <div id=\"tooltip\"></div>\n `\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n this.initializeResizeObserver()\n }\n\n disconnectedCallback(): void {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect()\n }\n super.disconnectedCallback()\n }\n\n protected initializeResizeObserver(): void {\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n this.initializeChart()\n this.drawChart()\n }\n })\n\n this.resizeObserver.observe(this)\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated(changedProperties)\n\n if (changedProperties.has('plots') && this.plots.length > 0) {\n this.initializeChart()\n this.drawChart()\n }\n }\n\n protected initializeChart(): void {\n const chart = this.chart\n\n d3.select(chart).selectAll('g').remove()\n\n this.svg = d3.select(chart).append('g')\n\n this.addMouseHandlers()\n }\n\n protected drawChart(): void {}\n\n private addMouseHandlers(): void {\n d3.select(this.chart)\n .on('mouseover', this.onMouseOver.bind(this))\n .on('mousemove', this.onMouseMove.bind(this))\n .on('mouseout', this.onMouseOut.bind(this))\n }\n\n protected onMouseOver(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n const data = target.datum()\n this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY)\n }\n }\n\n protected onMouseMove(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n const data = target.datum()\n this.showTooltip(this.tooltipContent(data), event.clientX, event.clientY)\n }\n }\n\n protected onMouseOut(event: MouseEvent): void {\n const target = d3.select(event.target as HTMLElement)\n\n if (target.classed('tooltip')) {\n this.hideTooltip()\n }\n }\n\n protected tooltipContent(data: any): string {\n return `Data: ${data}`\n }\n\n protected showTooltip(content: string, x: number, y: number): void {\n this.tooltip.style.opacity = '1'\n this.tooltip.style.left = `${x}px`\n this.tooltip.style.top = `${y}px`\n this.tooltip.innerHTML = content\n }\n\n protected hideTooltip(): void {\n this.tooltip.style.opacity = '0'\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ export type TaskTag = 'done' | 'active' | 'crit' | 'milestone';
2
+ export interface Task {
3
+ id: string;
4
+ type: string;
5
+ section: any;
6
+ startTime: Date;
7
+ endTime: Date;
8
+ after: string;
9
+ length: string;
10
+ tags: TaskTag[];
11
+ }
12
+ export interface Section {
13
+ name: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type TaskTag = 'done' | 'active' | 'crit' | 'milestone'\n\nexport interface Task {\n id: string\n type: string\n section: any\n startTime: Date\n endTime: Date\n after: string\n length: string\n tags: TaskTag[]\n}\n\nexport interface Section {\n name: string\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import '../src/gantt.js';
2
+ import { TemplateResult } from 'lit';
3
+ declare const _default: {
4
+ title: string;
5
+ component: string;
6
+ argTypes: {
7
+ theme: {
8
+ control: string;
9
+ options: string[];
10
+ };
11
+ };
12
+ };
13
+ export default _default;
14
+ interface Story<T> {
15
+ (args: T): TemplateResult;
16
+ args?: Partial<T>;
17
+ argTypes?: Record<string, unknown>;
18
+ }
19
+ interface ArgTypes {
20
+ theme: 'light' | 'dark';
21
+ }
22
+ export declare const Regular: Story<ArgTypes>;
@@ -0,0 +1,74 @@
1
+ import { CommonHeaderStyles } from '@operato/styles';
2
+ import '../src/gantt.js';
3
+ import { html } from 'lit';
4
+ import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles';
5
+ export default {
6
+ title: 'ox-gantt',
7
+ component: 'ox-gantt',
8
+ argTypes: {
9
+ theme: { control: 'select', options: ['light', 'dark'] }
10
+ }
11
+ };
12
+ const Template = ({ theme = 'light' }) => html `
13
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
14
+
15
+ <link href="/themes/light.css" rel="stylesheet" />
16
+ <link href="/themes/dark.css" rel="stylesheet" />
17
+ <link href="/themes/spacing.css" rel="stylesheet" />
18
+
19
+ <link
20
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
21
+ rel="stylesheet"
22
+ />
23
+ <link
24
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
25
+ rel="stylesheet"
26
+ />
27
+ <link
28
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
29
+ rel="stylesheet"
30
+ />
31
+
32
+ <style>
33
+ ${MDTypeScaleStyles.cssText}
34
+ </style>
35
+
36
+ <style>
37
+ ${CommonHeaderStyles.cssText}
38
+ </style>
39
+
40
+ <style>
41
+ body {
42
+ width: 100%;
43
+ height: 500px;
44
+ text-align: center;
45
+
46
+ background-color: var(--md-sys-color-background);
47
+ color: var(--md-sys-color-on-background);
48
+ }
49
+
50
+ .header {
51
+ padding: var(--spacing-medium);
52
+ background-color: var(--md-sys-color-primary-container);
53
+ color: var(--md-sys-color-on-primary-container);
54
+ }
55
+ </style>
56
+
57
+ <script>
58
+ document.body.classList.add('${theme}')
59
+ </script>
60
+
61
+ <div class="header">
62
+ <div class="filters">
63
+ <ox-gantt
64
+ @change=${(e) => {
65
+ console.log('search form changed', e.detail);
66
+ }}
67
+ >
68
+ </ox-gantt>
69
+ </div>
70
+ </div>
71
+ `;
72
+ export const Regular = Template.bind({});
73
+ Regular.args = {};
74
+ //# sourceMappingURL=ox-gantt.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-gantt.stories.js","sourceRoot":"","sources":["../../stories/ox-gantt.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,iBAAiB,CAAA;AAExB,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AAI1F,eAAe;IACb,KAAK,EAAE,UAAU;IACjB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;KACzD;CACF,CAAA;AAYD,MAAM,QAAQ,GAAoB,CAAC,EAAE,KAAK,GAAG,OAAO,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;MAqBnE,iBAAiB,CAAC,OAAO;;;;MAIzB,kBAAkB,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;mCAqBG,KAAK;;;;;;kBAMtB,CAAC,CAAc,EAAE,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC;;;;;CAKR,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA","sourcesContent":["import { CommonHeaderStyles } from '@operato/styles'\nimport '../src/gantt.js'\n\nimport { html, TemplateResult } from 'lit'\nimport { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'\n\nimport { Task, Section } from '../src/types.js'\n\nexport default {\n title: 'ox-gantt',\n component: 'ox-gantt',\n argTypes: {\n theme: { control: 'select', options: ['light', 'dark'] }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n theme: 'light' | 'dark'\n}\n\nconst Template: Story<ArgTypes> = ({ theme = 'light' }: ArgTypes) => html`\n <link href=\"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap\" rel=\"stylesheet\" />\n\n <link href=\"/themes/light.css\" rel=\"stylesheet\" />\n <link href=\"/themes/dark.css\" rel=\"stylesheet\" />\n <link href=\"/themes/spacing.css\" rel=\"stylesheet\" />\n\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n\n <style>\n ${MDTypeScaleStyles.cssText}\n </style>\n\n <style>\n ${CommonHeaderStyles.cssText}\n </style>\n\n <style>\n body {\n width: 100%;\n height: 500px;\n text-align: center;\n\n background-color: var(--md-sys-color-background);\n color: var(--md-sys-color-on-background);\n }\n\n .header {\n padding: var(--spacing-medium);\n background-color: var(--md-sys-color-primary-container);\n color: var(--md-sys-color-on-primary-container);\n }\n </style>\n\n <script>\n document.body.classList.add('${theme}')\n </script>\n\n <div class=\"header\">\n <div class=\"filters\">\n <ox-gantt\n @change=${(e: CustomEvent) => {\n console.log('search form changed', e.detail)\n }}\n >\n </ox-gantt>\n </div>\n </div>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {}\n"]}