Commit 406885a2 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Wrap chart in ResizableChartContainer

parent d495c43d
<script> <script>
import { GlAreaChart } from '@gitlab/ui/dist/charts'; import { GlAreaChart } from '@gitlab/ui/dist/charts';
import { __ } from '~/locale'; import { s__ } from '~/locale';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
import { CHART_CONTAINER_HEIGHT } from '../constants'; import { CHART_CONTAINER_HEIGHT } from '../constants';
export default { export default {
components: { components: {
GlAreaChart, GlAreaChart,
ResizableChartContainer,
}, },
props: { props: {
chartData: { chartData: {
...@@ -15,11 +17,11 @@ export default { ...@@ -15,11 +17,11 @@ export default {
}, },
areaChartOptions: { areaChartOptions: {
xAxis: { xAxis: {
name: __('Date'), name: s__('Pipeline|Date'),
type: 'category', type: 'category',
}, },
yAxis: { yAxis: {
name: __('Pipelines'), name: s__('Pipeline|Pipelines'),
}, },
}, },
chartContainerHeight: CHART_CONTAINER_HEIGHT, chartContainerHeight: CHART_CONTAINER_HEIGHT,
...@@ -30,13 +32,15 @@ export default { ...@@ -30,13 +32,15 @@ export default {
<p> <p>
<slot></slot> <slot></slot>
</p> </p>
<div> <resizable-chart-container>
<gl-area-chart <gl-area-chart
slot-scope="{ width }"
:width="width"
:height="$options.chartContainerHeight" :height="$options.chartContainerHeight"
:data="chartData" :data="chartData"
:include-legend-avg-max="false" :include-legend-avg-max="false"
:option="$options.areaChartOptions" :option="$options.areaChartOptions"
/> />
</div> </resizable-chart-container>
</div> </div>
</template> </template>
...@@ -13741,6 +13741,9 @@ msgstr "" ...@@ -13741,6 +13741,9 @@ msgstr ""
msgid "Pipeline|Coverage" msgid "Pipeline|Coverage"
msgstr "" msgstr ""
msgid "Pipeline|Date"
msgstr ""
msgid "Pipeline|Detached merge request pipeline" msgid "Pipeline|Detached merge request pipeline"
msgstr "" msgstr ""
...@@ -13762,6 +13765,9 @@ msgstr "" ...@@ -13762,6 +13765,9 @@ msgstr ""
msgid "Pipeline|Pipeline" msgid "Pipeline|Pipeline"
msgstr "" msgstr ""
msgid "Pipeline|Pipelines"
msgstr ""
msgid "Pipeline|Run Pipeline" msgid "Pipeline|Run Pipeline"
msgstr "" msgstr ""
......
...@@ -9,13 +9,14 @@ exports[`PipelinesAreaChart matches the snapshot 1`] = ` ...@@ -9,13 +9,14 @@ exports[`PipelinesAreaChart matches the snapshot 1`] = `
</p> </p>
<div> <div>
<gl-area-chart-stub <glareachart-stub
data="[object Object],[object Object]" data="[object Object],[object Object]"
height="300" height="300"
legendaveragetext="Avg" legendaveragetext="Avg"
legendmaxtext="Max" legendmaxtext="Max"
option="[object Object]" option="[object Object]"
thresholds="" thresholds=""
width="0"
/> />
</div> </div>
</div> </div>
......
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Component from '~/projects/pipelines/charts/components/pipelines_area_chart.vue'; import Component from '~/projects/pipelines/charts/components/pipelines_area_chart.vue';
import { transformedAreaChartData } from '../mock_data'; import { transformedAreaChartData } from '../mock_data';
...@@ -6,13 +6,16 @@ describe('PipelinesAreaChart', () => { ...@@ -6,13 +6,16 @@ describe('PipelinesAreaChart', () => {
let wrapper; let wrapper;
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(Component, { wrapper = mount(Component, {
propsData: { propsData: {
chartData: transformedAreaChartData, chartData: transformedAreaChartData,
}, },
slots: { slots: {
default: 'Some title', default: 'Some title',
}, },
stubs: {
GlAreaChart: true,
},
}); });
}); });
......
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