Commit bf894c6f authored by Rémy Coutable's avatar Rémy Coutable

Support pie charts in Insights

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 65e7821f
...@@ -131,6 +131,7 @@ Supported values are: ...@@ -131,6 +131,7 @@ Supported values are:
| ----- | ------- | | ----- | ------- |
| `bar` | ![Insights example bar chart](img/insights_example_bar_chart.png) | | `bar` | ![Insights example bar chart](img/insights_example_bar_chart.png) |
| `bar` (time series, i.e. when `group_by` is used) | ![Insights example bar time series chart](img/insights_example_bar_time_series_chart.png) | | `bar` (time series, i.e. when `group_by` is used) | ![Insights example bar time series chart](img/insights_example_bar_time_series_chart.png) |
| `pie` | ![Insights example pie chart](img/insights_example_pie_chart.png) |
| `line` | ![Insights example stacked bar chart](img/insights_example_line_chart.png) | | `line` | ![Insights example stacked bar chart](img/insights_example_line_chart.png) |
| `stacked-bar` | ![Insights example stacked bar chart](img/insights_example_stacked_bar_chart.png) | | `stacked-bar` | ![Insights example stacked bar chart](img/insights_example_stacked_bar_chart.png) |
......
...@@ -3,9 +3,6 @@ import BaseChart from './insights_chart.vue'; ...@@ -3,9 +3,6 @@ import BaseChart from './insights_chart.vue';
import * as chartOptions from '~/lib/utils/chart_utils'; import * as chartOptions from '~/lib/utils/chart_utils';
export default { export default {
components: {
BaseChart,
},
extends: BaseChart, extends: BaseChart,
computed: { computed: {
config() { config() {
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
import BaseChart from './insights_chart.vue'; import BaseChart from './insights_chart.vue';
export default { export default {
components: {
BaseChart,
},
extends: BaseChart, extends: BaseChart,
computed: { computed: {
config() { config() {
......
<script>
import BaseChart from './insights_chart.vue';
import * as chartOptions from '~/lib/utils/chart_utils';
export default {
extends: BaseChart,
computed: {
config() {
return {
type: 'pie',
data: this.data,
options: {
...chartOptions.pieChartOptions(),
...this.title(),
...this.commonOptions(),
},
};
},
},
};
</script>
<template>
<div class="chart-canvas-wrapper">
<canvas ref="insightsChart" class="pie" height="180"></canvas>
</div>
</template>
...@@ -3,9 +3,6 @@ import BaseChart from './insights_chart.vue'; ...@@ -3,9 +3,6 @@ import BaseChart from './insights_chart.vue';
import * as chartOptions from '~/lib/utils/chart_utils'; import * as chartOptions from '~/lib/utils/chart_utils';
export default { export default {
components: {
BaseChart,
},
extends: BaseChart, extends: BaseChart,
computed: { computed: {
config() { config() {
......
...@@ -7,18 +7,20 @@ import { GlLoadingIcon } from '@gitlab/ui'; ...@@ -7,18 +7,20 @@ import { GlLoadingIcon } from '@gitlab/ui';
import InsightsChartError from './insights_chart_error.vue'; import InsightsChartError from './insights_chart_error.vue';
import InsightsConfigWarning from './insights_config_warning.vue'; import InsightsConfigWarning from './insights_config_warning.vue';
import StackedBar from './chart_js/stacked_bar.vue';
import Bar from './chart_js/bar.vue'; import Bar from './chart_js/bar.vue';
import LineChart from './chart_js/line.vue'; import LineChart from './chart_js/line.vue';
import Pie from './chart_js/pie.vue';
import StackedBar from './chart_js/stacked_bar.vue';
export default { export default {
components: { components: {
GlLoadingIcon, GlLoadingIcon,
InsightsChartError, InsightsChartError,
InsightsConfigWarning, InsightsConfigWarning,
StackedBar,
Bar, Bar,
LineChart, LineChart,
Pie,
StackedBar,
}, },
props: { props: {
queryEndpoint: { queryEndpoint: {
......
...@@ -65,7 +65,7 @@ module InsightsActions ...@@ -65,7 +65,7 @@ module InsightsActions
case chart_type_param case chart_type_param
when 'stacked-bar', 'line' when 'stacked-bar', 'line'
Gitlab::Insights::Reducers::LabelCountPerPeriodReducer.reduce(issuables, period: period_param, period_limit: period_limit, labels: collection_labels_param) Gitlab::Insights::Reducers::LabelCountPerPeriodReducer.reduce(issuables, period: period_param, period_limit: period_limit, labels: collection_labels_param)
when 'bar' when 'bar', 'pie'
if period_param if period_param
Gitlab::Insights::Reducers::CountPerPeriodReducer.reduce(issuables, period: period_param, period_limit: period_limit) Gitlab::Insights::Reducers::CountPerPeriodReducer.reduce(issuables, period: period_param, period_limit: period_limit)
else else
...@@ -84,7 +84,7 @@ module InsightsActions ...@@ -84,7 +84,7 @@ module InsightsActions
case chart_type_param case chart_type_param
when 'stacked-bar' when 'stacked-bar'
Gitlab::Insights::Serializers::Chartjs::MultiSeriesSerializer Gitlab::Insights::Serializers::Chartjs::MultiSeriesSerializer
when 'bar' when 'bar', 'pie'
if period_param if period_param
Gitlab::Insights::Serializers::Chartjs::BarTimeSeriesSerializer Gitlab::Insights::Serializers::Chartjs::BarTimeSeriesSerializer
else else
......
---
title: Support pie charts in Insights
merge_request: 11186
author:
type: added
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