@dssp/dkpi 1.0.0-alpha.7 → 1.0.0-alpha.70
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/KPI-STATISTICS-SERVICE.md +233 -0
- package/_index.html +0 -5
- package/assets/favicon.ico +0 -0
- package/assets/images/project-image.png +0 -0
- package/assets/manifest/apple-1024.png +0 -0
- package/assets/manifest/apple-120.png +0 -0
- package/assets/manifest/apple-152.png +0 -0
- package/assets/manifest/apple-167.png +0 -0
- package/assets/manifest/apple-180.png +0 -0
- package/assets/manifest/apple-touch-icon.png +0 -0
- package/assets/manifest/badge-128x128.png +0 -0
- package/assets/manifest/chrome-splashscreen-icon-384x384.png +0 -0
- package/assets/manifest/chrome-touch-icon-192x192.png +0 -0
- package/assets/manifest/icon-128x128.png +0 -0
- package/assets/manifest/icon-192x192.png +0 -0
- package/assets/manifest/icon-512x512.png +0 -0
- package/assets/manifest/icon-72x72.png +0 -0
- package/assets/manifest/icon-96x96.png +0 -0
- package/assets/manifest/image-metaog.png +0 -0
- package/assets/manifest/maskable_icon.png +0 -0
- package/assets/manifest/ms-icon-144x144.png +0 -0
- package/assets/manifest/ms-touch-icon-144x144-precomposed.png +0 -0
- package/assets/videos/intro.mp4 +0 -0
- package/dist-client/bootstrap.js +64 -4
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/components/kpi-2d-lookup-chart.d.ts +43 -0
- package/dist-client/components/kpi-2d-lookup-chart.js +253 -0
- package/dist-client/components/kpi-2d-lookup-chart.js.map +1 -0
- package/dist-client/components/kpi-boxplot-chart.d.ts +24 -0
- package/dist-client/components/kpi-boxplot-chart.js +291 -0
- package/dist-client/components/kpi-boxplot-chart.js.map +1 -0
- package/dist-client/components/kpi-lookup-chart.d.ts +53 -0
- package/dist-client/components/kpi-lookup-chart.js +430 -0
- package/dist-client/components/kpi-lookup-chart.js.map +1 -0
- package/dist-client/components/kpi-mini-trend-chart.d.ts +14 -0
- package/dist-client/components/kpi-mini-trend-chart.js +148 -0
- package/dist-client/components/kpi-mini-trend-chart.js.map +1 -0
- package/dist-client/components/kpi-radar-chart.d.ts +17 -0
- package/dist-client/components/kpi-radar-chart.js +259 -0
- package/dist-client/components/kpi-radar-chart.js.map +1 -0
- package/dist-client/components/kpi-single-boxplot-chart.d.ts +24 -0
- package/dist-client/components/kpi-single-boxplot-chart.js +391 -0
- package/dist-client/components/kpi-single-boxplot-chart.js.map +1 -0
- package/dist-client/components/kpi-trend-chart.d.ts +25 -0
- package/dist-client/components/kpi-trend-chart.js +220 -0
- package/dist-client/components/kpi-trend-chart.js.map +1 -0
- package/dist-client/components/sv-pagenation-control.d.ts +18 -0
- package/dist-client/components/sv-pagenation-control.js +142 -0
- package/dist-client/components/sv-pagenation-control.js.map +1 -0
- package/dist-client/google-map/common-google-map.d.ts +35 -0
- package/dist-client/google-map/common-google-map.js +345 -0
- package/dist-client/google-map/common-google-map.js.map +1 -0
- package/dist-client/google-map/google-map-loader.d.ts +6 -0
- package/dist-client/google-map/google-map-loader.js +23 -0
- package/dist-client/google-map/google-map-loader.js.map +1 -0
- package/dist-client/icons/menu-icons.d.ts +6 -0
- package/dist-client/icons/menu-icons.js +42 -0
- package/dist-client/icons/menu-icons.js.map +1 -1
- package/dist-client/pages/kpi-admin/dssp-kpi-list-page.d.ts +22 -0
- package/dist-client/pages/kpi-admin/dssp-kpi-list-page.js +57 -0
- package/dist-client/pages/kpi-admin/dssp-kpi-list-page.js.map +1 -0
- package/dist-client/pages/kpi-admin/dssp-kpi-overview.d.ts +46 -0
- package/dist-client/pages/kpi-admin/dssp-kpi-overview.js +378 -0
- package/dist-client/pages/kpi-admin/dssp-kpi-overview.js.map +1 -0
- package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.d.ts +20 -0
- package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.js +445 -0
- package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.js.map +1 -0
- package/dist-client/pages/kpi-admin/kpi-system-guide.d.ts +18 -0
- package/dist-client/pages/kpi-admin/kpi-system-guide.js +535 -0
- package/dist-client/pages/kpi-admin/kpi-system-guide.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.d.ts +18 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +259 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.d.ts +22 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +346 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.d.ts +26 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +433 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.d.ts +8 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js +78 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +38 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +851 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +42 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +316 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.d.ts +28 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +497 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.d.ts +18 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js +131 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.d.ts +52 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +798 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.d.ts +63 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +1089 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.d.ts +12 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js +82 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.d.ts +11 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js +65 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.d.ts +13 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js +115 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.d.ts +15 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js +147 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.d.ts +7 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js +86 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +57 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +719 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.d.ts +23 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +76 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +68 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +380 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts +12 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +174 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.d.ts +40 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js +190 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.d.ts +23 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.js +93 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +71 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.js +464 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -0
- package/dist-client/pages/project-complete-tabs/pc-tab1-plan.d.ts +14 -0
- package/dist-client/pages/project-complete-tabs/pc-tab1-plan.js +339 -0
- package/dist-client/pages/project-complete-tabs/pc-tab1-plan.js.map +1 -0
- package/dist-client/pages/project-complete-tabs/pc-tab2-rating.d.ts +14 -0
- package/dist-client/pages/project-complete-tabs/pc-tab2-rating.js +276 -0
- package/dist-client/pages/project-complete-tabs/pc-tab2-rating.js.map +1 -0
- package/dist-client/pages/project-complete-tabs/pc-tab3-upload.d.ts +18 -0
- package/dist-client/pages/project-complete-tabs/pc-tab3-upload.js +307 -0
- package/dist-client/pages/project-complete-tabs/pc-tab3-upload.js.map +1 -0
- package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.d.ts +18 -0
- package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.js +433 -0
- package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.js.map +1 -0
- package/dist-client/pages/sv-project-complete.d.ts +21 -0
- package/dist-client/pages/sv-project-complete.js +213 -0
- package/dist-client/pages/sv-project-complete.js.map +1 -0
- package/dist-client/pages/sv-project-completed-list.d.ts +27 -0
- package/dist-client/pages/sv-project-completed-list.js +416 -0
- package/dist-client/pages/sv-project-completed-list.js.map +1 -0
- package/dist-client/pages/sv-project-detail.d.ts +46 -0
- package/dist-client/pages/sv-project-detail.js +1236 -0
- package/dist-client/pages/sv-project-detail.js.map +1 -0
- package/dist-client/pages/sv-project-list.d.ts +165 -0
- package/dist-client/pages/sv-project-list.js +488 -0
- package/dist-client/pages/sv-project-list.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +35 -1
- package/dist-client/route.js.map +1 -1
- package/dist-client/shared/complete-api.d.ts +8 -0
- package/dist-client/shared/complete-api.js +177 -0
- package/dist-client/shared/complete-api.js.map +1 -0
- package/dist-client/shared/func.d.ts +2 -0
- package/dist-client/shared/func.js +22 -0
- package/dist-client/shared/func.js.map +1 -0
- package/dist-client/themes/dark.css +24 -24
- package/dist-client/themes/light.css +23 -23
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/menu-tools.d.ts +40 -5
- package/dist-client/viewparts/menu-tools.js +289 -34
- package/dist-client/viewparts/menu-tools.js.map +1 -1
- package/dist-server/index.d.ts +2 -0
- package/dist-server/index.js +5 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/scripts/calculate-kpi-scores.d.ts +10 -0
- package/dist-server/scripts/calculate-kpi-scores.js +333 -0
- package/dist-server/scripts/calculate-kpi-scores.js.map +1 -0
- package/dist-server/scripts/load-grade-data-migration.d.ts +14 -0
- package/dist-server/scripts/load-grade-data-migration.js +279 -0
- package/dist-server/scripts/load-grade-data-migration.js.map +1 -0
- package/dist-server/scripts/propagate-parent-kpi-values.d.ts +14 -0
- package/dist-server/scripts/propagate-parent-kpi-values.js +786 -0
- package/dist-server/scripts/propagate-parent-kpi-values.js.map +1 -0
- package/dist-server/scripts/recalculate-by-project-name.d.ts +2 -0
- package/dist-server/scripts/recalculate-by-project-name.js +72 -0
- package/dist-server/scripts/recalculate-by-project-name.js.map +1 -0
- package/dist-server/service/index.d.ts +4 -0
- package/dist-server/service/index.js +20 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/kpi-metric-value/index.d.ts +4 -0
- package/dist-server/service/kpi-metric-value/index.js +8 -0
- package/dist-server/service/kpi-metric-value/index.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +74 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +687 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.d.ts +7 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js +52 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js.map +1 -0
- package/dist-server/service/kpi-stat/index.d.ts +4 -0
- package/dist-server/service/kpi-stat/index.js +8 -0
- package/dist-server/service/kpi-stat/index.js.map +1 -0
- package/dist-server/service/kpi-stat/kpi-stat-query.d.ts +12 -0
- package/dist-server/service/kpi-stat/kpi-stat-query.js +662 -0
- package/dist-server/service/kpi-stat/kpi-stat-query.js.map +1 -0
- package/dist-server/service/kpi-stat/kpi-stat-types.d.ts +32 -0
- package/dist-server/service/kpi-stat/kpi-stat-types.js +180 -0
- package/dist-server/service/kpi-stat/kpi-stat-types.js.map +1 -0
- package/dist-server/service/kpi-value/index.d.ts +3 -0
- package/dist-server/service/kpi-value/index.js +7 -0
- package/dist-server/service/kpi-value/index.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value-query.d.ts +8 -0
- package/dist-server/service/kpi-value/kpi-value-query.js +69 -0
- package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/kpi-module-service-tests.md +1286 -0
- package/kpi-module-test-report.md +676 -0
- package/kpi-module-unit-test-detailed-report.md +925 -0
- package/kpi-module-unit-tests-detailed.md +1452 -0
- package/package.json +65 -55
- package/recalculate-batch.sh +64 -0
- package/recalculate-projects-range.sh +98 -0
- package/schema.graphql +2514 -455
- package/things-factory.config.js +11 -1
- package/views/auth-page.html +0 -1
- package/views/public/home.html +0 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
const SCORE_COLORS = {
|
|
6
|
+
5: '#1565c0',
|
|
7
|
+
4: '#4caf50',
|
|
8
|
+
3: '#ffc107',
|
|
9
|
+
2: '#ff9800',
|
|
10
|
+
1: '#e53935'
|
|
11
|
+
};
|
|
12
|
+
const SCORE_LABELS = {
|
|
13
|
+
5: '5점 (우수)',
|
|
14
|
+
4: '4점 (양호)',
|
|
15
|
+
3: '3점 (보통)',
|
|
16
|
+
2: '2점 (미흡)',
|
|
17
|
+
1: '1점 (매우 미흡)'
|
|
18
|
+
};
|
|
19
|
+
let Kpi2dLookupChart = class Kpi2dLookupChart extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.grades = null;
|
|
23
|
+
this.value = null;
|
|
24
|
+
this.progressRate = 50;
|
|
25
|
+
this.unit = '%';
|
|
26
|
+
this.kpiName = '';
|
|
27
|
+
this.chartWidth = 0;
|
|
28
|
+
this.chartHeight = 0;
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
return html `
|
|
32
|
+
<svg
|
|
33
|
+
id="lookup-2d-chart"
|
|
34
|
+
width=${this.chartWidth}
|
|
35
|
+
height=${this.chartHeight}
|
|
36
|
+
viewBox="0 0 ${this.chartWidth} ${this.chartHeight}"
|
|
37
|
+
preserveAspectRatio="xMidYMid meet"
|
|
38
|
+
></svg>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
const rect = entry.contentRect;
|
|
46
|
+
this.chartWidth = rect.width;
|
|
47
|
+
this.chartHeight = rect.height;
|
|
48
|
+
this.requestUpdate();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this.resizeObserver.observe(this);
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
56
|
+
super.disconnectedCallback();
|
|
57
|
+
}
|
|
58
|
+
updated() {
|
|
59
|
+
this.renderChart();
|
|
60
|
+
}
|
|
61
|
+
getScore(row, deviation) {
|
|
62
|
+
if (deviation < row.boundary5to4)
|
|
63
|
+
return 5;
|
|
64
|
+
if (deviation < row.boundary4to3)
|
|
65
|
+
return 4;
|
|
66
|
+
if (deviation < row.boundary3to2)
|
|
67
|
+
return 3;
|
|
68
|
+
if (deviation < row.boundary2to1)
|
|
69
|
+
return 2;
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
getCurrentScore() {
|
|
73
|
+
var _a;
|
|
74
|
+
if (this.value === null || !((_a = this.grades) === null || _a === void 0 ? void 0 : _a.rows))
|
|
75
|
+
return null;
|
|
76
|
+
const idx = Math.min(99, Math.max(0, Math.floor(this.progressRate)));
|
|
77
|
+
const row = this.grades.rows.find(r => r.progressRate === idx);
|
|
78
|
+
return row ? this.getScore(row, this.value) : null;
|
|
79
|
+
}
|
|
80
|
+
renderChart() {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
const svg = d3.select(this.renderRoot.querySelector('#lookup-2d-chart'));
|
|
83
|
+
svg.selectAll('*').remove();
|
|
84
|
+
if (!((_b = (_a = this.grades) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
85
|
+
svg.append('text')
|
|
86
|
+
.attr('x', this.chartWidth / 2).attr('y', this.chartHeight / 2)
|
|
87
|
+
.attr('text-anchor', 'middle').attr('fill', '#999').attr('font-size', '14px')
|
|
88
|
+
.text('No 2D grade data available');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const w = this.chartWidth || 400;
|
|
92
|
+
const h = this.chartHeight || 250;
|
|
93
|
+
const margin = { top: 20, right: 80, bottom: 50, left: 60 };
|
|
94
|
+
const plotW = w - margin.left - margin.right;
|
|
95
|
+
const plotH = h - margin.top - margin.bottom;
|
|
96
|
+
if (plotW <= 0 || plotH <= 0)
|
|
97
|
+
return;
|
|
98
|
+
const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`);
|
|
99
|
+
const rows = this.grades.rows;
|
|
100
|
+
// Y축 범위 (편차율)
|
|
101
|
+
const allBoundaries = rows.flatMap(r => [r.boundary5to4, r.boundary4to3, r.boundary3to2, r.boundary2to1]);
|
|
102
|
+
let yMin = Math.min(...allBoundaries);
|
|
103
|
+
let yMax = Math.max(...allBoundaries);
|
|
104
|
+
if (this.value !== null) {
|
|
105
|
+
yMin = Math.min(yMin, this.value);
|
|
106
|
+
yMax = Math.max(yMax, this.value);
|
|
107
|
+
}
|
|
108
|
+
const yPad = (yMax - yMin) * 0.1 || 0.01;
|
|
109
|
+
yMin -= yPad;
|
|
110
|
+
yMax += yPad;
|
|
111
|
+
// X축: 공정률 0~100
|
|
112
|
+
const xScale = d3.scaleLinear().domain([0, 100]).range([0, plotW]);
|
|
113
|
+
const yScale = d3.scaleLinear().domain([yMin, yMax]).range([plotH, 0]);
|
|
114
|
+
// 히트맵: 각 공정률(x) × 편차율(y) 셀의 점수를 색상으로
|
|
115
|
+
const xSteps = rows.map(r => r.progressRate).sort((a, b) => a - b);
|
|
116
|
+
const yStepCount = 50; // Y축 해상도
|
|
117
|
+
const yStep = (yMax - yMin) / yStepCount;
|
|
118
|
+
const xCellW = plotW / Math.max(xSteps.length, 1);
|
|
119
|
+
for (const row of rows) {
|
|
120
|
+
const xi = xScale(row.progressRate);
|
|
121
|
+
for (let j = 0; j < yStepCount; j++) {
|
|
122
|
+
const dev = yMin + j * yStep;
|
|
123
|
+
const score = this.getScore(row, dev);
|
|
124
|
+
g.append('rect')
|
|
125
|
+
.attr('x', xi)
|
|
126
|
+
.attr('y', yScale(dev + yStep))
|
|
127
|
+
.attr('width', xCellW + 0.5) // 약간 겹쳐서 틈새 방지
|
|
128
|
+
.attr('height', Math.abs(yScale(dev) - yScale(dev + yStep)) + 0.5)
|
|
129
|
+
.attr('fill', SCORE_COLORS[score])
|
|
130
|
+
.attr('opacity', 0.35);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// 경계선: 현재 공정률에서의 점수 전환선
|
|
134
|
+
const currentIdx = Math.min(99, Math.max(0, Math.floor(this.progressRate)));
|
|
135
|
+
const currentRow = rows.find(r => r.progressRate === currentIdx);
|
|
136
|
+
if (currentRow) {
|
|
137
|
+
const boundaries = [currentRow.boundary5to4, currentRow.boundary4to3, currentRow.boundary3to2, currentRow.boundary2to1];
|
|
138
|
+
boundaries.forEach(bdy => {
|
|
139
|
+
g.append('line')
|
|
140
|
+
.attr('x1', xScale(this.progressRate)).attr('x2', xScale(this.progressRate))
|
|
141
|
+
.attr('y1', yScale(bdy) - 3).attr('y2', yScale(bdy) + 3)
|
|
142
|
+
.attr('stroke', '#333').attr('stroke-width', 2);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// 현재 공정률 수직선
|
|
146
|
+
g.append('line')
|
|
147
|
+
.attr('x1', xScale(this.progressRate)).attr('x2', xScale(this.progressRate))
|
|
148
|
+
.attr('y1', 0).attr('y2', plotH)
|
|
149
|
+
.attr('stroke', '#1565c0').attr('stroke-width', 1.5).attr('stroke-dasharray', '4,3');
|
|
150
|
+
// 현재 위치 포인트
|
|
151
|
+
if (this.value !== null) {
|
|
152
|
+
g.append('circle')
|
|
153
|
+
.attr('cx', xScale(this.progressRate))
|
|
154
|
+
.attr('cy', yScale(this.value))
|
|
155
|
+
.attr('r', 7)
|
|
156
|
+
.attr('fill', '#e53935').attr('stroke', '#fff').attr('stroke-width', 2.5);
|
|
157
|
+
// 현재 편차율 수평선
|
|
158
|
+
g.append('line')
|
|
159
|
+
.attr('x1', 0).attr('x2', xScale(this.progressRate))
|
|
160
|
+
.attr('y1', yScale(this.value)).attr('y2', yScale(this.value))
|
|
161
|
+
.attr('stroke', '#e53935').attr('stroke-width', 1).attr('stroke-dasharray', '3,3');
|
|
162
|
+
}
|
|
163
|
+
// 축
|
|
164
|
+
g.append('g')
|
|
165
|
+
.attr('transform', `translate(0,${plotH})`)
|
|
166
|
+
.call(d3.axisBottom(xScale).ticks(10).tickFormat((d) => `${d}%`))
|
|
167
|
+
.selectAll('text').attr('font-size', '10px');
|
|
168
|
+
g.append('g')
|
|
169
|
+
.call(d3.axisLeft(yScale).ticks(8))
|
|
170
|
+
.selectAll('text').attr('font-size', '10px');
|
|
171
|
+
// 축 라벨
|
|
172
|
+
g.append('text')
|
|
173
|
+
.attr('x', plotW / 2).attr('y', plotH + 38)
|
|
174
|
+
.attr('text-anchor', 'middle').attr('font-size', '11px').attr('fill', '#666')
|
|
175
|
+
.text('공정률 (%)');
|
|
176
|
+
g.append('text')
|
|
177
|
+
.attr('transform', 'rotate(-90)')
|
|
178
|
+
.attr('x', -plotH / 2).attr('y', -45)
|
|
179
|
+
.attr('text-anchor', 'middle').attr('font-size', '11px').attr('fill', '#666')
|
|
180
|
+
.text('공기편차 (%)');
|
|
181
|
+
// 범례
|
|
182
|
+
const legendX = plotW + 15;
|
|
183
|
+
const legendY = 10;
|
|
184
|
+
[5, 4, 3, 2, 1].forEach((score, i) => {
|
|
185
|
+
g.append('rect')
|
|
186
|
+
.attr('x', legendX).attr('y', legendY + i * 22)
|
|
187
|
+
.attr('width', 14).attr('height', 14)
|
|
188
|
+
.attr('fill', SCORE_COLORS[score]).attr('opacity', 0.7).attr('rx', 2);
|
|
189
|
+
g.append('text')
|
|
190
|
+
.attr('x', legendX + 20).attr('y', legendY + i * 22 + 11)
|
|
191
|
+
.attr('font-size', '10px').attr('fill', '#555')
|
|
192
|
+
.text(`${score}점`);
|
|
193
|
+
});
|
|
194
|
+
// 헤더
|
|
195
|
+
const currentScore = this.getCurrentScore();
|
|
196
|
+
// 제목은 차트 외부에서 표시하므로 차트 내부에는 미표시
|
|
197
|
+
const headerY = 38;
|
|
198
|
+
if (this.value !== null) {
|
|
199
|
+
svg.append('text')
|
|
200
|
+
.attr('x', margin.left).attr('y', headerY)
|
|
201
|
+
.attr('font-size', '11px').attr('font-weight', 'bold').attr('fill', '#e53935')
|
|
202
|
+
.text(`편차율: ${(this.value * 100).toFixed(2)}%`);
|
|
203
|
+
}
|
|
204
|
+
svg.append('text')
|
|
205
|
+
.attr('x', w / 2).attr('y', headerY)
|
|
206
|
+
.attr('text-anchor', 'middle').attr('font-size', '11px').attr('font-weight', '600').attr('fill', '#1565c0')
|
|
207
|
+
.text(`공정률: ${this.progressRate.toFixed(0)}%`);
|
|
208
|
+
if (currentScore !== null) {
|
|
209
|
+
svg.append('text')
|
|
210
|
+
.attr('x', w - margin.right).attr('y', headerY)
|
|
211
|
+
.attr('text-anchor', 'end').attr('font-size', '11px').attr('font-weight', 'bold').attr('fill', SCORE_COLORS[currentScore])
|
|
212
|
+
.text(`${currentScore}점`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
Kpi2dLookupChart.styles = css `
|
|
217
|
+
:host {
|
|
218
|
+
display: block;
|
|
219
|
+
width: 100%;
|
|
220
|
+
height: 100%;
|
|
221
|
+
min-height: 200px;
|
|
222
|
+
}
|
|
223
|
+
svg {
|
|
224
|
+
width: 100%;
|
|
225
|
+
height: 100%;
|
|
226
|
+
display: block;
|
|
227
|
+
}
|
|
228
|
+
`;
|
|
229
|
+
__decorate([
|
|
230
|
+
property({ type: Object }),
|
|
231
|
+
__metadata("design:type", Object)
|
|
232
|
+
], Kpi2dLookupChart.prototype, "grades", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ type: Number }),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], Kpi2dLookupChart.prototype, "value", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: Number }),
|
|
239
|
+
__metadata("design:type", Number)
|
|
240
|
+
], Kpi2dLookupChart.prototype, "progressRate", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: String }),
|
|
243
|
+
__metadata("design:type", String)
|
|
244
|
+
], Kpi2dLookupChart.prototype, "unit", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
property({ type: String }),
|
|
247
|
+
__metadata("design:type", String)
|
|
248
|
+
], Kpi2dLookupChart.prototype, "kpiName", void 0);
|
|
249
|
+
Kpi2dLookupChart = __decorate([
|
|
250
|
+
customElement('kpi-2d-lookup-chart')
|
|
251
|
+
], Kpi2dLookupChart);
|
|
252
|
+
export { Kpi2dLookupChart };
|
|
253
|
+
//# sourceMappingURL=kpi-2d-lookup-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-2d-lookup-chart.js","sourceRoot":"","sources":["../../client/components/kpi-2d-lookup-chart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AA4BxB,MAA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A3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAAqB;AALrC,gBAAgB;IAD5B,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAsO5B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport * as d3 from 'd3'\n\n/**\n * X13 성과 분포 히트맵 (2D 룩업)\n *\n * 공정률(%)×공기편차(%) 2차원 입력에 대한 성과수준(1~5점) 분포를 히트맵으로 표시.\n * 현재 프로젝트의 위치를 강조 표시하여 성과 수준을 직관적으로 파악.\n *\n * X축: 공정률 (0~100%)\n * Y축: 공기편차 (%)\n * 색상: 성과수준 (5점=파랑 ~ 1점=빨강)\n * ● 현재 프로젝트 위치 (강조 표시)\n */\n\ninterface Grade2DRow {\n progressRate: number\n boundary5to4: number\n boundary4to3: number\n boundary3to2: number\n boundary2to1: number\n}\n\ninterface Grade2DLookup {\n type: 'PROGRESS_DEVIATION_LOOKUP'\n description?: string\n rows: Grade2DRow[]\n}\n\nconst SCORE_COLORS: Record<number, string> = {\n 5: '#1565c0',\n 4: '#4caf50',\n 3: '#ffc107',\n 2: '#ff9800',\n 1: '#e53935'\n}\n\nconst SCORE_LABELS: Record<number, string> = {\n 5: '5점 (우수)',\n 4: '4점 (양호)',\n 3: '3점 (보통)',\n 2: '2점 (미흡)',\n 1: '1점 (매우 미흡)'\n}\n\n@customElement('kpi-2d-lookup-chart')\nexport class Kpi2dLookupChart extends LitElement {\n @property({ type: Object }) grades: Grade2DLookup | null = null\n @property({ type: Number }) value: number | null = null\n @property({ type: Number }) progressRate: number = 50\n @property({ type: String }) unit: string = '%'\n @property({ type: String }) kpiName: string = ''\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 200px;\n }\n svg {\n width: 100%;\n height: 100%;\n display: block;\n }\n `\n\n private chartWidth = 0\n private chartHeight = 0\n private resizeObserver?: ResizeObserver\n\n render() {\n return html`\n <svg\n id=\"lookup-2d-chart\"\n width=${this.chartWidth}\n height=${this.chartHeight}\n viewBox=\"0 0 ${this.chartWidth} ${this.chartHeight}\"\n preserveAspectRatio=\"xMidYMid meet\"\n ></svg>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n const rect = entry.contentRect\n this.chartWidth = rect.width\n this.chartHeight = rect.height\n this.requestUpdate()\n }\n })\n this.resizeObserver.observe(this)\n }\n\n disconnectedCallback() {\n this.resizeObserver?.disconnect()\n super.disconnectedCallback()\n }\n\n updated() {\n this.renderChart()\n }\n\n private getScore(row: Grade2DRow, deviation: number): number {\n if (deviation < row.boundary5to4) return 5\n if (deviation < row.boundary4to3) return 4\n if (deviation < row.boundary3to2) return 3\n if (deviation < row.boundary2to1) return 2\n return 1\n }\n\n private getCurrentScore(): number | null {\n if (this.value === null || !this.grades?.rows) return null\n const idx = Math.min(99, Math.max(0, Math.floor(this.progressRate)))\n const row = this.grades.rows.find(r => r.progressRate === idx)\n return row ? this.getScore(row, this.value) : null\n }\n\n private renderChart() {\n const svg = d3.select(this.renderRoot.querySelector('#lookup-2d-chart'))\n svg.selectAll('*').remove()\n\n if (!this.grades?.rows?.length) {\n svg.append('text')\n .attr('x', this.chartWidth / 2).attr('y', this.chartHeight / 2)\n .attr('text-anchor', 'middle').attr('fill', '#999').attr('font-size', '14px')\n .text('No 2D grade data available')\n return\n }\n\n const w = this.chartWidth || 400\n const h = this.chartHeight || 250\n const margin = { top: 20, right: 80, bottom: 50, left: 60 }\n const plotW = w - margin.left - margin.right\n const plotH = h - margin.top - margin.bottom\n\n if (plotW <= 0 || plotH <= 0) return\n\n const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`)\n const rows = this.grades.rows\n\n // Y축 범위 (편차율)\n const allBoundaries = rows.flatMap(r => [r.boundary5to4, r.boundary4to3, r.boundary3to2, r.boundary2to1])\n let yMin = Math.min(...allBoundaries)\n let yMax = Math.max(...allBoundaries)\n if (this.value !== null) {\n yMin = Math.min(yMin, this.value)\n yMax = Math.max(yMax, this.value)\n }\n const yPad = (yMax - yMin) * 0.1 || 0.01\n yMin -= yPad\n yMax += yPad\n\n // X축: 공정률 0~100\n const xScale = d3.scaleLinear().domain([0, 100]).range([0, plotW])\n const yScale = d3.scaleLinear().domain([yMin, yMax]).range([plotH, 0])\n\n // 히트맵: 각 공정률(x) × 편차율(y) 셀의 점수를 색상으로\n const xSteps = rows.map(r => r.progressRate).sort((a, b) => a - b)\n const yStepCount = 50 // Y축 해상도\n const yStep = (yMax - yMin) / yStepCount\n const xCellW = plotW / Math.max(xSteps.length, 1)\n\n for (const row of rows) {\n const xi = xScale(row.progressRate)\n for (let j = 0; j < yStepCount; j++) {\n const dev = yMin + j * yStep\n const score = this.getScore(row, dev)\n g.append('rect')\n .attr('x', xi)\n .attr('y', yScale(dev + yStep))\n .attr('width', xCellW + 0.5) // 약간 겹쳐서 틈새 방지\n .attr('height', Math.abs(yScale(dev) - yScale(dev + yStep)) + 0.5)\n .attr('fill', SCORE_COLORS[score])\n .attr('opacity', 0.35)\n }\n }\n\n // 경계선: 현재 공정률에서의 점수 전환선\n const currentIdx = Math.min(99, Math.max(0, Math.floor(this.progressRate)))\n const currentRow = rows.find(r => r.progressRate === currentIdx)\n if (currentRow) {\n const boundaries = [currentRow.boundary5to4, currentRow.boundary4to3, currentRow.boundary3to2, currentRow.boundary2to1]\n boundaries.forEach(bdy => {\n g.append('line')\n .attr('x1', xScale(this.progressRate)).attr('x2', xScale(this.progressRate))\n .attr('y1', yScale(bdy) - 3).attr('y2', yScale(bdy) + 3)\n .attr('stroke', '#333').attr('stroke-width', 2)\n })\n }\n\n // 현재 공정률 수직선\n g.append('line')\n .attr('x1', xScale(this.progressRate)).attr('x2', xScale(this.progressRate))\n .attr('y1', 0).attr('y2', plotH)\n .attr('stroke', '#1565c0').attr('stroke-width', 1.5).attr('stroke-dasharray', '4,3')\n\n // 현재 위치 포인트\n if (this.value !== null) {\n g.append('circle')\n .attr('cx', xScale(this.progressRate))\n .attr('cy', yScale(this.value))\n .attr('r', 7)\n .attr('fill', '#e53935').attr('stroke', '#fff').attr('stroke-width', 2.5)\n\n // 현재 편차율 수평선\n g.append('line')\n .attr('x1', 0).attr('x2', xScale(this.progressRate))\n .attr('y1', yScale(this.value)).attr('y2', yScale(this.value))\n .attr('stroke', '#e53935').attr('stroke-width', 1).attr('stroke-dasharray', '3,3')\n }\n\n // 축\n g.append('g')\n .attr('transform', `translate(0,${plotH})`)\n .call(d3.axisBottom(xScale).ticks(10).tickFormat((d: any) => `${d}%`))\n .selectAll('text').attr('font-size', '10px')\n\n g.append('g')\n .call(d3.axisLeft(yScale).ticks(8))\n .selectAll('text').attr('font-size', '10px')\n\n // 축 라벨\n g.append('text')\n .attr('x', plotW / 2).attr('y', plotH + 38)\n .attr('text-anchor', 'middle').attr('font-size', '11px').attr('fill', '#666')\n .text('공정률 (%)')\n\n g.append('text')\n .attr('transform', 'rotate(-90)')\n .attr('x', -plotH / 2).attr('y', -45)\n .attr('text-anchor', 'middle').attr('font-size', '11px').attr('fill', '#666')\n .text('공기편차 (%)')\n\n // 범례\n const legendX = plotW + 15\n const legendY = 10\n ;[5, 4, 3, 2, 1].forEach((score, i) => {\n g.append('rect')\n .attr('x', legendX).attr('y', legendY + i * 22)\n .attr('width', 14).attr('height', 14)\n .attr('fill', SCORE_COLORS[score]).attr('opacity', 0.7).attr('rx', 2)\n\n g.append('text')\n .attr('x', legendX + 20).attr('y', legendY + i * 22 + 11)\n .attr('font-size', '10px').attr('fill', '#555')\n .text(`${score}점`)\n })\n\n // 헤더\n const currentScore = this.getCurrentScore()\n\n // 제목은 차트 외부에서 표시하므로 차트 내부에는 미표시\n\n const headerY = 38\n if (this.value !== null) {\n svg.append('text')\n .attr('x', margin.left).attr('y', headerY)\n .attr('font-size', '11px').attr('font-weight', 'bold').attr('fill', '#e53935')\n .text(`편차율: ${(this.value * 100).toFixed(2)}%`)\n }\n\n svg.append('text')\n .attr('x', w / 2).attr('y', headerY)\n .attr('text-anchor', 'middle').attr('font-size', '11px').attr('font-weight', '600').attr('fill', '#1565c0')\n .text(`공정률: ${this.progressRate.toFixed(0)}%`)\n\n if (currentScore !== null) {\n svg.append('text')\n .attr('x', w - margin.right).attr('y', headerY)\n .attr('text-anchor', 'end').attr('font-size', '11px').attr('font-weight', 'bold').attr('fill', SCORE_COLORS[currentScore])\n .text(`${currentScore}점`)\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class SvKpiBoxplotChart extends LitElement {
|
|
3
|
+
data: any[];
|
|
4
|
+
groups: string[];
|
|
5
|
+
minKey: string;
|
|
6
|
+
maxKey: string;
|
|
7
|
+
meanKey: string;
|
|
8
|
+
medianKey: string;
|
|
9
|
+
q1Key: string;
|
|
10
|
+
q3Key: string;
|
|
11
|
+
valueKey: string;
|
|
12
|
+
currentGroup: string;
|
|
13
|
+
independentScale: boolean;
|
|
14
|
+
static styles: import("lit").CSSResult;
|
|
15
|
+
private chartWidth;
|
|
16
|
+
private chartHeight;
|
|
17
|
+
private resizeObserver?;
|
|
18
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
updated(): void;
|
|
22
|
+
private getOrgValue;
|
|
23
|
+
drawBoxplot(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
let SvKpiBoxplotChart = class SvKpiBoxplotChart extends LitElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.data = [];
|
|
9
|
+
this.groups = []; // 조직 단위 목록 (빈 배열이면 데이터에서 자동 추출)
|
|
10
|
+
this.minKey = 'min';
|
|
11
|
+
this.maxKey = 'max';
|
|
12
|
+
this.meanKey = 'mean';
|
|
13
|
+
this.medianKey = 'median';
|
|
14
|
+
this.q1Key = 'q1';
|
|
15
|
+
this.q3Key = 'q3';
|
|
16
|
+
this.valueKey = 'value';
|
|
17
|
+
this.currentGroup = '';
|
|
18
|
+
this.independentScale = false;
|
|
19
|
+
this.chartWidth = 0;
|
|
20
|
+
this.chartHeight = 0;
|
|
21
|
+
this.getOrgValue = (d) => d.org || d.group;
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return html `<svg
|
|
25
|
+
id="boxplot"
|
|
26
|
+
width=${this.chartWidth}
|
|
27
|
+
height=${this.chartHeight}
|
|
28
|
+
viewBox="0 0 ${this.chartWidth} ${this.chartHeight}"
|
|
29
|
+
preserveAspectRatio="xMidYMid meet"
|
|
30
|
+
></svg>`;
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
35
|
+
for (const entry of entries) {
|
|
36
|
+
const rect = entry.contentRect;
|
|
37
|
+
this.chartWidth = rect.width;
|
|
38
|
+
this.chartHeight = rect.height;
|
|
39
|
+
this.requestUpdate();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.resizeObserver.observe(this);
|
|
43
|
+
}
|
|
44
|
+
disconnectedCallback() {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
47
|
+
super.disconnectedCallback();
|
|
48
|
+
}
|
|
49
|
+
updated() {
|
|
50
|
+
this.drawBoxplot();
|
|
51
|
+
}
|
|
52
|
+
drawBoxplot() {
|
|
53
|
+
var _a;
|
|
54
|
+
const svg = d3.select(this.renderRoot.querySelector('#boxplot'));
|
|
55
|
+
svg.selectAll('*').remove();
|
|
56
|
+
// 데이터 검증
|
|
57
|
+
if (!this.data || this.data.length === 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const w = this.chartWidth || 300;
|
|
61
|
+
const h = this.chartHeight || 300;
|
|
62
|
+
const margin = {
|
|
63
|
+
top: 20,
|
|
64
|
+
right: 20,
|
|
65
|
+
bottom: 40,
|
|
66
|
+
left: this.independentScale ? 20 : 40
|
|
67
|
+
};
|
|
68
|
+
const plotW = w - margin.left - margin.right;
|
|
69
|
+
const plotH = h - margin.top - margin.bottom;
|
|
70
|
+
// x축: 조직 단위 (그룹) - org 또는 group 필드 지원
|
|
71
|
+
const groups = this.groups.length > 0 ? this.groups : [...new Set(this.data.map(d => this.getOrgValue(d)).filter(org => org != null))];
|
|
72
|
+
if (groups.length === 0) {
|
|
73
|
+
console.warn('No valid groups found in data:', this.data);
|
|
74
|
+
return; // 유효한 그룹이 없으면 차트를 그리지 않음
|
|
75
|
+
}
|
|
76
|
+
const x = d3.scaleBand().domain(groups).range([0, plotW]).padding(0.4);
|
|
77
|
+
// y축 스케일 설정
|
|
78
|
+
let y;
|
|
79
|
+
if (this.independentScale) {
|
|
80
|
+
// 독립 스케일: 각 시리즈별로 개별 스케일 생성 (모두 0-100 범위로 통일)
|
|
81
|
+
const yScales = this.data.map(d => {
|
|
82
|
+
return {
|
|
83
|
+
org: d.org,
|
|
84
|
+
scale: d3.scaleLinear().domain([0, 100]).range([plotH, 0])
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
// 기본 y축은 첫 번째 스케일 사용
|
|
88
|
+
y = ((_a = yScales[0]) === null || _a === void 0 ? void 0 : _a.scale) || d3.scaleLinear().domain([0, 100]).range([plotH, 0]);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// 통합 스케일: 0-100 범위로 고정
|
|
92
|
+
y = d3.scaleLinear().domain([0, 100]).range([plotH, 0]);
|
|
93
|
+
}
|
|
94
|
+
const g = svg.attr('width', w).attr('height', h).append('g').attr('transform', `translate(${margin.left},${margin.top})`);
|
|
95
|
+
// Y축 (왼쪽)
|
|
96
|
+
if (!this.independentScale) {
|
|
97
|
+
const yAxis = g.append('g').call(d3.axisLeft(y).tickSize(-plotW));
|
|
98
|
+
yAxis.select('.domain').remove();
|
|
99
|
+
yAxis.selectAll('.tick line').attr('stroke', '#e0e0e0').attr('stroke-width', 1).attr('opacity', 0.7);
|
|
100
|
+
yAxis.selectAll('.tick text').attr('fill', '#666').attr('font-size', '12px');
|
|
101
|
+
}
|
|
102
|
+
// X축 (아래쪽)
|
|
103
|
+
const xAxis = g.append('g').attr('transform', `translate(0,${plotH})`).call(d3.axisBottom(x).tickSize(0));
|
|
104
|
+
xAxis.select('.domain').attr('stroke', '#e0e0e0').attr('stroke-width', 1);
|
|
105
|
+
xAxis.selectAll('.tick text').attr('fill', '#333').attr('font-size', '13px').attr('font-weight', '500').attr('dy', '1.5em');
|
|
106
|
+
// 툴팁 (전체 공유, forEach 밖)
|
|
107
|
+
const tooltip = svg.append('g').attr('class', 'boxplot-tooltip').attr('visibility', 'hidden');
|
|
108
|
+
tooltip.append('rect').attr('rx', 4).attr('ry', 4).attr('fill', 'rgba(33,33,33,0.9)');
|
|
109
|
+
tooltip.append('text').attr('fill', '#fff').attr('font-size', '10px');
|
|
110
|
+
const showTooltip = (evt, lines) => {
|
|
111
|
+
const tipText = tooltip.select('text');
|
|
112
|
+
tipText.selectAll('tspan').remove();
|
|
113
|
+
lines.forEach((line, i) => {
|
|
114
|
+
tipText.append('tspan').attr('x', 8).attr('dy', i === 0 ? 14 : 13).text(line);
|
|
115
|
+
});
|
|
116
|
+
const tipW = Math.max(...lines.map(l => l.length)) * 8 + 24;
|
|
117
|
+
const tipH = lines.length * 13 + 10;
|
|
118
|
+
const [mx, my] = d3.pointer(evt, svg.node());
|
|
119
|
+
const tx = Math.min(mx + 10, (this.chartWidth || 400) - tipW - 5);
|
|
120
|
+
const ty = Math.max(my - tipH - 5, 5);
|
|
121
|
+
tooltip.select('rect').attr('x', tx).attr('y', ty).attr('width', tipW).attr('height', tipH);
|
|
122
|
+
tipText.attr('transform', `translate(${tx},${ty})`);
|
|
123
|
+
tooltip.attr('visibility', 'visible').raise();
|
|
124
|
+
};
|
|
125
|
+
const hideTooltip = () => tooltip.attr('visibility', 'hidden');
|
|
126
|
+
// 박스플롯 - 각 그룹별로 박스 생성
|
|
127
|
+
groups.forEach(groupName => {
|
|
128
|
+
var _a;
|
|
129
|
+
const groupData = this.data.find(d => this.getOrgValue(d) === groupName);
|
|
130
|
+
if (!groupData)
|
|
131
|
+
return;
|
|
132
|
+
const requiredFields = [this.minKey, this.maxKey, this.q1Key, this.q3Key, this.medianKey, this.meanKey];
|
|
133
|
+
if (requiredFields.some(field => groupData[field] == null))
|
|
134
|
+
return;
|
|
135
|
+
const gx = (_a = x(groupName)) !== null && _a !== void 0 ? _a : 0;
|
|
136
|
+
let currentY = y;
|
|
137
|
+
if (this.independentScale) {
|
|
138
|
+
currentY = d3.scaleLinear().domain([0, 100]).range([plotH, 0]);
|
|
139
|
+
}
|
|
140
|
+
const actualMin = groupData[this.minKey];
|
|
141
|
+
const actualMax = groupData[this.maxKey];
|
|
142
|
+
// 박스
|
|
143
|
+
g.append('rect')
|
|
144
|
+
.attr('x', gx)
|
|
145
|
+
.attr('y', currentY(groupData[this.q3Key]))
|
|
146
|
+
.attr('width', x.bandwidth())
|
|
147
|
+
.attr('height', currentY(groupData[this.q1Key]) - currentY(groupData[this.q3Key]))
|
|
148
|
+
.attr('fill', '#B3D4FC')
|
|
149
|
+
.attr('opacity', 0.8)
|
|
150
|
+
.attr('stroke', '#7BB3F0')
|
|
151
|
+
.attr('stroke-width', 1)
|
|
152
|
+
.style('cursor', 'pointer')
|
|
153
|
+
.on('mouseenter', (evt) => showTooltip(evt, [
|
|
154
|
+
groupName,
|
|
155
|
+
`최대: ${Number(groupData[this.maxKey]).toFixed(2)}`,
|
|
156
|
+
`Q3: ${Number(groupData[this.q3Key]).toFixed(2)}`,
|
|
157
|
+
`중앙값: ${Number(groupData[this.medianKey]).toFixed(2)}`,
|
|
158
|
+
`Q1: ${Number(groupData[this.q1Key]).toFixed(2)}`,
|
|
159
|
+
`최소: ${Number(groupData[this.minKey]).toFixed(2)}`,
|
|
160
|
+
`평균: ${Number(groupData[this.meanKey]).toFixed(2)}`
|
|
161
|
+
]))
|
|
162
|
+
.on('mouseleave', hideTooltip);
|
|
163
|
+
// 중앙선(중앙값)
|
|
164
|
+
g.append('line')
|
|
165
|
+
.attr('x1', gx)
|
|
166
|
+
.attr('x2', gx + x.bandwidth())
|
|
167
|
+
.attr('y1', currentY(groupData[this.medianKey]))
|
|
168
|
+
.attr('y2', currentY(groupData[this.medianKey]))
|
|
169
|
+
.attr('stroke', '#7BB3F0')
|
|
170
|
+
.attr('stroke-width', 1.5);
|
|
171
|
+
// 수염 (fence 내부의 min-max)
|
|
172
|
+
g.append('line')
|
|
173
|
+
.attr('x1', gx + x.bandwidth() / 2)
|
|
174
|
+
.attr('x2', gx + x.bandwidth() / 2)
|
|
175
|
+
.attr('y1', currentY(actualMin))
|
|
176
|
+
.attr('y2', currentY(actualMax))
|
|
177
|
+
.attr('stroke', '#7BB3F0')
|
|
178
|
+
.attr('stroke-width', 1);
|
|
179
|
+
// min/max 선 (fence 내부)
|
|
180
|
+
g.append('line')
|
|
181
|
+
.attr('x1', gx + x.bandwidth() / 4)
|
|
182
|
+
.attr('x2', gx + (x.bandwidth() * 3) / 4)
|
|
183
|
+
.attr('y1', currentY(actualMin))
|
|
184
|
+
.attr('y2', currentY(actualMin))
|
|
185
|
+
.attr('stroke', '#7BB3F0')
|
|
186
|
+
.attr('stroke-width', 1);
|
|
187
|
+
g.append('line')
|
|
188
|
+
.attr('x1', gx + x.bandwidth() / 4)
|
|
189
|
+
.attr('x2', gx + (x.bandwidth() * 3) / 4)
|
|
190
|
+
.attr('y1', currentY(actualMax))
|
|
191
|
+
.attr('y2', currentY(actualMax))
|
|
192
|
+
.attr('stroke', '#7BB3F0')
|
|
193
|
+
.attr('stroke-width', 1);
|
|
194
|
+
// 평균값 (녹색)
|
|
195
|
+
g.append('circle')
|
|
196
|
+
.attr('cx', gx + x.bandwidth() / 2)
|
|
197
|
+
.attr('cy', currentY(groupData[this.meanKey]))
|
|
198
|
+
.attr('r', 3)
|
|
199
|
+
.attr('fill', '#4CAF50')
|
|
200
|
+
.attr('stroke', '#fff')
|
|
201
|
+
.attr('stroke-width', 1)
|
|
202
|
+
.style('cursor', 'pointer')
|
|
203
|
+
.on('mouseenter', (evt) => showTooltip(evt, [
|
|
204
|
+
`${groupName} — 평균`,
|
|
205
|
+
`${Number(groupData[this.meanKey]).toFixed(2)}`
|
|
206
|
+
]))
|
|
207
|
+
.on('mouseleave', hideTooltip);
|
|
208
|
+
// 현재 프로젝트 값 (아웃라이어면 빨간색, 정상이면 오렌지색)
|
|
209
|
+
if (groupData[this.valueKey] != null) {
|
|
210
|
+
const currentValue = groupData[this.valueKey];
|
|
211
|
+
const isOutlier = currentValue < groupData[this.minKey] || currentValue > groupData[this.maxKey];
|
|
212
|
+
g.append('circle')
|
|
213
|
+
.attr('cx', gx + x.bandwidth() / 2)
|
|
214
|
+
.attr('cy', currentY(currentValue))
|
|
215
|
+
.attr('r', 3)
|
|
216
|
+
.attr('fill', isOutlier ? '#ff4444' : '#ff9800')
|
|
217
|
+
.attr('stroke', '#fff')
|
|
218
|
+
.attr('stroke-width', 1)
|
|
219
|
+
.style('cursor', 'pointer')
|
|
220
|
+
.on('mouseenter', (evt) => showTooltip(evt, [
|
|
221
|
+
`${groupName} — 현재 프로젝트`,
|
|
222
|
+
`값: ${Number(currentValue).toFixed(2)}`,
|
|
223
|
+
isOutlier ? '⚠ 이상치' : '정상 범위'
|
|
224
|
+
]))
|
|
225
|
+
.on('mouseleave', hideTooltip);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
// 현재 그룹 값 강조는 이미 위에서 처리되므로 제거
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
SvKpiBoxplotChart.styles = css `
|
|
232
|
+
:host {
|
|
233
|
+
display: block;
|
|
234
|
+
width: 100%;
|
|
235
|
+
height: 100%;
|
|
236
|
+
}
|
|
237
|
+
svg {
|
|
238
|
+
width: 100%;
|
|
239
|
+
height: 100%;
|
|
240
|
+
display: block;
|
|
241
|
+
}
|
|
242
|
+
`;
|
|
243
|
+
__decorate([
|
|
244
|
+
property({ type: Array }),
|
|
245
|
+
__metadata("design:type", Array)
|
|
246
|
+
], SvKpiBoxplotChart.prototype, "data", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property({ type: Array }),
|
|
249
|
+
__metadata("design:type", Array)
|
|
250
|
+
], SvKpiBoxplotChart.prototype, "groups", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
property({ type: String }),
|
|
253
|
+
__metadata("design:type", String)
|
|
254
|
+
], SvKpiBoxplotChart.prototype, "minKey", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
property({ type: String }),
|
|
257
|
+
__metadata("design:type", String)
|
|
258
|
+
], SvKpiBoxplotChart.prototype, "maxKey", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
property({ type: String }),
|
|
261
|
+
__metadata("design:type", String)
|
|
262
|
+
], SvKpiBoxplotChart.prototype, "meanKey", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
property({ type: String }),
|
|
265
|
+
__metadata("design:type", String)
|
|
266
|
+
], SvKpiBoxplotChart.prototype, "medianKey", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
property({ type: String }),
|
|
269
|
+
__metadata("design:type", String)
|
|
270
|
+
], SvKpiBoxplotChart.prototype, "q1Key", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
property({ type: String }),
|
|
273
|
+
__metadata("design:type", String)
|
|
274
|
+
], SvKpiBoxplotChart.prototype, "q3Key", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
property({ type: String }),
|
|
277
|
+
__metadata("design:type", String)
|
|
278
|
+
], SvKpiBoxplotChart.prototype, "valueKey", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
property({ type: String }),
|
|
281
|
+
__metadata("design:type", String)
|
|
282
|
+
], SvKpiBoxplotChart.prototype, "currentGroup", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
property({ type: Boolean }),
|
|
285
|
+
__metadata("design:type", Boolean)
|
|
286
|
+
], SvKpiBoxplotChart.prototype, "independentScale", void 0);
|
|
287
|
+
SvKpiBoxplotChart = __decorate([
|
|
288
|
+
customElement('sv-kpi-boxplot-chart')
|
|
289
|
+
], SvKpiBoxplotChart);
|
|
290
|
+
export { SvKpiBoxplotChart };
|
|
291
|
+
//# sourceMappingURL=kpi-boxplot-chart.js.map
|