Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | import React from "react";
import "./LineGraphCell.css";
import { SeverityLambdas } from "@/objects/interfaces/states/Severity";
import {
LineGraph,
scaleGraphPoints,
} from "@/objects/interfaces/graph/LineGraph";
import SVGCell from "../SVG/SVGCell";
import { scalePointOnAxis } from "@/objects/interfaces/graph/LineGraph";
import { Axes } from "./Axes/Axes";
import { SVGLines } from "../SVG/Lines/Lines";
import { Size } from "@/objects/interfaces/number/Size";
export interface LineGraphCellProps {
title: string;
graph: LineGraph;
pad?: number;
size?: Size;
sev?: SeverityLambdas;
}
const LineGraphCell: React.FC<LineGraphCellProps> = (props) => {
const gPad = props.pad ?? 40;
const svgSize = props.size ?? { width: 300, height: 300 };
const graphSize = {
width: svgSize.width - gPad * 2,
height: svgSize.height - gPad * 2,
};
const scaled_lines = scaleGraphPoints(props.graph, svgSize, {
x: gPad,
y: gPad,
});
// var severity = SEV_STATES.OK;
const center = {
x:
(props.graph.x_axis.range.min < 0
? scalePointOnAxis(0, props.graph.x_axis, graphSize.width)
: 0) + gPad,
y:
(props.graph.y_axis.range.max > 0
? scalePointOnAxis(0, props.graph.y_axis, graphSize.height)
: 0) + gPad,
};
return (
<div className={`cell absolute top-0 bottom-0 left-0 right-0 text-white`}>
<h2>{props.title}</h2>
<SVGCell size={svgSize}>
<Axes
x_axis={props.graph.x_axis}
y_axis={props.graph.y_axis}
pad={gPad}
size={graphSize}
center={center}
></Axes>
<SVGLines lines={scaled_lines} size={svgSize}></SVGLines>
</SVGCell>
</div>
);
};
export default LineGraphCell;
|