valueLineComponent.tsx 941 B

12345678910111213141516171819202122232425262728293031
  1. import * as React from "react";
  2. interface IValueLineComponentProps {
  3. label: string;
  4. value: number;
  5. color?: string;
  6. fractionDigits?: number;
  7. units?: string;
  8. }
  9. export class ValueLineComponent extends React.Component<IValueLineComponentProps> {
  10. constructor(props: IValueLineComponentProps) {
  11. super(props);
  12. }
  13. render() {
  14. const digits = this.props.fractionDigits !== undefined ? this.props.fractionDigits : 2;
  15. const value = this.props.value.toFixed(digits) + (this.props.units ? " " + this.props.units : "");
  16. return (
  17. <div className="textLine">
  18. <div className="label">
  19. {this.props.label}
  20. </div>
  21. <div className="value" style={{ color: this.props.color ? this.props.color : "" }}>
  22. {value}
  23. </div>
  24. </div>
  25. );
  26. }
  27. }