Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: show unintended flatten graph in better way #38574

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions pkg/ui/src/views/cluster/util/graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AxisDomain {
}
}

const countIncrementTable = [0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.9, 1.0];
const countIncrementTable = [0.01, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.9, 1.0];

// computeNormalizedIncrement computes a human-friendly increment between tick
// values on an axis with a range of the given size. The provided size is taken
Expand Down Expand Up @@ -134,7 +134,11 @@ function computeAxisDomain(extent: Extent, factor: number = 1): AxisDomain {
// but with a metric prefix for large numbers (i.e. 1000 will display as "1k")
let unitFormat: (v: number) => string;
if (Math.floor(increment) !== increment) {
unitFormat = d3.format(".1f");
if (increment < 0.1) {
unitFormat = d3.format(".2f");
} else {
unitFormat = d3.format(".1f");
}
} else {
unitFormat = d3.format("s");
}
Expand Down Expand Up @@ -257,7 +261,7 @@ function ComputeTimeAxisDomain(extent: Extent): AxisDomain {
function calculateYAxisDomain(axisUnits: AxisUnits, data: TSResponse): AxisDomain {
const resultDatapoints = _.flatMap(data.results, (result) => _.map(result.datapoints, (dp) => dp.value));
// TODO(couchand): Remove these random datapoints when NVD3 is gone.
const allDatapoints = resultDatapoints.concat([0, 1]);
const allDatapoints = resultDatapoints.concat((_.max(resultDatapoints) == 0 && _.min(resultDatapoints) == 0) ? [0, 1] : [0]);
const yExtent = d3.extent(allDatapoints);

switch (axisUnits) {
Expand Down