Strip trailing decimal zeros from Metrics axis
This commit is contained in:
parent
9749a25f02
commit
fce7e7374f
3 changed files with 21 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
|
import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
|
||||||
import dateFormat from 'dateformat';
|
import dateFormat from 'dateformat';
|
||||||
import { debounceByAnimationFrame } from '~/lib/utils/common_utils';
|
import { debounceByAnimationFrame, roundOffFloat } from '~/lib/utils/common_utils';
|
||||||
import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
|
import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
|
||||||
import Icon from '~/vue_shared/components/icon.vue';
|
import Icon from '~/vue_shared/components/icon.vue';
|
||||||
import { chartHeight, graphTypes, lineTypes } from '../../constants';
|
import { chartHeight, graphTypes, lineTypes } from '../../constants';
|
||||||
|
@ -111,7 +111,7 @@ export default {
|
||||||
yAxis: {
|
yAxis: {
|
||||||
name: this.yAxisLabel,
|
name: this.yAxisLabel,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
formatter: value => value.toFixed(3),
|
formatter: num => roundOffFloat(num, 3).toString(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
series: this.scatterSeries,
|
series: this.scatterSeries,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Remove unnecessary decimals on Metrics chart axis
|
||||||
|
merge_request: 29468
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -214,6 +214,20 @@ describe('Area component', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('chartOptions', () => {
|
||||||
|
describe('yAxis formatter', () => {
|
||||||
|
let format;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
format = areaChart.vm.chartOptions.yAxis.axisLabel.formatter;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rounds to 3 decimal places', () => {
|
||||||
|
expect(format(0.88888)).toBe('0.889');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('scatterSeries', () => {
|
describe('scatterSeries', () => {
|
||||||
it('utilizes deployment data', () => {
|
it('utilizes deployment data', () => {
|
||||||
expect(areaChart.vm.scatterSeries.data).toEqual([
|
expect(areaChart.vm.scatterSeries.data).toEqual([
|
||||||
|
|
Loading…
Reference in a new issue