@nwebui/react-niagara-px
Version:
React Niagara Px View
28 lines • 1.24 kB
JavaScript
import React from "react";
import useWidgetChanged from "./useWidgetChanged";
import { color } from "./utils";
import { Widget } from "./Widget";
const BarGraph = function ({ nativeWidget, children }) {
useWidgetChanged(nativeWidget);
const orientation = nativeWidget.gets("orientation");
const bg = nativeWidget.gets("background");
const fill = nativeWidget.gets("fill");
const max = +nativeWidget.get("max");
const value = +nativeWidget.get("value");
const text = nativeWidget.gets("text");
const font = nativeWidget.gets("valueFont");
const style = {
position: "absolute",
bottom: 0,
width: orientation == "vertical" ? "100%" : (value * 100.0) / max + "%",
height: orientation == "vertical" ? (value * 100.0) / max + "%" : "100%",
background: color(fill),
transition: orientation == "vertical" ? "height 700ms" : "width 700ms",
font: font?.replace("pt", "px"),
};
return (React.createElement(Widget, { nativeWidget: nativeWidget, style: { background: color(bg) } },
React.createElement("div", { style: style }, text),
children));
};
export default BarGraph;
//# sourceMappingURL=BarGraph.js.map