|
9 | 9 | dataLabel as dl, |
10 | 10 | error, |
11 | 11 | getMissingDatasetAttributes, |
| 12 | + hasDeepProperty, |
12 | 13 | largestTriangleThreeBucketsArrayObjects, |
13 | 14 | objectIsEmpty, |
14 | 15 | setOpacity, |
@@ -79,16 +80,36 @@ function prepareConfig() { |
79 | 80 | userConfig: props.config, |
80 | 81 | defaultConfig: DEFAULT_CONFIG |
81 | 82 | }); |
| 83 | + let finalConfig = {}; |
| 84 | +
|
82 | 85 | if (mergedConfig.theme) { |
83 | | - return { |
| 86 | + finalConfig = { |
84 | 87 | ...useNestedProp({ |
85 | 88 | userConfig: themes.vue_ui_sparkline[mergedConfig.theme] || props.config, |
86 | 89 | defaultConfig: mergedConfig |
87 | 90 | }), |
88 | 91 | } |
89 | 92 | } else { |
90 | | - return mergedConfig; |
| 93 | + finalConfig = mergedConfig; |
| 94 | + } |
| 95 | +
|
| 96 | + // ------------------------------ OVERRIDES ----------------------------------- |
| 97 | +
|
| 98 | + if (props.config && hasDeepProperty(props.config, 'style.scaleMin')) { |
| 99 | + finalConfig.style.scaleMin = props.config.style.scaleMin; |
| 100 | + } else { |
| 101 | + finalConfig.style.scaleMin = null; |
| 102 | + } |
| 103 | +
|
| 104 | + if (props.config && hasDeepProperty(props.config, 'style.scaleMax')) { |
| 105 | + finalConfig.style.scaleMax = props.config.style.scaleMax; |
| 106 | + } else { |
| 107 | + finalConfig.style.scaleMax = null; |
91 | 108 | } |
| 109 | +
|
| 110 | + // ---------------------------------------------------------------------------- |
| 111 | +
|
| 112 | + return finalConfig; |
92 | 113 | } |
93 | 114 |
|
94 | 115 | const downsampled = computed(() => { |
@@ -226,13 +247,21 @@ const drawingArea = computed(() => { |
226 | 247 | }); |
227 | 248 |
|
228 | 249 | const min = computed(() => { |
229 | | - return Math.min(...safeDatasetCopy.value.map(s => isNaN(s.value) || [undefined, null, 'NaN', NaN, Infinity, -Infinity].includes(s.value) ? 0 : s.value || 0)) |
| 250 | + if (![null, undefined].includes(FINAL_CONFIG.value.style.scaleMin)) { |
| 251 | + return FINAL_CONFIG.value.style.scaleMin; |
| 252 | + } else { |
| 253 | + return Math.min(...safeDatasetCopy.value.map(s => isNaN(s.value) || [undefined, null, 'NaN', NaN, Infinity, -Infinity].includes(s.value) ? 0 : s.value || 0)) |
| 254 | + } |
230 | 255 | }); |
| 256 | +
|
231 | 257 | const max = computed(() => { |
232 | | - return Math.max(...safeDatasetCopy.value.map(s => isNaN(s.value) || [undefined, null, 'NaN', NaN, Infinity, -Infinity].includes(s.value) ? 0 : s.value || 0)) |
| 258 | + if (![null, undefined].includes(FINAL_CONFIG.value.style.scaleMax)) { |
| 259 | + return FINAL_CONFIG.value.style.scaleMax; |
| 260 | + } else { |
| 261 | + return Math.max(...safeDatasetCopy.value.map(s => isNaN(s.value) || [undefined, null, 'NaN', NaN, Infinity, -Infinity].includes(s.value) ? 0 : s.value || 0)) |
| 262 | + } |
233 | 263 | }); |
234 | 264 |
|
235 | | -
|
236 | 265 | const absoluteMin = computed(() => { |
237 | 266 | const num = min.value >= 0 ? 0 : min.value |
238 | 267 | return Math.abs(num); |
@@ -368,7 +397,7 @@ function selectDatapoint(datapoint, index) { |
368 | 397 | </div> |
369 | 398 |
|
370 | 399 | <!-- CHART --> |
371 | | - <svg :xmlns="XMLNS" v-if="isDataset" data-cy="sparkline-svg" :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`background:${FINAL_CONFIG.style.backgroundColor};overflow:visible`"> |
| 400 | + <svg :xmlns="XMLNS" v-if="isDataset" data-cy="sparkline-svg" :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`background:${FINAL_CONFIG.style.backgroundColor};overflow:hidden`"> |
372 | 401 | <PackageVersion /> |
373 | 402 |
|
374 | 403 | <!-- BACKGROUND SLOT --> |
|
0 commit comments