feat(client): upgrade Dashboard, Charts & Server Detail views for v1.1
This commit is contained in:
parent
3a28a2332f
commit
c003afa9df
4 changed files with 578 additions and 47 deletions
|
|
@ -97,3 +97,44 @@ export function createRangeChartSvg(
|
|||
svg.appendChild(poly);
|
||||
return svg;
|
||||
}
|
||||
|
||||
export function createDualRangeChartSvg(
|
||||
seriesA: number[],
|
||||
seriesB: number[],
|
||||
options: { colorA?: string; colorB?: string; maxVal?: number } = {},
|
||||
): SVGSVGElement {
|
||||
const computedMax =
|
||||
options.maxVal ??
|
||||
Math.max(
|
||||
1,
|
||||
...seriesA.map((v) => (Number.isFinite(v) ? v : 0)),
|
||||
...seriesB.map((v) => (Number.isFinite(v) ? v : 0)),
|
||||
);
|
||||
|
||||
const svg = document.createElementNS(SVG_NS, 'svg');
|
||||
svg.setAttribute('viewBox', '0 0 600 120');
|
||||
svg.setAttribute('preserveAspectRatio', 'none');
|
||||
svg.setAttribute('class', 'chart-svg');
|
||||
|
||||
const midLine = document.createElementNS(SVG_NS, 'line');
|
||||
midLine.setAttribute('x1', '0');
|
||||
midLine.setAttribute('y1', '60');
|
||||
midLine.setAttribute('x2', '600');
|
||||
midLine.setAttribute('y2', '60');
|
||||
midLine.setAttribute('stroke', 'var(--border)');
|
||||
midLine.setAttribute('stroke-dasharray', '4 4');
|
||||
svg.appendChild(midLine);
|
||||
|
||||
const addLine = (vals: number[], stroke: string) => {
|
||||
const poly = document.createElementNS(SVG_NS, 'polyline');
|
||||
poly.setAttribute('fill', 'none');
|
||||
poly.setAttribute('stroke', stroke);
|
||||
poly.setAttribute('stroke-width', '2');
|
||||
poly.setAttribute('points', buildPolylinePoints(vals, 600, 120, 0, computedMax));
|
||||
svg.appendChild(poly);
|
||||
};
|
||||
|
||||
addLine(seriesA, options.colorA ?? 'var(--accent)');
|
||||
addLine(seriesB, options.colorB ?? 'var(--warn)');
|
||||
return svg;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue