Commit 87b4e9a8 authored by Anshul Riyal's avatar Anshul Riyal

Refactored bar chart responsiveness

parent 6172b14a
<script> <script>
import { GlResizeObserverDirective } from '@gitlab/ui';
import { GlBarChart } from '@gitlab/ui/dist/charts'; import { GlBarChart } from '@gitlab/ui/dist/charts';
import { getSvgIconPathContent } from '~/lib/utils/icon_utils'; import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
import { chartHeight } from '../../constants'; import { chartHeight } from '../../constants';
...@@ -9,9 +8,6 @@ export default { ...@@ -9,9 +8,6 @@ export default {
components: { components: {
GlBarChart, GlBarChart,
}, },
directives: {
GlResizeObserverDirective,
},
props: { props: {
graphData: { graphData: {
type: Object, type: Object,
...@@ -60,11 +56,6 @@ export default { ...@@ -60,11 +56,6 @@ export default {
formatLegendLabel(query) { formatLegendLabel(query) {
return query.label; return query.label;
}, },
onResize() {
if (!this.$refs.barChart) return;
const { width } = this.$refs.barChart.$el.getBoundingClientRect();
this.width = width;
},
setSvg(name) { setSvg(name) {
getSvgIconPathContent(name) getSvgIconPathContent(name)
.then((path) => { .then((path) => {
...@@ -81,17 +72,16 @@ export default { ...@@ -81,17 +72,16 @@ export default {
}; };
</script> </script>
<template> <template>
<div v-gl-resize-observer-directive="onResize"> <gl-bar-chart
<gl-bar-chart ref="barChart"
ref="barChart" v-bind="$attrs"
v-bind="$attrs" :responsive="true"
:data="chartData" :data="chartData"
: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