Commit 0eff2c2c authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch '351901-bar-chart-responsiveness' into 'master'

Refactored bar chart responsiveness

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