diff --git a/app/components/Package/TrendsChart.vue b/app/components/Package/TrendsChart.vue index 98548cf94..7b5a20c78 100644 --- a/app/components/Package/TrendsChart.vue +++ b/app/components/Package/TrendsChart.vue @@ -1345,12 +1345,54 @@ function drawSvgPrintLegend(svg: Record) { return seriesNames.join('\n') } +const showCorrectionControls = shallowRef(false) +const isResizing = shallowRef(false) + +const chartHeight = computed(() => { + if (isMobile.value) { + return 950 + } + return showCorrectionControls.value && props.inModal ? 494 : 600 +}) + +const timeoutId = shallowRef | null>(null) + +function pauseChartTransitions() { + if (timeoutId.value) { + clearTimeout(timeoutId.value) + } + + isResizing.value = true + + timeoutId.value = setTimeout(() => { + isResizing.value = false + timeoutId.value = null + }, 200) +} + +onBeforeUnmount(() => { + if (timeoutId.value) { + clearTimeout(timeoutId.value) + } +}) + +watch( + chartHeight, + (newH, oldH) => { + if (newH !== oldH) { + // Avoids triggering chart line transitions when the chart is resized + pauseChartTransitions() + } + }, + { immediate: true }, +) + // VueUiXy chart component configuration const chartConfig = computed(() => { return { theme: isDarkMode.value ? 'dark' : ('' as VueDataUiTheme), chart: { - height: isMobile.value ? 950 : 600, + height: chartHeight.value, backgroundColor: colors.value.bg, padding: { bottom: displayedGranularity.value === 'yearly' ? 84 : 64, right: 128 }, // padding right is set to leave space of last datapoint label(s) userOptions: { @@ -1554,7 +1596,6 @@ const chartConfig = computed(() => { }) const isDownloadsMetric = computed(() => selectedMetric.value === 'downloads') -const showCorrectionControls = shallowRef(false) const packageAnomalies = computed(() => getAnomaliesForPackages(effectivePackageNames.value)) const hasAnomalies = computed(() => packageAnomalies.value.length > 0) @@ -1666,116 +1707,139 @@ watch(selectedMetric, value => { /> {{ $t('package.trends.data_correction') }} -
- - - -
- - {{ $t('package.trends.known_anomalies') }} - -
@@ -1794,14 +1858,23 @@ watch(selectedMetric, value => {
{ top: calc(100% - 2rem) !important; } +.no-transition line, +.no-transition circle { + transition: none !important; +} + input::-webkit-date-and-time-value { margin-inline: 4px; }