@icij/murmur-next 4.1.0 → 4.1.2

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.
@@ -1,13 +1,5 @@
1
1
  <script lang="ts">
2
- import {
3
- ComponentPublicInstance,
4
- computed,
5
- defineComponent,
6
- PropType,
7
- ref,
8
- watchEffect,
9
- onMounted
10
- } from 'vue'
2
+ import { ComponentPublicInstance, computed, defineComponent, PropType, ref, watch } from 'vue'
11
3
  import { identity, iteratee, sortBy } from 'lodash'
12
4
  import * as d3 from 'd3'
13
5
  import { chartProps, getChartProps, useChart } from '@/composables/chart'
@@ -175,6 +167,7 @@ export default defineComponent({
175
167
  const isLoaded = ref(false)
176
168
  const {
177
169
  loadedData,
170
+ mounted,
178
171
  elementsMaxBBox,
179
172
  d3Formatter,
180
173
  baseHeightRatio,
@@ -339,7 +332,7 @@ export default defineComponent({
339
332
  }
340
333
 
341
334
  function update() {
342
- if (!el.value) {
335
+ if (!mounted.value) {
343
336
  return
344
337
  }
345
338
 
@@ -359,8 +352,9 @@ export default defineComponent({
359
352
  }
360
353
 
361
354
  function barTooltipStyle(bar: { x: number; y: number; width: number }) {
362
- const top = `${bar.y + margin.value.top}px`
363
- const left = `${bar.x + bar.width / 2 + margin.value.left}px`
355
+ const { x, y } = el?.value?.getBoundingClientRect() ?? new DOMRect()
356
+ const top = `${y + bar.y + margin.value.top}px`
357
+ const left = `${x + bar.x + bar.width / 2 + margin.value.left}px`
364
358
  return { top, left }
365
359
  }
366
360
 
@@ -369,10 +363,9 @@ export default defineComponent({
369
363
  datum.highlight || props.highlights.includes(datum[props.timeseriesKey])
370
364
  )
371
365
  }
372
-
373
- watchEffect(async () => {
374
- update()
375
- })
366
+
367
+ watch([width, height, loadedData, mounted], update.bind(this), { immediate: true})
368
+ watch(() => props.socialMode, update.bind(this), { immediate: true})
376
369
 
377
370
  return {
378
371
  el,
@@ -449,27 +442,29 @@ export default defineComponent({
449
442
  </g>
450
443
  </g>
451
444
  </svg>
452
- <div v-if="!noTooltips" class="column-chart__tooltips">
453
- <div v-for="(bar, index) in bars" :key="index">
454
- <div :style="barTooltipStyle(bar)" class="column-chart__tooltips__item">
455
- <transition name="fade">
456
- <div
457
- v-if="shownTooltip === index"
458
- class="column-chart__tooltips__item__wrapper"
459
- >
460
- <slot name="tooltip" v-bind="bar">
461
- <h6 class="column-chart__tooltips__item__wrapper__heading mb-0">
462
- {{ formatXDatum(bar.datum[timeseriesKey]) }}
463
- </h6>
464
- <div class="column-chart__tooltips__item__wrapper__value">
465
- {{ formatYDatum(bar.datum[seriesName]) }}
466
- </div>
467
- </slot>
468
- </div>
469
- </transition>
445
+ <teleport to="body">
446
+ <div v-if="!noTooltips" class="column-chart__tooltips">
447
+ <div v-for="(bar, index) in bars" :key="index">
448
+ <div :style="barTooltipStyle(bar)" class="column-chart__tooltips__item">
449
+ <transition name="fade">
450
+ <div
451
+ v-if="shownTooltip === index"
452
+ class="column-chart__tooltips__item__wrapper"
453
+ >
454
+ <slot name="tooltip" v-bind="bar">
455
+ <h6 class="column-chart__tooltips__item__wrapper__heading mb-0">
456
+ {{ formatXDatum(bar.datum[timeseriesKey]) }}
457
+ </h6>
458
+ <div class="column-chart__tooltips__item__wrapper__value">
459
+ {{ formatYDatum(bar.datum[seriesName]) }}
460
+ </div>
461
+ </slot>
462
+ </div>
463
+ </transition>
464
+ </div>
470
465
  </div>
471
466
  </div>
472
- </div>
467
+ </teleport>
473
468
  </div>
474
469
  </template>
475
470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icij/murmur-next",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "private": false,
5
5
  "description": "Murmur is ICIJ's Design System for Bootstrap 5 and Vue.js",
6
6
  "author": "promera@icij.org",