11<script setup lang="ts">
22import { VueUiXy } from ' vue-data-ui/vue-ui-xy'
3- import {
4- type VueUiXyDatasetItem ,
5- type VueUiXyDatasetBarItem ,
6- type VueUiXyDatapointItem ,
7- type MinimalCustomFormatParams ,
8- } from ' vue-data-ui'
3+ import { type VueUiXyDatasetItem , type VueUiXyConfig } from ' vue-data-ui'
94import { useElementSize } from ' @vueuse/core'
105import { useCssVariables } from ' ~/composables/useColors'
116import { OKLCH_NEUTRAL_FALLBACK , transparentizeOklch , lightenHex } from ' ~/utils/colors'
@@ -15,10 +10,6 @@ import {
1510} from ' ~/composables/useChartWatermark'
1611import TooltipApp from ' ~/components/Tooltip/App.vue'
1712
18- type TooltipParams = MinimalCustomFormatParams <VueUiXyDatapointItem []> & {
19- bars: VueUiXyDatasetBarItem []
20- }
21-
2213const props = defineProps <{
2314 packageName: string
2415 inModal? : boolean
@@ -176,7 +167,7 @@ const hasMinimap = computed<boolean>(() => {
176167 return series .length > 6
177168})
178169
179- const chartConfig = computed (() => {
170+ const chartConfig = computed < VueUiXyConfig > (() => {
180171 return {
181172 theme: isDarkMode .value ? ' dark' : ' ' ,
182173 chart: {
@@ -209,10 +200,13 @@ const chartConfig = computed(() => {
209200 altCopy: undefined , // TODO: set to proper translation key
210201 },
211202 callbacks: {
212- img : ({ imageUri }: { imageUri: string }) => {
203+ img : args => {
204+ const imageUri = args ?.imageUri
205+ if (! imageUri ) return
213206 loadFile (imageUri , buildExportFilename (' png' ))
214207 },
215- csv : (csvStr : string ) => {
208+ csv : csvStr => {
209+ if (! csvStr ) return
216210 const PLACEHOLDER_CHAR = ' \0 '
217211 const multilineDateTemplate = $t (' package.trends.date_range_multiline' , {
218212 start: PLACEHOLDER_CHAR ,
@@ -229,7 +223,7 @@ const chartConfig = computed(() => {
229223 loadFile (url , buildExportFilename (' csv' ))
230224 URL .revokeObjectURL (url )
231225 },
232- svg : ({ blob }: { blob : Blob } ) => {
226+ svg : ({ blob }) => {
233227 const url = URL .createObjectURL (blob )
234228 loadFile (url , buildExportFilename (' svg' ))
235229 URL .revokeObjectURL (url )
@@ -277,8 +271,7 @@ const chartConfig = computed(() => {
277271 borderColor: ' transparent' ,
278272 backdropFilter: false ,
279273 backgroundColor: ' transparent' ,
280- customFormat : (params : TooltipParams ) => {
281- const { datapoint, absoluteIndex, bars } = params
274+ customFormat : ({ datapoint , absoluteIndex , bars }) => {
282275 if (! datapoint || pending .value ) return ' '
283276
284277 // Use absoluteIndex to get the correct version from chartDataset
@@ -329,9 +322,6 @@ const chartConfig = computed(() => {
329322 },
330323 },
331324 },
332- table: {
333- show: false ,
334- },
335325 }
336326})
337327 </script >
@@ -447,7 +437,7 @@ const chartConfig = computed(() => {
447437 role =" region"
448438 aria-labelledby =" version-distribution-title"
449439 class =" relative"
450- :class =" isMobile ? 'min-h-[260px]' : 'min-h-[400px ]'"
440+ :class =" isMobile ? 'min-h-[260px]' : 'min-h-[520px ]'"
451441 >
452442 <!-- Chart content -->
453443 <ClientOnly v-if =" xyDataset.length > 0 && !error" >
@@ -463,6 +453,16 @@ const chartConfig = computed(() => {
463453 v-if =" svg.isPrintingSvg || svg.isPrintingImg"
464454 v-html =" drawNpmxLogoAndTaglineWatermark(svg, watermarkColors, $t, 'bottom')"
465455 />
456+
457+ <!-- Overlay covering the chart area to hide line resizing when switching granularities recalculates VueUiXy scaleMax when estimation lines are necessary -->
458+ <rect
459+ v-if =" pending"
460+ :x =" svg.drawingArea.left"
461+ :y =" svg.drawingArea.top - 12"
462+ :width =" svg.drawingArea.width + 12"
463+ :height =" svg.drawingArea.height + 48"
464+ :fill =" colors.bg"
465+ />
466466 </template >
467467
468468 <!-- Custom bar gradient based on the series color -->
@@ -620,21 +620,6 @@ const chartConfig = computed(() => {
620620:deep(.vue-ui-xy ) svg rect {
621621 transition : none !important ;
622622}
623-
624- @keyframes fadeInUp {
625- from {
626- opacity : 0 ;
627- transform : translateY (8px );
628- }
629- to {
630- opacity : 1 ;
631- transform : translateY (0 );
632- }
633- }
634-
635- .chart-container {
636- animation : fadeInUp 350ms cubic-bezier (0.4 , 0 , 0.2 , 1 );
637- }
638623 </style >
639624
640625<style >
0 commit comments