Refine project status workflows and dashboards
This commit is contained in:
@@ -345,7 +345,7 @@
|
||||
function pickTickStep(maxValue) {
|
||||
const baseUnit = maxValue < 1000000 ? 1000 : 1000000;
|
||||
const units = [1, 2, 5];
|
||||
const raw = Math.max(maxValue / 5 / baseUnit, 1);
|
||||
const raw = Math.max(maxValue / baseUnit, 1);
|
||||
let power = 1;
|
||||
while (power * 10 <= raw) power *= 10;
|
||||
for (const unit of units) {
|
||||
@@ -355,6 +355,14 @@
|
||||
return power * 10 * baseUnit;
|
||||
}
|
||||
|
||||
function buildPositiveAxis(maxValue, tickCount = 4) {
|
||||
const safeMax = Math.max(Number(maxValue || 0), 1);
|
||||
const paddedMax = safeMax * (safeMax < 1000 ? 1.12 : 1.08);
|
||||
const tickStep = pickTickStep(paddedMax / tickCount);
|
||||
const tickMax = Math.max(tickStep, Math.ceil(paddedMax / tickStep) * tickStep);
|
||||
return { tickStep, tickMax };
|
||||
}
|
||||
|
||||
function setLegend(containerId, metricKeys) {
|
||||
const target = document.getElementById(containerId);
|
||||
if (!target) return;
|
||||
@@ -393,8 +401,7 @@
|
||||
1,
|
||||
...rows.flatMap((row) => metricKeys.map((key) => Number(row[key] || 0))),
|
||||
);
|
||||
const tickStep = pickTickStep(maxValue);
|
||||
const tickMax = Math.ceil(maxValue / tickStep) * tickStep;
|
||||
const { tickStep, tickMax } = buildPositiveAxis(maxValue, 4);
|
||||
const groupWidth = plotWidth / Math.max(rows.length, 1);
|
||||
const axisBaseY = height - margin.bottom;
|
||||
const groupGapRatio = granularity === "monthly" ? 0.28 : 0.18;
|
||||
@@ -464,8 +471,7 @@
|
||||
1,
|
||||
...rows.flatMap((row) => metricKeys.map((key) => Number(row[key] || 0))),
|
||||
);
|
||||
const tickStep = pickTickStep(maxValue);
|
||||
const tickMax = Math.ceil(maxValue / tickStep) * tickStep;
|
||||
const { tickStep, tickMax } = buildPositiveAxis(maxValue, 4);
|
||||
const xStep = rows.length > 1 ? plotWidth / (rows.length - 1) : 0;
|
||||
const axisBaseY = height - margin.bottom;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user