Commit f153f3a7 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'mw-responsive-contributors-charts' into 'master'

Contributors charts: Resize charts when screen size changes

Closes #20488

See merge request gitlab-org/gitlab!24794
parents 71525c4c a80b18c9
...@@ -7,11 +7,13 @@ import { __ } from '~/locale'; ...@@ -7,11 +7,13 @@ import { __ } from '~/locale';
import { getSvgIconPathContent } from '~/lib/utils/icon_utils'; import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
import { getDatesInRange } from '~/lib/utils/datetime_utility'; import { getDatesInRange } from '~/lib/utils/datetime_utility';
import { xAxisLabelFormatter, dateFormatter } from '../utils'; import { xAxisLabelFormatter, dateFormatter } from '../utils';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
export default { export default {
components: { components: {
GlAreaChart, GlAreaChart,
GlLoadingIcon, GlLoadingIcon,
ResizableChartContainer,
}, },
props: { props: {
endpoint: { endpoint: {
...@@ -201,25 +203,35 @@ export default { ...@@ -201,25 +203,35 @@ export default {
<div v-else-if="showChart" class="contributors-charts"> <div v-else-if="showChart" class="contributors-charts">
<h4>{{ __('Commits to') }} {{ branch }}</h4> <h4>{{ __('Commits to') }} {{ branch }}</h4>
<span>{{ __('Excluding merge commits. Limited to 6,000 commits.') }}</span> <span>{{ __('Excluding merge commits. Limited to 6,000 commits.') }}</span>
<div> <resizable-chart-container>
<gl-area-chart <gl-area-chart
slot-scope="{ width }"
:width="width"
:data="masterChartData" :data="masterChartData"
:option="masterChartOptions" :option="masterChartOptions"
:height="masterChartHeight" :height="masterChartHeight"
@created="onMasterChartCreated" @created="onMasterChartCreated"
/> />
</div> </resizable-chart-container>
<div class="row"> <div class="row">
<div v-for="contributor in individualChartsData" :key="contributor.name" class="col-6"> <div
v-for="(contributor, index) in individualChartsData"
:key="index"
class="col-lg-6 col-12"
>
<h4>{{ contributor.name }}</h4> <h4>{{ contributor.name }}</h4>
<p>{{ n__('%d commit', '%d commits', contributor.commits) }} ({{ contributor.email }})</p> <p>{{ n__('%d commit', '%d commits', contributor.commits) }} ({{ contributor.email }})</p>
<gl-area-chart <resizable-chart-container>
:data="contributor.dates" <gl-area-chart
:option="individualChartOptions" slot-scope="{ width }"
:height="individualChartHeight" :width="width"
@created="onIndividualChartCreated" :data="contributor.dates"
/> :option="individualChartOptions"
:height="individualChartHeight"
@created="onIndividualChartCreated"
/>
</resizable-chart-container>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -22,6 +22,7 @@ exports[`Contributors charts should render charts when loading completed and the ...@@ -22,6 +22,7 @@ exports[`Contributors charts should render charts when loading completed and the
legendmaxtext="Max" legendmaxtext="Max"
option="[object Object]" option="[object Object]"
thresholds="" thresholds=""
width="0"
/> />
</div> </div>
...@@ -29,7 +30,7 @@ exports[`Contributors charts should render charts when loading completed and the ...@@ -29,7 +30,7 @@ exports[`Contributors charts should render charts when loading completed and the
class="row" class="row"
> >
<div <div
class="col-6" class="col-lg-6 col-12"
> >
<h4> <h4>
John John
...@@ -39,15 +40,18 @@ exports[`Contributors charts should render charts when loading completed and the ...@@ -39,15 +40,18 @@ exports[`Contributors charts should render charts when loading completed and the
2 commits (jawnnypoo@gmail.com) 2 commits (jawnnypoo@gmail.com)
</p> </p>
<glareachart-stub <div>
data="[object Object]" <glareachart-stub
height="216" data="[object Object]"
includelegendavgmax="true" height="216"
legendaveragetext="Avg" includelegendavgmax="true"
legendmaxtext="Max" legendaveragetext="Avg"
option="[object Object]" legendmaxtext="Max"
thresholds="" option="[object Object]"
/> thresholds=""
width="0"
/>
</div>
</div> </div>
</div> </div>
</div> </div>
......
import Vue from 'vue'; import Vue from 'vue';
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { createStore } from '~/contributors/stores'; import { createStore } from '~/contributors/stores';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -22,7 +22,7 @@ function factory() { ...@@ -22,7 +22,7 @@ function factory() {
mock.onGet().reply(200, chartData); mock.onGet().reply(200, chartData);
store = createStore(); store = createStore();
wrapper = shallowMount(Component, { wrapper = mount(Component, {
propsData: { propsData: {
endpoint, endpoint,
branch, branch,
......
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