Commit a6dff66b authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch '351907-time-series-chart-responsiveness' into 'master'

Refactored time series chart responsiveness

See merge request gitlab-org/gitlab!81454
parents 3c813b29 8894e27c
<script> <script>
import { GlLink, GlTooltip, GlResizeObserverDirective, GlIcon } from '@gitlab/ui'; import { GlLink, GlTooltip, GlIcon } from '@gitlab/ui';
import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import { isEmpty, omit, throttle } from 'lodash'; import { isEmpty, omit, throttle } from 'lodash';
import { makeDataSeries } from '~/helpers/monitor_helper'; import { makeDataSeries } from '~/helpers/monitor_helper';
...@@ -28,9 +28,6 @@ export default { ...@@ -28,9 +28,6 @@ export default {
GlLink, GlLink,
GlIcon, GlIcon,
}, },
directives: {
GlResizeObserverDirective,
},
inheritAttrs: false, inheritAttrs: false,
props: { props: {
graphData: { graphData: {
...@@ -366,21 +363,16 @@ export default { ...@@ -366,21 +363,16 @@ export default {
eChart.off('datazoom'); eChart.off('datazoom');
eChart.on('datazoom', this.throttledDatazoom); eChart.on('datazoom', this.throttledDatazoom);
}, },
onResize() {
if (!this.$refs.chart) return;
const { width } = this.$refs.chart.$el.getBoundingClientRect();
this.width = width;
},
}, },
}; };
</script> </script>
<template> <template>
<div v-gl-resize-observer-directive="onResize">
<component <component
:is="glChartComponent" :is="glChartComponent"
ref="chart" ref="chart"
v-bind="$attrs" v-bind="$attrs"
:responsive="true"
:group-id="groupId" :group-id="groupId"
:data="chartData" :data="chartData"
:option="chartOptions" :option="chartOptions"
...@@ -425,5 +417,4 @@ export default { ...@@ -425,5 +417,4 @@ export default {
</template> </template>
</template> </template>
</component> </component>
</div>
</template> </template>
...@@ -335,21 +335,6 @@ describe('Time series component', () => { ...@@ -335,21 +335,6 @@ describe('Time series component', () => {
expect(formattedTooltipData.content).toBe(annotationsMetadata.tooltipData.content); expect(formattedTooltipData.content).toBe(annotationsMetadata.tooltipData.content);
}); });
}); });
describe('onResize', () => {
const mockWidth = 233;
beforeEach(() => {
jest.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(() => ({
width: mockWidth,
}));
wrapper.vm.onResize();
});
it('sets area chart width', () => {
expect(wrapper.vm.width).toBe(mockWidth);
});
});
}); });
describe('computed', () => { describe('computed', () => {
......
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