Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Fix infinite padding on multiple unload/load where maximum datapoint is zero #314

Merged
merged 4 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/carbon-graphs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Fixed
* Fixed infinite padding in line graphs on multiple unload/load where maximum datapoint is zero.
* Fixed tick lines overflowing outside the grid container when using custom tick values.

* Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/carbon-graphs/dev-site/serve/serve-static.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const express = require('express');
const rateLimit = require('express-rate-limit');
const fs = require('fs');

const displayServer = (localAddress) => {
console.log('[serve-static] Server started listening at');
Expand Down
2 changes: 1 addition & 1 deletion packages/carbon-graphs/src/js/helpers/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ const getAxesDataRange = (
const prevMax = config.axis[axis].dataRange.oldMax;
let isRangeModified;

if (prevMin === 0) {
if (prevMin === 0 || prevMax === 0) {
isRangeModified = !(prevMin <= curRange.min || prevMax >= curRange.max);
} else {
isRangeModified = !(prevMin && prevMax)
Expand Down
59 changes: 41 additions & 18 deletions packages/carbon-graphs/tests/unit/controls/Line/LinePanning-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,24 +430,47 @@ describe('Line - Panning', () => {
});
});
describe('when the same data is passed on multiple clicks of panning', () => {
it('Range modified should be false', () => {
const panData = {
key: 'uid_1',
values: [
{
x: '2016-03-03T12:00:00Z',
y: 0,
},
{
x: '2016-04-03T12:00:00Z',
y: 20,
},
],
};
graphDefault.reflow(panData);
graphDefault.reflow(panData);
graphDefault.reflow(panData);
expect(graphDefault.config.axis.y.dataRange.isRangeModified).toEqual(false);
describe('when Minimum Datapoint is 0', () => {
it('Range modified should be false', () => {
const panData = {
key: 'uid_1',
values: [
{
x: '2016-03-03T12:00:00Z',
y: 0,
},
{
x: '2016-04-03T12:00:00Z',
y: 20,
},
],
};
graphDefault.reflow(panData);
graphDefault.reflow(panData);
graphDefault.reflow(panData);
expect(graphDefault.config.axis.y.dataRange.isRangeModified).toEqual(false);
});
});
describe('when Maximum Datapoint is 0', () => {
it('Range modified should be false', () => {
const panData = {
key: 'uid_1',
values: [
{
x: '2016-03-03T12:00:00Z',
y: 0,
},
{
x: '2016-04-03T12:00:00Z',
y: -20,
},
],
};
graphDefault.reflow(panData);
graphDefault.reflow(panData);
graphDefault.reflow(panData);
expect(graphDefault.config.axis.y.dataRange.isRangeModified).toEqual(false);
});
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/carbon-graphs/webpack/dev-server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const WebpackDevServer = require('webpack-dev-server');
const path = require('path');
const WebpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');
const { jsOptions, cssOptions } = require('./helpers/rules');

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');
const { merge } = require('webpack-merge');
const {
TerraDevSite,
} = require('@cerner/terra-dev-site');
const path = require('path');

const WebpackConfigTerra = require('@cerner/webpack-config-terra');

Expand Down
Loading