Skip to content

Commit

Permalink
Merge pull request #4536 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…4524-to-release-4.4

[release-4.4] Bug 1804925: Monitoring Dashboards: Fix stack chart Y axis when all values are zero
  • Loading branch information
openshift-merge-robot committed Feb 28, 2020
2 parents 65ea6bc + b9ca3f4 commit fe50aa8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/public/components/monitoring/query-browser.tsx
Expand Up @@ -241,7 +241,15 @@ const Graph: React.FC<GraphProps> = React.memo(

let yTickFormat = formatValue;

if (!isStack) {
if (isStack) {
// Specify Y axis range if all values are zero, but otherwise let Chart set it automatically
const isAllZero = _.every(allSeries, (series) =>
_.every(series, ([, values]) => _.every(values, { y: 0 })),
);
if (isAllZero) {
domain.y = [-1, 1];
}
} else {
// Set a reasonable Y-axis range based on the min and max values in the data
const findMin = (series: GraphDataPoint[]) => _.minBy(series, 'y');
const findMax = (series: GraphDataPoint[]) => _.maxBy(series, 'y');
Expand Down

0 comments on commit fe50aa8

Please sign in to comment.