Overview
The Boolean Chart component renders a realistic LED indicator that displays on/off states for equipment, pumps, valves, or any binary sensor. Features include glowing effects, custom labels, and automatic “no data” handling.Props
The current state of the indicator.
true: Shows “on” state with glow effectfalse: Shows “off” state (dimmed)'Sin datos': Shows gray “no data” state
Label displayed when
value is true.Label displayed when
value is false.LED color in the ON state. Accepts hex color codes.
LED base color in the OFF state (before radial gradient is applied).
Visual States
The component renders three distinct visual states:ON State (value = true)
- LED Color: Radial gradient from light center to dark edge using
colorOn - Glow Effect: Strong shadow blur (35px) in the ON color
- Text: Displays
textOnin dark green (#065f46) - Appearance: Bright, glowing LED with pronounced radial gradient
OFF State (value = false)
- LED Color: Radial gradient from gray (#9ca3af) to dark gray (#1f2937)
- Glow Effect: Minimal shadow blur (10px) in black
- Text: Displays
textOffin dark gray (#374151) - Appearance: Dim, inactive LED
No Data State (value = 'Sin datos')
- LED Color: Radial gradient from light gray (#e5e7eb) to medium gray (#6b7280)
- Glow Effect: Subtle shadow blur (8px)
- Text: Displays “Sin datos” in gray (#6b7280)
- Appearance: Neutral, inactive state indicating missing data
Visual Design Elements
The component creates a realistic LED indicator using multiple ECharts series layers:Main LED (Series 0)
Size: 110px circleStyle: Radial gradient with 3 color stops for depth effectShadow: Dynamic blur based on state (8-35px)
Outer Ring (Series 1)
Size: 130px circleStyle: Transparent fill with 6px dark border (#1f2937)Shadow: 15px blur for depth and dimension
Status Text (Series 2)
Position: 82% from top (below LED)Style: 20px bold font, center-alignedColor: Dynamic based on state
Configuration Schema
The component validates configuration using Zod schema:Color Validation:
colorOn and colorOff must be different hex colors (e.g., #00ff00). The schema enforces this with a custom refinement.Usage Examples
Basic Pump Status
Chlorine Injection System
Alarm Indicator
Valve Position Indicator
Multi-Indicator Dashboard
Color Recommendations
Use semantically appropriate colors for better user understanding:
| Use Case | Suggested Color | Hex Code |
|---|---|---|
| Normal operation | Green | #10b981 |
| Warning/attention | Amber | #f59e0b |
| Alarm/critical | Red | #ef4444 |
| Information | Blue | #3b82f6 |
| Success | Green (bright) | #22c55e |
| Standby | Gray | #6b7280 |
Accessibility Considerations
- Color Alone: Don’t rely solely on color to convey state - text labels are required
- Contrast: Ensure sufficient contrast between LED and background
- Text Labels: Use clear, descriptive labels (e.g., “Bomba Activa” vs just “ON”)
- Size: Minimum container size of 150×150px recommended for legibility
Performance
- Rendering: Static chart (no animations by default)
- Updates: Efficient re-renders when
valueprop changes - Memory: Minimal footprint - single ECharts instance per component
Responsive Behavior
The component automatically scales to fit its container:Related Components
- Gauge - For displaying numeric values with thresholds
- Liquid Fill - For percentage-based indicators
- Line Chart - For historical state trends
Source Reference
File:~/workspace/source/src/modules/Charts/components/BooleanChart.jsx:4
Schema: ~/workspace/source/src/modules/Charts/schemas/BooleanChartSchema.js
Built with Apache ECharts for the Centinela water treatment monitoring system.