Commit 693020b2 authored by Jose Vargas's avatar Jose Vargas

Update the heatmap chart component

This changes the use of the resizable_chart_container
component to use the GlResizeObserver directive instead
parent f601aa4d
<script> <script>
import { GlResizeObserverDirective } from '@gitlab/ui';
import { GlHeatmap } from '@gitlab/ui/dist/charts'; import { GlHeatmap } from '@gitlab/ui/dist/charts';
import dateformat from 'dateformat'; import dateformat from 'dateformat';
import PrometheusHeader from '../shared/prometheus_header.vue'; import PrometheusHeader from '../shared/prometheus_header.vue';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
import { graphDataValidatorForValues } from '../../utils'; import { graphDataValidatorForValues } from '../../utils';
export default { export default {
components: { components: {
GlHeatmap, GlHeatmap,
ResizableChartContainer,
PrometheusHeader, PrometheusHeader,
}, },
directives: {
GlResizeObserverDirective,
},
props: { props: {
graphData: { graphData: {
type: Object, type: Object,
required: true, required: true,
validator: graphDataValidatorForValues.bind(null, false), validator: graphDataValidatorForValues.bind(null, false),
}, },
containerWidth: { },
type: Number, data() {
required: true, return {
}, width: 0,
};
}, },
computed: { computed: {
chartData() { chartData() {
...@@ -52,22 +55,27 @@ export default { ...@@ -52,22 +55,27 @@ export default {
return this.graphData.metrics[0]; return this.graphData.metrics[0];
}, },
}, },
methods: {
onResize() {
if (this.$refs.heatmapChart) return;
const { width } = this.$refs.heatmapChart.$el.getBoundingClientRect();
this.width = width;
},
},
}; };
</script> </script>
<template> <template>
<div class="prometheus-graph col-12 col-lg-6"> <div v-gl-resize-observer-directive="onResize" class="prometheus-graph col-12 col-lg-6">
<prometheus-header :graph-title="graphData.title" /> <prometheus-header :graph-title="graphData.title" />
<resizable-chart-container> <gl-heatmap
<gl-heatmap ref="heatmapChart"
ref="heatmapChart" v-bind="$attrs"
v-bind="$attrs" :data-series="chartData"
:data-series="chartData" :x-axis-name="xAxisName"
:x-axis-name="xAxisName" :y-axis-name="yAxisName"
:y-axis-name="yAxisName" :x-axis-labels="xAxisLabels"
:x-axis-labels="xAxisLabels" :y-axis-labels="yAxisLabels"
:y-axis-labels="yAxisLabels" :width="width"
:width="containerWidth" />
/>
</resizable-chart-container>
</div> </div>
</template> </template>
...@@ -114,7 +114,6 @@ export default { ...@@ -114,7 +114,6 @@ export default {
<monitor-heatmap-chart <monitor-heatmap-chart
v-else-if="isPanelType('heatmap') && graphDataHasMetrics" v-else-if="isPanelType('heatmap') && graphDataHasMetrics"
:graph-data="graphData" :graph-data="graphData"
:container-width="dashboardWidth"
/> />
<component <component
:is="monitorChartComponent" :is="monitorChartComponent"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment