From 46b399476eae05f35cd085dbd5fa7007ed11ae10 Mon Sep 17 00:00:00 2001 From: Filip Gutica Date: Fri, 22 Mar 2024 14:45:25 -0700 Subject: [PATCH 1/2] fix: make chart tiles respond to new height if they are "fitToContent" --- .../src/components/DashboardTile.vue | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue b/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue index 963f97d1e1..7620e9365b 100644 --- a/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue +++ b/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue @@ -1,5 +1,8 @@ diff --git a/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue b/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue index 7620e9365b..5b52ffe136 100644 --- a/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue +++ b/packages/analytics/dashboard-renderer/src/components/DashboardTile.vue @@ -15,7 +15,7 @@ import { ChartTypes, type DashboardRendererContext, type TileDefinition } from ' import type { Component, } from 'vue' -import { computed, onMounted, onUnmounted, ref, toRef } from 'vue' +import { computed, onMounted, onUnmounted, ref } from 'vue' import '@kong-ui-public/analytics-chart/dist/style.css' import '@kong-ui-public/analytics-metric-provider/dist/style.css' import SimpleChartRenderer from './SimpleChartRenderer.vue' @@ -23,17 +23,19 @@ import BarChartRenderer from './BarChartRenderer.vue' import { DEFAULT_TILE_HEIGHT } from '../constants' import TimeseriesChartRenderer from './TimeseriesChartRenderer.vue' import GoldenSignalsRenderer from './GoldenSignalsRenderer.vue' -import { KUI_SPACE_70 } from '@kong/design-tokens' import TopNTableRenderer from './TopNTableRenderer.vue' +import { KUI_SPACE_70 } from '@kong/design-tokens' const PADDING_SIZE = parseInt(KUI_SPACE_70, 10) const props = withDefaults(defineProps<{ definition: TileDefinition, context: DashboardRendererContext, - height?: number + height?: number, + fitToContent?: boolean, }>(), { height: DEFAULT_TILE_HEIGHT, + fitToContent: false, }) const heightRef = ref(props.height) @@ -64,13 +66,13 @@ const componentData = computed(() => { context: props.context, queryReady: true, // TODO: Pipelining chartOptions: props.definition.chart, - height: heightRef.value, + height: heightRef.value - PADDING_SIZE * 2, }, } }) onMounted(() => { - if (tileBoundary.value) { + if (tileBoundary.value && props.fitToContent) { resizeObserver.observe(tileBoundary.value as HTMLDivElement) } })