@eturnity/eturnity_reusable_components 8.16.9-qa-16-03-26.2 → 8.16.9-qa-16-03-26.3
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
CHANGED
@@ -32,6 +32,7 @@
|
|
32
32
|
>
|
33
33
|
<InputNumber
|
34
34
|
:allow-negative="false"
|
35
|
+
:disabled="isInputsDisabled"
|
35
36
|
:error-message="null"
|
36
37
|
input-height="36px"
|
37
38
|
:is-border-error-only="true"
|
@@ -40,12 +41,14 @@
|
|
40
41
|
? calculatePercentageTotal(item.label) !== 100
|
41
42
|
: false
|
42
43
|
"
|
43
|
-
:number-precision="0"
|
44
|
+
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
44
45
|
:min-decimals="0"
|
45
46
|
text-align="center"
|
46
47
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
47
48
|
:value="getDisplayValue(series.data, item.label)"
|
48
|
-
@input-blur="
|
49
|
+
@input-blur="
|
50
|
+
handleInputBlur($event, series.name, item.label, series.data)
|
51
|
+
"
|
49
52
|
@input-focus="handleInputFocus(series.name, item.label)"
|
50
53
|
/>
|
51
54
|
</InputGroup>
|
@@ -60,15 +63,15 @@
|
|
60
63
|
>
|
61
64
|
<InputNumber
|
62
65
|
:allow-negative="false"
|
66
|
+
:disabled="isInputsDisabled"
|
63
67
|
input-height="36px"
|
64
68
|
:is-read-only="true"
|
65
|
-
:number-precision="0"
|
69
|
+
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
66
70
|
:min-decimals="0"
|
67
71
|
text-align="center"
|
68
72
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
69
73
|
:value="calculatePercentageTotal(item.label)"
|
70
74
|
/>
|
71
|
-
{{ $c.log(calculatePercentageTotal(item.label)) }}
|
72
75
|
</InputGroup>
|
73
76
|
</TotalInputRow>
|
74
77
|
|
@@ -108,12 +111,13 @@
|
|
108
111
|
:key="index"
|
109
112
|
>
|
110
113
|
<InputNumber
|
114
|
+
:disabled="isInputsDisabled"
|
111
115
|
input-height="36px"
|
112
116
|
:min-decimals="0"
|
113
117
|
:number-precision="2"
|
114
118
|
text-align="center"
|
115
119
|
:value="item.value"
|
116
|
-
@input-blur="handleInputBlur($event, null, item.label)"
|
120
|
+
@input-blur="handleInputBlur($event, null, item.label, null)"
|
117
121
|
@input-focus="handleInputFocus(null, item.label)"
|
118
122
|
/>
|
119
123
|
</InputGroup>
|
@@ -125,7 +129,7 @@
|
|
125
129
|
</template>
|
126
130
|
|
127
131
|
<script setup>
|
128
|
-
import { ref, watch, onMounted } from 'vue'
|
132
|
+
import { ref, watch, watchEffect, onMounted } from 'vue'
|
129
133
|
import styled from 'vue3-styled-components'
|
130
134
|
import InputNumber from '../inputs/inputNumber'
|
131
135
|
|
@@ -175,34 +179,52 @@
|
|
175
179
|
default: 'absolute',
|
176
180
|
validator: (value) => ['absolute', 'percentage'].includes(value),
|
177
181
|
},
|
182
|
+
isInputsDisabled: {
|
183
|
+
type: Boolean,
|
184
|
+
default: false,
|
185
|
+
},
|
178
186
|
})
|
179
187
|
|
180
188
|
const seriesData = ref([])
|
181
189
|
|
182
|
-
onMounted(() => {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
})
|
196
|
-
|
197
|
-
|
198
|
-
|
190
|
+
// onMounted(() => {
|
191
|
+
// seriesData.value = props.series.map((item) => {
|
192
|
+
// const data = item.data.map((d) => ({
|
193
|
+
// label: d.label,
|
194
|
+
// value: d.value,
|
195
|
+
// originalValue: d.value,
|
196
|
+
// }))
|
197
|
+
|
198
|
+
// return {
|
199
|
+
// name: item.name,
|
200
|
+
// data,
|
201
|
+
// }
|
202
|
+
// })
|
203
|
+
// })
|
204
|
+
|
205
|
+
watchEffect(() => {
|
206
|
+
let isNewSetOfSeries = false
|
207
|
+
const seriesDataCopy = [...seriesData.value]
|
208
|
+
if (
|
209
|
+
!seriesDataCopy.length ||
|
210
|
+
!props.series.length ||
|
211
|
+
seriesDataCopy.length !== props.series.length ||
|
212
|
+
!seriesDataCopy.some((item) => {
|
213
|
+
return props.series.map((s) => s.name).includes(item.name)
|
214
|
+
})
|
215
|
+
) {
|
216
|
+
isNewSetOfSeries = true
|
217
|
+
}
|
218
|
+
const currentSeriesData = !isNewSetOfSeries ? seriesDataCopy : []
|
199
219
|
const newSeriesData = []
|
200
220
|
|
201
221
|
props.series.forEach((item, itemIndex) => {
|
202
222
|
const data = item.data.map((d, dIndex) => ({
|
203
223
|
label: d.label,
|
204
224
|
value: d.value,
|
205
|
-
originalValue: currentSeriesData
|
225
|
+
originalValue: currentSeriesData.length
|
226
|
+
? currentSeriesData[itemIndex].data[dIndex].originalValue
|
227
|
+
: d.value,
|
206
228
|
}))
|
207
229
|
|
208
230
|
newSeriesData.push({
|
@@ -254,7 +276,7 @@
|
|
254
276
|
}, 0)
|
255
277
|
}
|
256
278
|
|
257
|
-
const getDisplayValue = (data, label) => {
|
279
|
+
const getDisplayValue = (data, label, shouldRound = true) => {
|
258
280
|
if (props.fieldMode === 'absolute') {
|
259
281
|
return data.find((d) => d.label === label)?.value || ''
|
260
282
|
}
|
@@ -267,7 +289,7 @@
|
|
267
289
|
return sum + value
|
268
290
|
}, 0)
|
269
291
|
|
270
|
-
return
|
292
|
+
return shouldRound ? (value / total) * 100 : (value / total) * 100
|
271
293
|
}
|
272
294
|
|
273
295
|
const calculatePercentageTotal = (label) => {
|
@@ -288,7 +310,7 @@
|
|
288
310
|
return Math.round(totalPercentage)
|
289
311
|
}
|
290
312
|
|
291
|
-
const handleInputBlur = (_value, seriesName, label) => {
|
313
|
+
const handleInputBlur = (_value, seriesName, label, currentSeriesData) => {
|
292
314
|
let value = Number(_value)
|
293
315
|
|
294
316
|
if (props.fieldMode === 'percentage') {
|
@@ -301,7 +323,18 @@
|
|
301
323
|
value = (value / 100) * total
|
302
324
|
}
|
303
325
|
|
304
|
-
const payload = seriesName
|
326
|
+
const payload = seriesName
|
327
|
+
? {
|
328
|
+
seriesName,
|
329
|
+
label,
|
330
|
+
value,
|
331
|
+
inputValue: _value,
|
332
|
+
percentage: Number(
|
333
|
+
getDisplayValue(currentSeriesData, label, false).toFixed(2)
|
334
|
+
),
|
335
|
+
totalSeriesValue: calculateTotalOriginalValue(label),
|
336
|
+
}
|
337
|
+
: { label, value }
|
305
338
|
emit('input-blur', payload)
|
306
339
|
focusedInput.value = null
|
307
340
|
|
@@ -331,6 +364,11 @@
|
|
331
364
|
emit('sync-scroll', event.target.scrollLeft)
|
332
365
|
}
|
333
366
|
|
367
|
+
const toFixedNoRounding = (number, decimals) => {
|
368
|
+
const factor = Math.pow(10, decimals)
|
369
|
+
return Math.floor(number * factor) / factor
|
370
|
+
}
|
371
|
+
|
334
372
|
defineExpose({
|
335
373
|
syncScroll,
|
336
374
|
})
|
@@ -84,7 +84,7 @@ export function useAxisCalculations(props, maxValue) {
|
|
84
84
|
})
|
85
85
|
|
86
86
|
const yAxisWidth = computed(() => {
|
87
|
-
return !!props.yAxisTitle || props.isBottomFieldsShown ? '
|
87
|
+
return !!props.yAxisTitle || props.isBottomFieldsShown ? '80px' : '60px'
|
88
88
|
})
|
89
89
|
|
90
90
|
const isChartControlsShown = (position) => {
|
@@ -16,7 +16,9 @@ export function useTooltip(chartId, normalizedData) {
|
|
16
16
|
if (!showTooltipContent.value) {
|
17
17
|
showTooltipContent.value = true
|
18
18
|
}
|
19
|
-
if (isObjectEqual(item, tooltipData.value))
|
19
|
+
if (isObjectEqual(item, tooltipData.value)) {
|
20
|
+
return
|
21
|
+
}
|
20
22
|
|
21
23
|
const totalValue = item.segments.reduce((acc, segment) => {
|
22
24
|
return acc + segment.value
|
@@ -53,16 +55,27 @@ export function useTooltip(chartId, normalizedData) {
|
|
53
55
|
|
54
56
|
isInputFocused.value = true
|
55
57
|
const barData = normalizedData.value.find((item) => item.label === label)
|
56
|
-
|
57
58
|
if (!barData) return
|
59
|
+
|
60
|
+
const totalValue = barData.segments.reduce((acc, segment) => {
|
61
|
+
return acc + segment.value
|
62
|
+
}, 0)
|
63
|
+
const segments = barData.segments.map((segment) => {
|
64
|
+
let valuePercentage = (segment.value / totalValue) * 100
|
65
|
+
segment.valuePercentage = Math.round(valuePercentage)
|
66
|
+
|
67
|
+
return segment
|
68
|
+
})
|
69
|
+
barData.segments = segments
|
58
70
|
focusedBarData.value = barData
|
71
|
+
|
59
72
|
const barElement = document.querySelector(
|
60
73
|
`.barchart-${chartId} .bar-group:nth-child(${
|
61
74
|
normalizedData.value.indexOf(barData) + 1
|
62
75
|
})`
|
63
76
|
)
|
64
|
-
|
65
77
|
if (!barElement) return
|
78
|
+
|
66
79
|
// Get the last bar segment, samee as hover behavior
|
67
80
|
const targetElement = barElement.querySelector('.bar-segment:last-child')
|
68
81
|
const rect = targetElement.getBoundingClientRect()
|
@@ -163,6 +163,7 @@
|
|
163
163
|
:data="data"
|
164
164
|
:field-mode="fieldMode"
|
165
165
|
:is-chart-controls-shown-in-bottom="isChartControlsShown('bottom')"
|
166
|
+
:is-inputs-disabled="isLoading"
|
166
167
|
:is-scrollable="isScrollable"
|
167
168
|
:series="series"
|
168
169
|
:y-axis-width="yAxisWidth"
|
@@ -387,13 +388,22 @@
|
|
387
388
|
}
|
388
389
|
|
389
390
|
const handleValueFormatter = (value) => {
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
391
|
+
let formattedValue = value
|
392
|
+
if (value < 1000) {
|
393
|
+
formattedValue = numberToString({
|
394
|
+
value: formattedValue,
|
395
|
+
numberPrecision: 0,
|
396
|
+
minDecimals: 0,
|
397
|
+
})
|
398
|
+
} else if (value < 1000000) {
|
399
|
+
formattedValue = Number((value / 1000).toFixed(2))
|
400
|
+
} else {
|
401
|
+
formattedValue = Number((value / 1000000).toFixed(2))
|
402
|
+
}
|
395
403
|
|
396
|
-
return props.valueFormatter
|
404
|
+
return props.valueFormatter
|
405
|
+
? props.valueFormatter(formattedValue)
|
406
|
+
: formattedValue
|
397
407
|
}
|
398
408
|
|
399
409
|
const getYAxisLabel = (label) => {
|