Commit 3c768ddb authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '32780-when-zooming-metrics-at-some-point-we-can-t-adjust-the-zoom-any-further' into 'master'

Fixed monitor charts from throwing error when zoomed

Closes #32780

See merge request gitlab-org/gitlab!20331
parents 4667b907 eed3c858
...@@ -253,23 +253,25 @@ export default { ...@@ -253,23 +253,25 @@ export default {
this.tooltip.title = dateFormat(params.value, dateFormats.default); this.tooltip.title = dateFormat(params.value, dateFormats.default);
this.tooltip.content = []; this.tooltip.content = [];
params.seriesData.forEach(dataPoint => { params.seriesData.forEach(dataPoint => {
const [xVal, yVal] = dataPoint.value; if (dataPoint.value) {
this.tooltip.isDeployment = dataPoint.componentSubType === graphTypes.deploymentData; const [xVal, yVal] = dataPoint.value;
if (this.tooltip.isDeployment) { this.tooltip.isDeployment = dataPoint.componentSubType === graphTypes.deploymentData;
const [deploy] = this.recentDeployments.filter( if (this.tooltip.isDeployment) {
deployment => deployment.createdAt === xVal, const [deploy] = this.recentDeployments.filter(
); deployment => deployment.createdAt === xVal,
this.tooltip.sha = deploy.sha.substring(0, 8); );
this.tooltip.commitUrl = deploy.commitUrl; this.tooltip.sha = deploy.sha.substring(0, 8);
} else { this.tooltip.commitUrl = deploy.commitUrl;
const { seriesName, color, dataIndex } = dataPoint; } else {
const value = yVal.toFixed(3); const { seriesName, color, dataIndex } = dataPoint;
this.tooltip.content.push({ const value = yVal.toFixed(3);
name: seriesName, this.tooltip.content.push({
dataIndex, name: seriesName,
value, dataIndex,
color, value,
}); color,
});
}
} }
}); });
}, },
......
---
title: Fixed monitor charts from throwing error when zoomed
merge_request: 20331
author:
type: fixed
...@@ -116,6 +116,19 @@ describe('Time series component', () => { ...@@ -116,6 +116,19 @@ describe('Time series component', () => {
}); });
}); });
it('does not throw error if data point is outside the zoom range', () => {
const seriesDataWithoutValue = generateSeriesData('line');
expect(
timeSeriesChart.vm.formatTooltipText({
...seriesDataWithoutValue,
seriesData: seriesDataWithoutValue.seriesData.map(data => ({
...data,
value: undefined,
})),
}),
).toBeUndefined();
});
describe('when series is of line type', () => { describe('when series is of line type', () => {
beforeEach(done => { beforeEach(done => {
timeSeriesChart.vm.formatTooltipText(generateSeriesData('line')); timeSeriesChart.vm.formatTooltipText(generateSeriesData('line'));
......
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