Commit 234c264f authored by Anshul Riyal's avatar Anshul Riyal

Refactored column chart responsiveness

parent 6172b14a
<script> <script>
import { GlResizeObserverDirective } from '@gitlab/ui';
import { GlColumnChart } from '@gitlab/ui/dist/charts'; import { GlColumnChart } from '@gitlab/ui/dist/charts';
import { makeDataSeries } from '~/helpers/monitor_helper'; import { makeDataSeries } from '~/helpers/monitor_helper';
import { getSvgIconPathContent } from '~/lib/utils/icon_utils'; import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
...@@ -12,9 +11,6 @@ export default { ...@@ -12,9 +11,6 @@ export default {
components: { components: {
GlColumnChart, GlColumnChart,
}, },
directives: {
GlResizeObserverDirective,
},
props: { props: {
graphData: { graphData: {
type: Object, type: Object,
...@@ -83,11 +79,6 @@ export default { ...@@ -83,11 +79,6 @@ export default {
formatLegendLabel(query) { formatLegendLabel(query) {
return query.label; return query.label;
}, },
onResize() {
if (!this.$refs.columnChart) return;
const { width } = this.$refs.columnChart.$el.getBoundingClientRect();
this.width = width;
},
setSvg(name) { setSvg(name) {
getSvgIconPathContent(name) getSvgIconPathContent(name)
.then((path) => { .then((path) => {
...@@ -101,17 +92,16 @@ export default { ...@@ -101,17 +92,16 @@ export default {
}; };
</script> </script>
<template> <template>
<div v-gl-resize-observer-directive="onResize"> <gl-column-chart
<gl-column-chart ref="columnChart"
ref="columnChart" v-bind="$attrs"
v-bind="$attrs" :responsive="true"
:bars="barChartData" :bars="barChartData"
:option="chartOptions" :option="chartOptions"
:width="width" :width="width"
:height="height" :height="height"
:x-axis-title="xAxisTitle" :x-axis-title="xAxisTitle"
:y-axis-title="yAxisTitle" :y-axis-title="yAxisTitle"
:x-axis-type="xAxisType" :x-axis-type="xAxisType"
/> />
</div>
</template> </template>
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