Overview
The Liquid Fill component renders an animated container with a waving liquid surface that rises to represent a percentage value. Supports multiple shapes (circle, rectangle, triangle, etc.) and can display single or multiple values simultaneously.Dependency: This component requires the
echarts-liquidfill plugin to be imported.Operating Modes
The component operates in two distinct modes:- Single Mode: Displays one value with customizable appearance
- Multiple Mode: Displays primary value with optional secondary value
Single Mode Props
The numeric value to display (not percentage). Combined with
maxValue to calculate fill percentage.Maximum value for percentage calculation. Percentage =
value / maxValue.Primary liquid color (middle of gradient). Accepts hex colors.
Container shape. Available options:
'circle'- Perfect circle (default)'rect'- Rectangle'roundRect'- Rounded rectangle'triangle'- Triangle'diamond'- Diamond shape'pin'- Map pin shape'arrow'- Arrow shape
Display format toggle:
true: Shows percentage value (e.g., “75.5 %”)false: Shows absolute value with unit (e.g., “45.50 m³”)
Enable or disable the decorative outer border with gradient.
Unit of measurement displayed after the value (only when
porcentage={false}).Optional second line of text below the main value.
Multiple Mode Props
When provided, switches to multiple-value mode. Overrides single-mode props.Object Structure:
value
Primary value. Can be
{ value: number } or just number.maxValue
Maximum for percentage calculation. Can be
{ value: number } or number.Secondary measurement configuration:
varsInflux: Object indicating presence of InfluxDB variables (any keys)value: Numeric value to displayunit: Unit string for this value
Shape Configurations
Each shape has optimized parameters for best appearance:| Shape | Radius | Amplitude | Wave Length | Font Size | Outline Distance |
|---|---|---|---|---|---|
| circle | 90% | 8 | 90% | 24px | 4 |
| rect | 85% | 6 | 90% | 24px | 4 |
| roundRect | 90% | 8 | 90% | 24px | 4 |
| triangle | 80% | 8 | 90% | 22px | 0 |
| diamond | 90% | 8 | 90% | 22px | 4 |
| arrow | 70% | 8 | 90% | 18px | 4 |
| pin | 100% | 8 | 90% | 24px | 4 |
Visual Effects
Liquid Gradient
The liquid uses a 3-stop vertical linear gradient:- Offset 0 (top):
#a5f3fc(light cyan) - Offset 0.5 (middle): Custom
colorprop - Offset 1 (bottom):
#0c4a6e(dark blue)
Wave Animation
Period
4000ms (4 seconds) - Full wave cycle durationSet to 0 when no valid data to freeze animation
Wave Length
90% of container width - Controls wave frequency
Amplitude
6-8px depending on shape - Wave height
Border Gradient
Whenborder={true}, an 8px border is applied with diagonal gradient:
- Start (top-left):
#93c5fd(light blue) - End (bottom-right):
#1e3a8a(dark blue)
Text Color (Dynamic)
Text color automatically adjusts based on fill level for readability:- Fill > 60%: White text (
#ffffff) - Fill > 40% (multiple mode): White text
- Fill ≤ 60%: Dark blue text (
#0f2a44)
Enter Animation
- Easing:
cubicOut- Smooth deceleration - Duration: 1800ms when data is valid, 0ms for no data
Usage Examples
Tank Level Indicator
Percentage Display
Rectangular Tank
Chemical Reservoir
Multiple Values Display
Dashboard Grid
No Data Handling
Data Validation
The component validates values using this logic:- 0% fill level
- “Sin datos” text display
- Gray color scheme
- No wave animation (frozen)
Shape Selection Guide
| Use Case | Recommended Shape | Reason |
|---|---|---|
| Generic percentage | circle | Clean, familiar design |
| Tank level | rect or roundRect | Matches physical tank shape |
| Funnel/Hopper | triangle | Visual representation |
| Highlight/Badge | diamond | Draws attention |
| Location marker | pin | Geographic context |
| Directional flow | arrow | Indicates direction |
Performance Considerations
Animation Performance: Wave animations use Canvas rendering. Limit to fewer than 10 simultaneous liquid fill components for optimal performance.
- Wave period: 4 seconds (smooth, not CPU-intensive)
- Frozen state when no data (0ms period)
- Responsive to container size changes
Accessibility
- Provide text alternative showing current value and percentage
- Use semantic HTML labels for tank/container names
- Ensure sufficient color contrast for text readability
- Consider adding ARIA attributes for screen reader support
Responsive Design
Color Palette Suggestions
| Liquid Type | Color | Hex Code |
|---|---|---|
| Water (clean) | Cyan | #06b6d4 |
| Water (treated) | Blue | #3b82f6 |
| Chemical (safe) | Green | #10b981 |
| Chemical (caution) | Amber | #f59e0b |
| Chemical (danger) | Red | #ef4444 |
| Fuel/Oil | Amber | #f59e0b |
| Generic | Sky Blue | #38bdf8 (default) |
Related Components
- Gauge - For speedometer-style percentage display
- Boolean Chart - For binary state indicators
- Line Chart - For historical level trends
Source Reference
File:~/workspace/source/src/modules/Charts/components/LiquidFillPorcentaje.jsx:65
Dependency: echarts-liquidfill plugin required
Built with Apache ECharts and echarts-liquidfill for the Centinela water treatment monitoring system.