@eturnity/eturnity_reusable_components 8.19.8-EPDM-14690.2 → 8.19.8-EPDM-13664.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 +1 -1
- package/src/components/barchart/BottomFields.vue +37 -121
- package/src/components/barchart/composables/useAxisCalculations.js +1 -1
- package/src/components/barchart/composables/useChartData.js +1 -1
- package/src/components/barchart/composables/useTooltip.js +3 -28
- package/src/components/barchart/index.vue +15 -53
- package/src/components/barchart/styles/bottomFields.js +4 -18
- package/src/components/barchart/styles/chart.js +0 -1
- package/src/components/errorMessage/index.vue +1 -1
- package/src/components/infoCard/index.vue +3 -15
- package/src/components/infoCard/infoCard.spec.js +3 -3
- package/src/components/infoText/defaultProps.js +16 -0
- package/src/components/infoText/index.vue +40 -37
- package/src/components/infoText/infoText.spec.js +39 -20
- package/src/components/infoText/infoText.stories.js +28 -0
- package/src/components/infoText/templates/iconTextContent.vue +105 -0
- package/src/components/inputs/inputNumber/index.vue +5 -87
- package/src/components/pageTitle/index.vue +1 -0
- package/src/DemoChart.vue +0 -424
- package/src/TestChart.vue +0 -229
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Container :is-chart-controls-shown-in-bottom="isChartControlsShownInBottom">
|
|
3
3
|
<LabelsColumn :width="yAxisWidth">
|
|
4
|
-
<LabelRow v-for="series in
|
|
4
|
+
<LabelRow v-for="series in props.series" :key="series.name">
|
|
5
5
|
{{ series.name }}
|
|
6
6
|
</LabelRow>
|
|
7
|
-
<TotalRow v-if="
|
|
8
|
-
{{ $gettext ?
|
|
7
|
+
<TotalRow v-if="props.series.length && fieldMode === 'percentage'">
|
|
8
|
+
{{ $gettext ? $gettext('Total (%)') : 'Total (%)' }}
|
|
9
9
|
</TotalRow>
|
|
10
|
-
<TotalRow v-if="
|
|
11
|
-
{{ $gettext ?
|
|
10
|
+
<TotalRow v-if="props.series.length">
|
|
11
|
+
{{ $gettext ? $gettext('Total (kWh)') : 'Total (kWh)' }}
|
|
12
12
|
</TotalRow>
|
|
13
13
|
</LabelsColumn>
|
|
14
14
|
|
|
@@ -18,35 +18,27 @@
|
|
|
18
18
|
>
|
|
19
19
|
<FieldsWrapper>
|
|
20
20
|
<!-- For stacked bar chart -->
|
|
21
|
-
<template v-if="
|
|
21
|
+
<template v-if="props.series.length">
|
|
22
22
|
<InputRow
|
|
23
|
-
v-for="series in
|
|
23
|
+
v-for="series in props.series"
|
|
24
24
|
:key="series.name"
|
|
25
25
|
:data-series-name="series.name"
|
|
26
26
|
>
|
|
27
27
|
<InputGroup
|
|
28
28
|
v-for="(item, index) in props.data"
|
|
29
|
-
:key="index"
|
|
30
29
|
:bar-width="barWidth"
|
|
31
30
|
:is-scrollable="isScrollable"
|
|
31
|
+
:key="index"
|
|
32
32
|
>
|
|
33
33
|
<InputNumber
|
|
34
34
|
:allow-negative="false"
|
|
35
|
-
:disabled="isInputsDisabled"
|
|
36
35
|
input-height="36px"
|
|
37
|
-
:
|
|
38
|
-
fieldMode === 'percentage'
|
|
39
|
-
? calculatePercentageTotal(item.label) !== 100
|
|
40
|
-
: false
|
|
41
|
-
"
|
|
36
|
+
:number-precision="0"
|
|
42
37
|
:min-decimals="0"
|
|
43
|
-
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
|
44
38
|
text-align="center"
|
|
45
39
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
|
46
40
|
:value="getDisplayValue(series.data, item.label)"
|
|
47
|
-
@input-blur="
|
|
48
|
-
handleInputBlur($event, series.name, item.label, series.data)
|
|
49
|
-
"
|
|
41
|
+
@input-blur="handleInputBlur($event, series.name, item.label)"
|
|
50
42
|
@input-focus="handleInputFocus(series.name, item.label)"
|
|
51
43
|
/>
|
|
52
44
|
</InputGroup>
|
|
@@ -55,17 +47,16 @@
|
|
|
55
47
|
<TotalInputRow v-if="fieldMode === 'percentage'">
|
|
56
48
|
<InputGroup
|
|
57
49
|
v-for="(item, index) in props.data"
|
|
58
|
-
:key="index"
|
|
59
50
|
:bar-width="barWidth"
|
|
60
51
|
:is-scrollable="isScrollable"
|
|
52
|
+
:key="index"
|
|
61
53
|
>
|
|
62
54
|
<InputNumber
|
|
63
55
|
:allow-negative="false"
|
|
64
|
-
:disabled="isInputsDisabled"
|
|
65
56
|
input-height="36px"
|
|
66
57
|
:is-read-only="true"
|
|
58
|
+
:number-precision="0"
|
|
67
59
|
:min-decimals="0"
|
|
68
|
-
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
|
69
60
|
text-align="center"
|
|
70
61
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
|
71
62
|
:value="calculatePercentageTotal(item.label)"
|
|
@@ -76,23 +67,17 @@
|
|
|
76
67
|
<TotalInputRow>
|
|
77
68
|
<InputGroup
|
|
78
69
|
v-for="(item, index) in props.data"
|
|
79
|
-
:key="index"
|
|
80
70
|
:bar-width="barWidth"
|
|
81
71
|
:is-scrollable="isScrollable"
|
|
72
|
+
:key="index"
|
|
82
73
|
>
|
|
83
74
|
<InputNumber
|
|
84
75
|
input-height="36px"
|
|
85
|
-
:is-border-error-only="true"
|
|
86
|
-
:is-info-border="
|
|
87
|
-
fieldMode === 'percentage'
|
|
88
|
-
? calculatePercentageTotal(item.label) !== 100
|
|
89
|
-
: false
|
|
90
|
-
"
|
|
91
76
|
:is-read-only="true"
|
|
77
|
+
:number-precision="2"
|
|
92
78
|
:min-decimals="0"
|
|
93
|
-
:number-precision="0"
|
|
94
79
|
text-align="center"
|
|
95
|
-
:value="
|
|
80
|
+
:value="calculateTotal(item.label)"
|
|
96
81
|
/>
|
|
97
82
|
</InputGroup>
|
|
98
83
|
</TotalInputRow>
|
|
@@ -103,19 +88,17 @@
|
|
|
103
88
|
<InputRow>
|
|
104
89
|
<InputGroup
|
|
105
90
|
v-for="(item, index) in props.data"
|
|
106
|
-
:key="index"
|
|
107
91
|
:bar-width="barWidth"
|
|
108
92
|
:is-scrollable="isScrollable"
|
|
93
|
+
:key="index"
|
|
109
94
|
>
|
|
110
95
|
<InputNumber
|
|
111
|
-
:allow-negative="false"
|
|
112
|
-
:disabled="isInputsDisabled"
|
|
113
96
|
input-height="36px"
|
|
114
97
|
:min-decimals="0"
|
|
115
|
-
:number-precision="
|
|
98
|
+
:number-precision="2"
|
|
116
99
|
text-align="center"
|
|
117
100
|
:value="item.value"
|
|
118
|
-
@input-blur="handleInputBlur($event, null, item.label
|
|
101
|
+
@input-blur="handleInputBlur($event, null, item.label)"
|
|
119
102
|
@input-focus="handleInputFocus(null, item.label)"
|
|
120
103
|
/>
|
|
121
104
|
</InputGroup>
|
|
@@ -124,26 +107,11 @@
|
|
|
124
107
|
</FieldsWrapper>
|
|
125
108
|
</FieldsContainer>
|
|
126
109
|
</Container>
|
|
127
|
-
<InfoCardContainer
|
|
128
|
-
v-if="hasAnySegmentNotTotatTo100Percent && fieldMode === 'percentage'"
|
|
129
|
-
:yAxisWidth="yAxisWidth"
|
|
130
|
-
>
|
|
131
|
-
<InfoCard align-items="center" type="info">
|
|
132
|
-
<InfoCardBody>
|
|
133
|
-
{{
|
|
134
|
-
$gettext
|
|
135
|
-
? $gettext('load_profile_not_add_up_to_100')
|
|
136
|
-
: 'load_profile_not_add_up_to_100'
|
|
137
|
-
}}
|
|
138
|
-
</InfoCardBody>
|
|
139
|
-
</InfoCard>
|
|
140
|
-
</InfoCardContainer>
|
|
141
110
|
</template>
|
|
142
111
|
|
|
143
112
|
<script setup>
|
|
144
|
-
import { ref
|
|
113
|
+
import { ref } from 'vue'
|
|
145
114
|
import InputNumber from '../inputs/inputNumber'
|
|
146
|
-
import InfoCard from '../infoCard'
|
|
147
115
|
|
|
148
116
|
import {
|
|
149
117
|
Container,
|
|
@@ -155,8 +123,6 @@
|
|
|
155
123
|
InputRow,
|
|
156
124
|
TotalInputRow,
|
|
157
125
|
InputGroup,
|
|
158
|
-
InfoCardContainer,
|
|
159
|
-
InfoCardBody,
|
|
160
126
|
} from './styles/bottomFields'
|
|
161
127
|
|
|
162
128
|
const props = defineProps({
|
|
@@ -193,47 +159,6 @@
|
|
|
193
159
|
default: 'absolute',
|
|
194
160
|
validator: (value) => ['absolute', 'percentage'].includes(value),
|
|
195
161
|
},
|
|
196
|
-
isInputsDisabled: {
|
|
197
|
-
type: Boolean,
|
|
198
|
-
default: false,
|
|
199
|
-
},
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
const seriesData = ref([])
|
|
203
|
-
|
|
204
|
-
watchEffect(() => {
|
|
205
|
-
let isNewSetOfSeries = false
|
|
206
|
-
const seriesDataCopy = [...seriesData.value]
|
|
207
|
-
if (
|
|
208
|
-
!seriesDataCopy.length ||
|
|
209
|
-
!props.series.length ||
|
|
210
|
-
seriesDataCopy.length !== props.series.length ||
|
|
211
|
-
!seriesDataCopy.some((item) => {
|
|
212
|
-
return props.series.map((s) => s.name).includes(item.name)
|
|
213
|
-
})
|
|
214
|
-
) {
|
|
215
|
-
isNewSetOfSeries = true
|
|
216
|
-
}
|
|
217
|
-
const currentSeriesData = !isNewSetOfSeries ? seriesDataCopy : []
|
|
218
|
-
const newSeriesData = []
|
|
219
|
-
|
|
220
|
-
props.series.forEach((item, itemIndex) => {
|
|
221
|
-
const data = item.data.map((d, dIndex) => ({
|
|
222
|
-
label: d.label,
|
|
223
|
-
value: d.value,
|
|
224
|
-
percentage: d.percentage,
|
|
225
|
-
originalValue: currentSeriesData.length
|
|
226
|
-
? currentSeriesData[itemIndex].data[dIndex].originalValue
|
|
227
|
-
: d.value,
|
|
228
|
-
}))
|
|
229
|
-
|
|
230
|
-
newSeriesData.push({
|
|
231
|
-
name: item.name,
|
|
232
|
-
data,
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
seriesData.value = [...newSeriesData]
|
|
237
162
|
})
|
|
238
163
|
|
|
239
164
|
const emit = defineEmits([
|
|
@@ -250,13 +175,11 @@
|
|
|
250
175
|
emit('input-focus', { seriesName, label })
|
|
251
176
|
}
|
|
252
177
|
|
|
253
|
-
const
|
|
254
|
-
|
|
178
|
+
const calculateTotal = (label) => {
|
|
179
|
+
return props.series.reduce((sum, series) => {
|
|
255
180
|
const value = series.data.find((d) => d.label === label)?.value || 0
|
|
256
181
|
return sum + value
|
|
257
182
|
}, 0)
|
|
258
|
-
|
|
259
|
-
return Math.round(total)
|
|
260
183
|
}
|
|
261
184
|
|
|
262
185
|
const syncScroll = (scrollLeft) => {
|
|
@@ -267,35 +190,34 @@
|
|
|
267
190
|
container.scrollLeft = scrollLeft
|
|
268
191
|
}
|
|
269
192
|
}
|
|
270
|
-
|
|
271
|
-
const getDisplayValue = (data, label, shouldRound = true) => {
|
|
193
|
+
const getDisplayValue = (seriesData, label) => {
|
|
272
194
|
if (props.fieldMode === 'absolute') {
|
|
273
|
-
return
|
|
195
|
+
return seriesData.find((d) => d.label === label)?.value || ''
|
|
274
196
|
}
|
|
275
197
|
|
|
276
|
-
|
|
198
|
+
const value = seriesData.find((d) => d.label === label)?.value || 0
|
|
199
|
+
const total = calculateTotal(label)
|
|
200
|
+
return total ? Number(((value / total) * 100).toFixed(0)) : 0
|
|
277
201
|
}
|
|
278
202
|
|
|
279
203
|
const calculatePercentageTotal = (label) => {
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
204
|
+
return props.series.reduce((sum, series) => {
|
|
205
|
+
const value = series.data.find((d) => d.label === label)?.value || 0
|
|
206
|
+
const total = calculateTotal(label)
|
|
207
|
+
const percentage = total ? Number(((value / total) * 100).toFixed(0)) : 0
|
|
283
208
|
return sum + percentage
|
|
284
209
|
}, 0)
|
|
285
|
-
|
|
286
|
-
return Math.round(percentageTotal)
|
|
287
210
|
}
|
|
288
211
|
|
|
289
|
-
const handleInputBlur = (_value, seriesName, label
|
|
212
|
+
const handleInputBlur = (_value, seriesName, label) => {
|
|
290
213
|
let value = Number(_value)
|
|
291
214
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
: { label, value }
|
|
215
|
+
if (props.fieldMode === 'percentage') {
|
|
216
|
+
const total = calculateTotal(label)
|
|
217
|
+
value = (value / 100) * total
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const payload = seriesName ? { seriesName, label, value } : { label, value }
|
|
299
221
|
emit('input-blur', payload)
|
|
300
222
|
focusedInput.value = null
|
|
301
223
|
|
|
@@ -321,12 +243,6 @@
|
|
|
321
243
|
}
|
|
322
244
|
}
|
|
323
245
|
|
|
324
|
-
const hasAnySegmentNotTotatTo100Percent = computed(() => {
|
|
325
|
-
return props.data.some((d) => {
|
|
326
|
-
return calculatePercentageTotal(d.label) !== 100
|
|
327
|
-
})
|
|
328
|
-
})
|
|
329
|
-
|
|
330
246
|
const handleFieldsScroll = (event) => {
|
|
331
247
|
emit('sync-scroll', event.target.scrollLeft)
|
|
332
248
|
}
|
|
@@ -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 ? '70px' : '60px'
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
const isChartControlsShown = (position) => {
|
|
@@ -66,7 +66,7 @@ export function useChartData(props, paddedMaxValue) {
|
|
|
66
66
|
let accumulated = 0
|
|
67
67
|
return {
|
|
68
68
|
label: item.label,
|
|
69
|
-
segments: [...props.series].map((series, index) => {
|
|
69
|
+
segments: [...props.series].reverse().map((series, index) => {
|
|
70
70
|
const value =
|
|
71
71
|
series.data.find((d) => d.label === item.label)?.value || 0
|
|
72
72
|
accumulated += value
|
|
@@ -16,21 +16,7 @@ export function useTooltip(chartId, normalizedData) {
|
|
|
16
16
|
if (!showTooltipContent.value) {
|
|
17
17
|
showTooltipContent.value = true
|
|
18
18
|
}
|
|
19
|
-
if (isObjectEqual(item, tooltipData.value))
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const totalValue = item.segments.reduce((acc, segment) => {
|
|
24
|
-
return acc + segment.value
|
|
25
|
-
}, 0)
|
|
26
|
-
|
|
27
|
-
const segments = item.segments.map((segment) => {
|
|
28
|
-
let valuePercentage = (segment.value / totalValue) * 100
|
|
29
|
-
segment.valuePercentage = Math.round(valuePercentage)
|
|
30
|
-
|
|
31
|
-
return segment
|
|
32
|
-
})
|
|
33
|
-
item.segments = segments
|
|
19
|
+
if (isObjectEqual(item, tooltipData.value)) return
|
|
34
20
|
|
|
35
21
|
tooltipData.value = { ...item }
|
|
36
22
|
|
|
@@ -55,27 +41,16 @@ export function useTooltip(chartId, normalizedData) {
|
|
|
55
41
|
|
|
56
42
|
isInputFocused.value = true
|
|
57
43
|
const barData = normalizedData.value.find((item) => item.label === label)
|
|
58
|
-
if (!barData) return
|
|
59
44
|
|
|
60
|
-
|
|
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
|
|
45
|
+
if (!barData) return
|
|
70
46
|
focusedBarData.value = barData
|
|
71
|
-
|
|
72
47
|
const barElement = document.querySelector(
|
|
73
48
|
`.barchart-${chartId} .bar-group:nth-child(${
|
|
74
49
|
normalizedData.value.indexOf(barData) + 1
|
|
75
50
|
})`
|
|
76
51
|
)
|
|
77
|
-
if (!barElement) return
|
|
78
52
|
|
|
53
|
+
if (!barElement) return
|
|
79
54
|
// Get the last bar segment, samee as hover behavior
|
|
80
55
|
const targetElement = barElement.querySelector('.bar-segment:last-child')
|
|
81
56
|
const rect = targetElement.getBoundingClientRect()
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
/>
|
|
18
18
|
</ChartControlsWrapper>
|
|
19
19
|
<GraphSection :height="height" :width="width">
|
|
20
|
-
<YAxis :
|
|
20
|
+
<YAxis :width="yAxisWidth" :height="height">
|
|
21
21
|
<YAxisTitleWrapper v-if="yAxisTitle" :height="yAxisHeight">
|
|
22
22
|
{{ yAxisTitle }}
|
|
23
23
|
</YAxisTitleWrapper>
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
)
|
|
31
31
|
"
|
|
32
32
|
>
|
|
33
|
-
<YAxisLabel>{{
|
|
33
|
+
<YAxisLabel>{{ label }}</YAxisLabel>
|
|
34
34
|
<YAxisLine :y-axis-width="yAxisWidth" />
|
|
35
35
|
</YAxisRow>
|
|
36
36
|
</YAxis>
|
|
37
37
|
|
|
38
38
|
<ScrollContainer
|
|
39
39
|
:class="`chart-scroll-container-${chartId}`"
|
|
40
|
-
:height="height"
|
|
41
40
|
:is-scrollable="isScrollable"
|
|
41
|
+
:height="height"
|
|
42
42
|
@scroll="handleChartScroll"
|
|
43
43
|
>
|
|
44
44
|
<ChartContent
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
<BarsContainer>
|
|
65
65
|
<BarGroup
|
|
66
66
|
v-for="(item, index) in normalizedData"
|
|
67
|
-
:key="index"
|
|
68
67
|
:bar-width="barWidth"
|
|
69
68
|
class="bar-group"
|
|
70
69
|
:is-scrollable="isScrollable"
|
|
70
|
+
:key="index"
|
|
71
71
|
>
|
|
72
72
|
<BarWrapper>
|
|
73
73
|
<BarSegment
|
|
74
74
|
v-for="(segment, segIndex) in item.segments"
|
|
75
|
-
:key="segIndex"
|
|
76
75
|
class="bar-segment"
|
|
77
76
|
:gradient-from="getSegmentGradient(index, segment).from"
|
|
78
77
|
:gradient-to="getSegmentGradient(index, segment).to"
|
|
79
78
|
:height="`${segment.percentage}%`"
|
|
79
|
+
:key="segIndex"
|
|
80
80
|
:z-index="item.segments.length - segIndex"
|
|
81
81
|
@mouseenter="showTooltip(item, $event, series)"
|
|
82
82
|
@mouseleave="hideTooltip"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
:left="tooltipStyle.left"
|
|
97
97
|
:top="tooltipStyle.top"
|
|
98
98
|
>
|
|
99
|
-
<slot :item="tooltipData" name="tooltip"
|
|
99
|
+
<slot :item="tooltipData" name="tooltip" />
|
|
100
100
|
<TooltipTextWrapper v-if="!slots.tooltip && tooltipData">
|
|
101
101
|
<template v-if="!series.length">
|
|
102
102
|
<TooltipText font-weight="500">{{ tooltipData.label }}</TooltipText>
|
|
@@ -128,11 +128,7 @@
|
|
|
128
128
|
:gradient-to="segment.gradientTo"
|
|
129
129
|
/>
|
|
130
130
|
<TooltipText>
|
|
131
|
-
{{
|
|
132
|
-
fieldMode === 'absolute' && showPercentageOnTooltip
|
|
133
|
-
? `${segment.valuePercentage}%`
|
|
134
|
-
: handleValueFormatter(segment.value)
|
|
135
|
-
}}
|
|
131
|
+
{{ handleValueFormatter(segment.value) }}
|
|
136
132
|
</TooltipText>
|
|
137
133
|
</TooltipRow>
|
|
138
134
|
</template>
|
|
@@ -163,7 +159,6 @@
|
|
|
163
159
|
:data="data"
|
|
164
160
|
:field-mode="fieldMode"
|
|
165
161
|
:is-chart-controls-shown-in-bottom="isChartControlsShown('bottom')"
|
|
166
|
-
:is-inputs-disabled="isLoading"
|
|
167
162
|
:is-scrollable="isScrollable"
|
|
168
163
|
:series="series"
|
|
169
164
|
:y-axis-width="yAxisWidth"
|
|
@@ -176,13 +171,12 @@
|
|
|
176
171
|
</template>
|
|
177
172
|
|
|
178
173
|
<script setup>
|
|
179
|
-
import { useSlots, computed
|
|
174
|
+
import { useSlots, computed } from 'vue'
|
|
180
175
|
|
|
181
176
|
import ChartControls from './ChartControls'
|
|
182
177
|
import BottomFields from './BottomFields'
|
|
183
178
|
import SelectionBox from './SelectionBox'
|
|
184
179
|
import Spinner from '../spinner'
|
|
185
|
-
import { numberToString } from '../../helpers/numberConverter'
|
|
186
180
|
|
|
187
181
|
import {
|
|
188
182
|
useTooltip,
|
|
@@ -252,6 +246,10 @@
|
|
|
252
246
|
type: String,
|
|
253
247
|
default: '',
|
|
254
248
|
},
|
|
249
|
+
valueFormatter: {
|
|
250
|
+
type: Function,
|
|
251
|
+
default: null,
|
|
252
|
+
},
|
|
255
253
|
isLegendShown: {
|
|
256
254
|
type: Boolean,
|
|
257
255
|
default: false,
|
|
@@ -298,10 +296,6 @@
|
|
|
298
296
|
type: Boolean,
|
|
299
297
|
default: false,
|
|
300
298
|
},
|
|
301
|
-
showPercentageOnTooltip: {
|
|
302
|
-
type: Boolean,
|
|
303
|
-
default: false,
|
|
304
|
-
},
|
|
305
299
|
})
|
|
306
300
|
|
|
307
301
|
const generateChartId = () =>
|
|
@@ -384,40 +378,8 @@
|
|
|
384
378
|
}
|
|
385
379
|
|
|
386
380
|
const handleValueFormatter = (value) => {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
value: formattedValue,
|
|
391
|
-
numberPrecision: 0,
|
|
392
|
-
minDecimals: 0,
|
|
393
|
-
})
|
|
394
|
-
} else if (value < 1000000) {
|
|
395
|
-
formattedValue = numberToString({
|
|
396
|
-
value: Number(formattedValue / 1000),
|
|
397
|
-
numberPrecision: 2,
|
|
398
|
-
minDecimals: 2,
|
|
399
|
-
})
|
|
400
|
-
} else {
|
|
401
|
-
formattedValue = numberToString({
|
|
402
|
-
value: Number(formattedValue / 1000000),
|
|
403
|
-
numberPrecision: 2,
|
|
404
|
-
minDecimals: 2,
|
|
405
|
-
})
|
|
406
|
-
}
|
|
407
|
-
if (value < 1000) {
|
|
408
|
-
return `${formattedValue} kWh`
|
|
409
|
-
} else if (value < 1000000) {
|
|
410
|
-
return `${formattedValue} MWh`
|
|
411
|
-
} else {
|
|
412
|
-
return `${formattedValue} GWh`
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const getYAxisLabel = (label) => {
|
|
417
|
-
return numberToString({
|
|
418
|
-
value: label,
|
|
419
|
-
numberPrecision: 0,
|
|
420
|
-
minDecimals: 0,
|
|
421
|
-
})
|
|
381
|
+
return props.valueFormatter
|
|
382
|
+
? props.valueFormatter(Math.round(value))
|
|
383
|
+
: value
|
|
422
384
|
}
|
|
423
385
|
</script>
|
|
@@ -17,18 +17,18 @@ export const LabelsColumn = styled('div', { width: String })`
|
|
|
17
17
|
|
|
18
18
|
export const LabelRow = styled.div`
|
|
19
19
|
height: 32px;
|
|
20
|
-
padding-top: 5px;
|
|
21
20
|
font-size: 12px;
|
|
22
21
|
font-weight: 500;
|
|
23
22
|
color: ${(props) => props.theme.semanticColors.teal[600]};
|
|
24
23
|
display: flex;
|
|
25
|
-
align-items:
|
|
24
|
+
align-items: flex-start;
|
|
26
25
|
`
|
|
27
26
|
|
|
28
27
|
export const TotalRow = styled(LabelRow)``
|
|
29
28
|
|
|
30
29
|
export const FieldsContainer = styled.div`
|
|
31
30
|
flex: 1;
|
|
31
|
+
overflow-x: auto;
|
|
32
32
|
scrollbar-width: none;
|
|
33
33
|
|
|
34
34
|
&::-webkit-scrollbar {
|
|
@@ -59,22 +59,8 @@ export const InputGroup = styled('div', {
|
|
|
59
59
|
barWidth: Number,
|
|
60
60
|
isScrollable: Boolean,
|
|
61
61
|
})`
|
|
62
|
-
${(props) => (props.isScrollable ? 'min-width' : 'width')}
|
|
62
|
+
${(props) => (props.isScrollable ? 'min-width' : 'width')}:${(props) =>
|
|
63
|
+
props.barWidth}px;
|
|
63
64
|
display: flex;
|
|
64
65
|
justify-content: center;
|
|
65
|
-
position: relative;
|
|
66
|
-
|
|
67
|
-
input[readonly] {
|
|
68
|
-
border: 1px solid ${(props) => props.theme.colors.grey4} !important;
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
|
|
72
|
-
export const InfoCardContainer = styled('div', { yAxisWidth: String })`
|
|
73
|
-
margin-left: ${(props) => props.yAxisWidth};
|
|
74
|
-
padding: 12px;
|
|
75
|
-
margin-top: 12px;
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
export const InfoCardBody = styled.div`
|
|
79
|
-
padding: 8px 0;
|
|
80
66
|
`
|
|
@@ -73,12 +73,7 @@
|
|
|
73
73
|
type: {
|
|
74
74
|
required: false,
|
|
75
75
|
type: String,
|
|
76
|
-
default: '
|
|
77
|
-
validator(value) {
|
|
78
|
-
return ['info_simple', 'warning', 'error_minor', 'info'].includes(
|
|
79
|
-
value
|
|
80
|
-
)
|
|
81
|
-
},
|
|
76
|
+
default: 'info',
|
|
82
77
|
},
|
|
83
78
|
minWidth: {
|
|
84
79
|
required: false,
|
|
@@ -117,11 +112,8 @@
|
|
|
117
112
|
},
|
|
118
113
|
},
|
|
119
114
|
computed: {
|
|
120
|
-
isInfoSimple() {
|
|
121
|
-
// this property is used for tests
|
|
122
|
-
return this.type === 'info_simple'
|
|
123
|
-
},
|
|
124
115
|
isInfo() {
|
|
116
|
+
// this property is used for tests
|
|
125
117
|
return this.type === 'info'
|
|
126
118
|
},
|
|
127
119
|
isWarning() {
|
|
@@ -156,13 +148,9 @@
|
|
|
156
148
|
stylesCollection.borderStyle = 'dashed'
|
|
157
149
|
stylesCollection.borderColor = theme.colors.grey4
|
|
158
150
|
stylesCollection.iconColor = theme.colors.red
|
|
159
|
-
} else
|
|
151
|
+
} else {
|
|
160
152
|
stylesCollection.borderStyle = 'dashed'
|
|
161
153
|
stylesCollection.borderColor = theme.colors.grey4
|
|
162
|
-
} else {
|
|
163
|
-
stylesCollection.color = theme.semanticColors.teal[800]
|
|
164
|
-
stylesCollection.backgroundColor = theme.semanticColors.blue[300]
|
|
165
|
-
stylesCollection.iconColor = theme.semanticColors.teal[800]
|
|
166
154
|
}
|
|
167
155
|
|
|
168
156
|
return stylesCollection
|
|
@@ -45,19 +45,19 @@ describe('RCInfoCard.vue', () => {
|
|
|
45
45
|
},
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
expect(wrapper.vm.
|
|
48
|
+
expect(wrapper.vm.isInfo).toBe(true)
|
|
49
49
|
expect(wrapper.vm.isWarning).toBe(false)
|
|
50
50
|
expect(wrapper.vm.isErrorMinor).toBe(false)
|
|
51
51
|
|
|
52
52
|
await wrapper.setProps({ type: 'warning' })
|
|
53
53
|
|
|
54
|
-
expect(wrapper.vm.
|
|
54
|
+
expect(wrapper.vm.isInfo).toBe(false)
|
|
55
55
|
expect(wrapper.vm.isWarning).toBe(true)
|
|
56
56
|
expect(wrapper.vm.isErrorMinor).toBe(false)
|
|
57
57
|
|
|
58
58
|
await wrapper.setProps({ type: 'error_minor' })
|
|
59
59
|
|
|
60
|
-
expect(wrapper.vm.
|
|
60
|
+
expect(wrapper.vm.isInfo).toBe(false)
|
|
61
61
|
expect(wrapper.vm.isWarning).toBe(false)
|
|
62
62
|
expect(wrapper.vm.isErrorMinor).toBe(true)
|
|
63
63
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
text: 'default text',
|
|
3
|
+
size: '14px',
|
|
4
|
+
infoPosition: 'bottom',
|
|
5
|
+
alignArrow: 'center',
|
|
6
|
+
openTrigger: 'onHover',
|
|
7
|
+
width: '165px',
|
|
8
|
+
maxWidth: '165px',
|
|
9
|
+
shouldUseTeleport: false,
|
|
10
|
+
dotColor: '#00009f',
|
|
11
|
+
type: 'info',
|
|
12
|
+
iconTextContent: {
|
|
13
|
+
iconName: 'error',
|
|
14
|
+
text: 'Sample Text',
|
|
15
|
+
},
|
|
16
|
+
}
|