@icij/murmur-next 4.0.18 → 4.1.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/dist/lib/composables/chart.d.ts +3 -2
- package/dist/lib/composables/queryObserver.d.ts +6 -0
- package/dist/lib/datavisualisations/BarChart.vue.d.ts +3 -3
- package/dist/lib/datavisualisations/ColumnChart.vue.d.ts +4 -3
- package/dist/lib/datavisualisations/LineChart.vue.d.ts +1 -1
- package/dist/lib/datavisualisations/StackedBarChart.vue.d.ts +6 -8
- package/dist/lib/datavisualisations/StackedColumnChart.vue.d.ts +7 -6
- package/dist/lib/murmur.css +1 -1
- package/dist/lib/murmur.js +9779 -9756
- package/dist/lib/murmur.js.map +1 -1
- package/dist/lib/murmur.umd.cjs +38 -38
- package/dist/lib/murmur.umd.cjs.map +1 -1
- package/lib/components/TinyPagination.vue +5 -1
- package/lib/composables/chart.ts +57 -38
- package/lib/composables/queryObserver.ts +66 -0
- package/lib/datavisualisations/ColumnChart.vue +13 -18
- package/lib/datavisualisations/StackedBarChart.vue +63 -101
- package/lib/datavisualisations/StackedColumnChart.vue +56 -40
- package/package.json +1 -1
|
@@ -11,11 +11,13 @@ import {
|
|
|
11
11
|
ComponentPublicInstance,
|
|
12
12
|
computed,
|
|
13
13
|
defineComponent,
|
|
14
|
+
getCurrentInstance,
|
|
14
15
|
ref,
|
|
15
16
|
nextTick,
|
|
16
17
|
watch
|
|
17
18
|
} from 'vue'
|
|
18
19
|
import { chartProps, getChartProps, useChart } from '@/composables/chart.js'
|
|
20
|
+
import { useQueryObserver } from '@/composables/queryObserver.js'
|
|
19
21
|
|
|
20
22
|
export default defineComponent({
|
|
21
23
|
name: 'StackedColumnChart',
|
|
@@ -186,14 +188,17 @@ export default defineComponent({
|
|
|
186
188
|
const highlightTimeout = ref<NodeJS.Timeout | undefined>(undefined)
|
|
187
189
|
const isLoaded = ref(false)
|
|
188
190
|
const el = ref<ComponentPublicInstance<HTMLElement> | null>(null)
|
|
191
|
+
const { querySelector, querySelectorAll } = useQueryObserver(el)
|
|
189
192
|
|
|
190
193
|
const {
|
|
191
194
|
elementsMaxBBox,
|
|
192
|
-
baseHeightRatio,
|
|
195
|
+
baseHeightRatio,
|
|
193
196
|
loadedData,
|
|
197
|
+
mounted,
|
|
194
198
|
d3Formatter,
|
|
195
199
|
dataHasHighlights
|
|
196
200
|
} = useChart(el, getChartProps(props), { emit }, isLoaded, setSizes)
|
|
201
|
+
|
|
197
202
|
const sortedData = computed(() => {
|
|
198
203
|
if (!isLoaded.value) {
|
|
199
204
|
return []
|
|
@@ -223,8 +228,6 @@ export default defineComponent({
|
|
|
223
228
|
return !!highlightedKeys.value.length
|
|
224
229
|
})
|
|
225
230
|
|
|
226
|
-
// different
|
|
227
|
-
|
|
228
231
|
const hasColumnHighlights = computed(() => {
|
|
229
232
|
return !!props.columnHighlights.length
|
|
230
233
|
})
|
|
@@ -242,7 +245,7 @@ export default defineComponent({
|
|
|
242
245
|
.tickFormat((d) => d3Formatter(d, props.yAxisTickFormat))
|
|
243
246
|
.tickSize(width.value - leftAxisLabelsWidth.value)
|
|
244
247
|
.tickPadding(props.yAxisTickPadding)
|
|
245
|
-
}
|
|
248
|
+
}
|
|
246
249
|
)
|
|
247
250
|
const leftAxisLabelsWidth = computed(
|
|
248
251
|
() => {
|
|
@@ -252,7 +255,7 @@ export default defineComponent({
|
|
|
252
255
|
elementsMaxBBox({ selector, defaultWidth }).width +
|
|
253
256
|
props.yAxisTickPadding
|
|
254
257
|
)
|
|
255
|
-
}
|
|
258
|
+
}
|
|
256
259
|
)
|
|
257
260
|
|
|
258
261
|
const leftAxisCanvas = computed(() => {
|
|
@@ -260,6 +263,7 @@ export default defineComponent({
|
|
|
260
263
|
.select(el.value)
|
|
261
264
|
.select('.stacked-column-chart__left-axis__canvas')
|
|
262
265
|
})
|
|
266
|
+
|
|
263
267
|
const paddedStyle = computed(() => {
|
|
264
268
|
return {
|
|
265
269
|
marginLeft: props.noDirectLabeling
|
|
@@ -267,9 +271,11 @@ export default defineComponent({
|
|
|
267
271
|
: 0
|
|
268
272
|
}
|
|
269
273
|
})
|
|
274
|
+
|
|
270
275
|
const barTooltipDelay = computed(() => {
|
|
271
276
|
return hasHighlights.value ? 0 : props.highlightDelay
|
|
272
277
|
})
|
|
278
|
+
|
|
273
279
|
const maxRowValue = computed(() => {
|
|
274
280
|
return (
|
|
275
281
|
props.maxValue ||
|
|
@@ -289,6 +295,7 @@ export default defineComponent({
|
|
|
289
295
|
? props.fixedHeight
|
|
290
296
|
: width.value * baseHeightRatio.value
|
|
291
297
|
}
|
|
298
|
+
|
|
292
299
|
function groupName(key: string) {
|
|
293
300
|
const index = discoveredKeys.value.indexOf(key)
|
|
294
301
|
return props.groups[index] || key
|
|
@@ -353,12 +360,16 @@ export default defineComponent({
|
|
|
353
360
|
return props.tooltipDisplay({ value, formattedValue, key, formattedKey })
|
|
354
361
|
}
|
|
355
362
|
|
|
356
|
-
|
|
363
|
+
function barUniqueId(i: string | number, key: string) {
|
|
364
|
+
// @ts-ignore
|
|
365
|
+
const { uid } = getCurrentInstance()
|
|
366
|
+
return `bar-${uid}-${i}-${key}`
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function stackBarAndValue(i: string | number) {
|
|
357
370
|
if (!sortedData.value) {
|
|
358
371
|
return []
|
|
359
372
|
}
|
|
360
|
-
await nextTick()
|
|
361
|
-
|
|
362
373
|
// Collect sizes first
|
|
363
374
|
const stack = discoveredKeys.value.map((key: string) => {
|
|
364
375
|
const { bar, row, value } = queryBarAndValue(i as number, key)
|
|
@@ -396,15 +407,14 @@ export default defineComponent({
|
|
|
396
407
|
}
|
|
397
408
|
|
|
398
409
|
function queryBarAndValue(i: number, key: string) {
|
|
399
|
-
if (!
|
|
410
|
+
if (!mounted.value) {
|
|
400
411
|
return {}
|
|
401
412
|
}
|
|
402
413
|
const rowSelector = '.stacked-column-chart__groups__item'
|
|
403
|
-
const row =
|
|
414
|
+
const row = querySelectorAll(rowSelector)[i] as HTMLElement
|
|
404
415
|
const barSelector = `.stacked-column-chart__groups__item__bars__item--${key}`
|
|
405
416
|
const bar = row.querySelector(barSelector) as HTMLElement
|
|
406
|
-
const valueSelector =
|
|
407
|
-
'.stacked-column-chart__groups__item__bars__item__value'
|
|
417
|
+
const valueSelector = '.stacked-column-chart__groups__item__bars__item__value'
|
|
408
418
|
const value = bar.querySelector(valueSelector) as HTMLElement
|
|
409
419
|
return { bar, row, value }
|
|
410
420
|
}
|
|
@@ -414,13 +424,21 @@ export default defineComponent({
|
|
|
414
424
|
}
|
|
415
425
|
|
|
416
426
|
function hasValueOverflow(i: string | number, key: string) {
|
|
417
|
-
|
|
418
|
-
|
|
427
|
+
try {
|
|
428
|
+
const stack = stackBarAndValue(i)
|
|
429
|
+
return find(stack, { key })?.overflow
|
|
430
|
+
} catch {
|
|
431
|
+
return false
|
|
432
|
+
}
|
|
419
433
|
}
|
|
420
434
|
|
|
421
435
|
function hasValuePushed(i: string | number, key: string) {
|
|
422
|
-
|
|
423
|
-
|
|
436
|
+
try {
|
|
437
|
+
const stack = stackBarAndValue(i)
|
|
438
|
+
return find(stack, { key })?.pushed
|
|
439
|
+
} catch {
|
|
440
|
+
return false
|
|
441
|
+
}
|
|
424
442
|
}
|
|
425
443
|
|
|
426
444
|
function hasValueHidden(i: string | number, key: string) {
|
|
@@ -446,16 +464,16 @@ export default defineComponent({
|
|
|
446
464
|
watch(sortedData, async (newVal) => {
|
|
447
465
|
await nextTick()
|
|
448
466
|
// This must be set after the column have been rendered
|
|
449
|
-
const element =
|
|
450
|
-
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
467
|
+
const element = querySelector('.stacked-column-chart__groups__item__bars')
|
|
468
|
+
// Update the left axis only if the bars exists
|
|
469
|
+
if (element) {
|
|
470
|
+
leftAxisHeight.value = (element as HTMLElement).offsetHeight
|
|
471
|
+
//@ts-ignore
|
|
472
|
+
leftAxisCanvas.value.call(leftAxis.value)
|
|
473
|
+
}
|
|
455
474
|
})
|
|
456
475
|
|
|
457
476
|
return {
|
|
458
|
-
barTooltipDelay,
|
|
459
477
|
colorScale,
|
|
460
478
|
dataHasHighlights,
|
|
461
479
|
discoveredKeys,
|
|
@@ -467,7 +485,9 @@ export default defineComponent({
|
|
|
467
485
|
paddedStyle,
|
|
468
486
|
sortedData,
|
|
469
487
|
width,
|
|
488
|
+
barTooltipDelay,
|
|
470
489
|
barTitle,
|
|
490
|
+
barUniqueId,
|
|
471
491
|
barStyle,
|
|
472
492
|
delayHighlight,
|
|
473
493
|
formatXDatum,
|
|
@@ -540,28 +560,19 @@ export default defineComponent({
|
|
|
540
560
|
>
|
|
541
561
|
<div
|
|
542
562
|
v-for="(key, j) in discoveredKeys"
|
|
543
|
-
:key="j"
|
|
544
|
-
v-b-tooltip.html="{
|
|
545
|
-
delay: barTooltipDelay,
|
|
546
|
-
disabled: noTooltips,
|
|
547
|
-
title: barTitle(i, key)
|
|
548
|
-
}"
|
|
549
|
-
:style="barStyle(i, key)"
|
|
550
563
|
class="stacked-column-chart__groups__item__bars__item"
|
|
551
564
|
:class="{
|
|
552
565
|
[`stacked-column-chart__groups__item__bars__item--${key}`]: true,
|
|
553
566
|
[`stacked-column-chart__groups__item__bars__item--${j}n`]: true,
|
|
554
|
-
'stacked-column-chart__groups__item__bars__item--hidden':
|
|
555
|
-
|
|
556
|
-
'stacked-column-chart__groups__item__bars__item--
|
|
557
|
-
|
|
558
|
-
'stacked-column-chart__groups__item__bars__item--value-
|
|
559
|
-
hasValueOverflow(i, key),
|
|
560
|
-
'stacked-column-chart__groups__item__bars__item--value-pushed':
|
|
561
|
-
hasValuePushed(i, key),
|
|
562
|
-
'stacked-column-chart__groups__item__bars__item--value-hidden':
|
|
563
|
-
hasValueHidden(i, key)
|
|
567
|
+
'stacked-column-chart__groups__item__bars__item--hidden': isHidden(i, key),
|
|
568
|
+
'stacked-column-chart__groups__item__bars__item--highlighted': isHighlighted(key) || isColumnHighlighted(i),
|
|
569
|
+
'stacked-column-chart__groups__item__bars__item--value-overflow': hasValueOverflow(i, key),
|
|
570
|
+
'stacked-column-chart__groups__item__bars__item--value-pushed': hasValuePushed(i, key),
|
|
571
|
+
'stacked-column-chart__groups__item__bars__item--value-hidden': hasValueHidden(i, key)
|
|
564
572
|
}"
|
|
573
|
+
:style="barStyle(i, key)"
|
|
574
|
+
:key="j"
|
|
575
|
+
:id="barUniqueId(i, key)"
|
|
565
576
|
@mouseover="delayHighlight(key)"
|
|
566
577
|
@mouseleave="restoreHighlights()"
|
|
567
578
|
>
|
|
@@ -571,6 +582,11 @@ export default defineComponent({
|
|
|
571
582
|
>
|
|
572
583
|
{{ formatYDatum(datum[key]) }}
|
|
573
584
|
</div>
|
|
585
|
+
<teleport to="body">
|
|
586
|
+
<b-tooltip v-if="!noTooltips" :delay="barTooltipDelay" :target="barUniqueId(i, key)" placement="top">
|
|
587
|
+
<span v-html="barTitle(i, key)"></span>
|
|
588
|
+
</b-tooltip>
|
|
589
|
+
</teleport>
|
|
574
590
|
</div>
|
|
575
591
|
</div>
|
|
576
592
|
<div class="stacked-column-chart__groups__item__label small py-2">
|