@ossy/consultancy 3.20.0 → 3.20.1
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/package.json +3 -3
- package/src/Forecast.jsx +10 -5
- package/src/forecast-kpi-chart.js +13 -10
- package/src/forecast-kpi-chart.spec.js +6 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/consultancy",
|
|
3
3
|
"description": "Consultancy feature package — schemas, forecasts UI, and assignment margins",
|
|
4
|
-
"version": "3.20.
|
|
4
|
+
"version": "3.20.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ossy/schema": "^3.20.
|
|
28
|
+
"@ossy/schema": "^3.20.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@ossy/calendar": "*",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"jest": "^30.2.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "3e8bb118b3ef163792a004663ccb803ab51a8601"
|
|
42
42
|
}
|
package/src/Forecast.jsx
CHANGED
|
@@ -120,9 +120,14 @@ function ForecastKpiChart ({ months }) {
|
|
|
120
120
|
data-consultancy-kpi-chart
|
|
121
121
|
viewBox={`0 0 ${chart.viewWidth} ${chart.viewHeight}`}
|
|
122
122
|
width="100%"
|
|
123
|
-
|
|
124
|
-
style={{
|
|
125
|
-
|
|
123
|
+
role="img"
|
|
124
|
+
style={{
|
|
125
|
+
display: 'block',
|
|
126
|
+
width: '100%',
|
|
127
|
+
height: 'auto',
|
|
128
|
+
aspectRatio: `${chart.viewWidth} / ${chart.viewHeight}`,
|
|
129
|
+
}}
|
|
130
|
+
preserveAspectRatio="xMidYMid meet"
|
|
126
131
|
>
|
|
127
132
|
{chart.seriesPaths.map((series) => (
|
|
128
133
|
series.path ? (
|
|
@@ -134,7 +139,7 @@ function ForecastKpiChart ({ months }) {
|
|
|
134
139
|
strokeWidth={2}
|
|
135
140
|
strokeLinejoin="round"
|
|
136
141
|
strokeLinecap="round"
|
|
137
|
-
strokeDasharray={series.dashed ? '4
|
|
142
|
+
strokeDasharray={series.dashed ? '6 4' : undefined}
|
|
138
143
|
vectorEffect="non-scaling-stroke"
|
|
139
144
|
/>
|
|
140
145
|
) : null
|
|
@@ -147,7 +152,7 @@ function ForecastKpiChart ({ months }) {
|
|
|
147
152
|
y={label.y}
|
|
148
153
|
textAnchor="middle"
|
|
149
154
|
fill="var(--fg-secondary, currentColor)"
|
|
150
|
-
fontSize={
|
|
155
|
+
fontSize={12}
|
|
151
156
|
style={{ opacity: 0.75 }}
|
|
152
157
|
>
|
|
153
158
|
{label.label}
|
|
@@ -67,26 +67,29 @@ export function valueToY (value, extent, padY, innerH) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Build SVG path strings for KPI series plus all-month X labels.
|
|
69
69
|
*
|
|
70
|
+
* ViewBox defaults use a wide aspect ratio (~3.5:1) so `preserveAspectRatio="meet"`
|
|
71
|
+
* can scale uniformly without squishing axis labels (see #1001).
|
|
72
|
+
*
|
|
70
73
|
* @param {object} options
|
|
71
74
|
* @param {Array<Record<string, unknown>>} options.months
|
|
72
75
|
* @param {Array<{ key: string, label: string, color: string, dashed?: boolean }>} options.series
|
|
73
76
|
* @param {string} [options.language='en']
|
|
74
|
-
* @param {number} [options.viewWidth=
|
|
75
|
-
* @param {number} [options.plotHeight=
|
|
76
|
-
* @param {number} [options.padX=
|
|
77
|
-
* @param {number} [options.padTop=
|
|
78
|
-
* @param {number} [options.padBottom=
|
|
77
|
+
* @param {number} [options.viewWidth=560]
|
|
78
|
+
* @param {number} [options.plotHeight=140]
|
|
79
|
+
* @param {number} [options.padX=16]
|
|
80
|
+
* @param {number} [options.padTop=12]
|
|
81
|
+
* @param {number} [options.padBottom=28]
|
|
79
82
|
* @returns {{ viewWidth: number, viewHeight: number, seriesPaths: Array<object>, monthLabels: Array<object> } | null}
|
|
80
83
|
*/
|
|
81
84
|
export function buildKpiChartLayout ({
|
|
82
85
|
months,
|
|
83
86
|
series,
|
|
84
87
|
language = 'en',
|
|
85
|
-
viewWidth =
|
|
86
|
-
plotHeight =
|
|
87
|
-
padX =
|
|
88
|
-
padTop =
|
|
89
|
-
padBottom =
|
|
88
|
+
viewWidth = 560,
|
|
89
|
+
plotHeight = 140,
|
|
90
|
+
padX = 16,
|
|
91
|
+
padTop = 12,
|
|
92
|
+
padBottom = 28,
|
|
90
93
|
}) {
|
|
91
94
|
if (!months?.length || !series?.length) return null
|
|
92
95
|
|
|
@@ -110,6 +110,12 @@ describe('buildKpiChartLayout', () => {
|
|
|
110
110
|
expect(layout.monthLabels[11].x).toBeCloseTo(layout.padX + 11 * layout.step)
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
+
it('defaults to a wide viewBox so meet-scaling keeps labels readable', () => {
|
|
114
|
+
const layout = buildKpiChartLayout({ months: sampleMonths, series })
|
|
115
|
+
expect(layout.viewWidth).toBe(560)
|
|
116
|
+
expect(layout.viewHeight / layout.viewWidth).toBeLessThan(0.5)
|
|
117
|
+
})
|
|
118
|
+
|
|
113
119
|
it('returns null for empty months', () => {
|
|
114
120
|
expect(buildKpiChartLayout({ months: [], series })).toBeNull()
|
|
115
121
|
})
|