Dynamic Height and Width for Tank Levels and Progress Bars

  • Cirill Sokolov
  • 16th November 2026
  • Reading time: ~11 min
ArticleSVGHMI Converter: Height & Width Connection: article.image

Introduction

The height and width connections let you resize rectangles dynamically based on process data — think tank level indicators that fill up as the level rises, or progress bars that grow as a batch completes. These are among the most visually impactful connections in the SVGHMI Converter.

The converter generates hmi-bind:height / hmi-bind:width and hmi-bind:y / hmi-bind:x bindings with a normalization formula. The value is mapped between Min and Max parameters, so you can connect any process range (e.g., 0–1000 liters) to the rectangle's full dimensions.

Before you build your own bar, ask yourself whether you need to: the built-in WinCC Unified bar objects are solid. A custom SVGHMI bar pays off when the bar has to be part of a drawing — a tank, a silo, a bottle — or match your own visual style.

Height Control

SVGHMI height control example

Height control resizes a rectangle vertically. By default, the bar grows from bottom to top (like a tank filling up). With the Inverse direction option, it grows from top to bottom.

Width Control

SVGHMI width control example

Width control resizes a rectangle horizontally. By default, the bar grows from left to right. With Inverse direction, it grows from right to left.

Configuration Fields

Upload your SVG to the SVGHMI Converter and add a Height or Width connection. The form has five fields:

Inverse Direction

Controls the growth direction:

Height:

  • Unchecked (default) — bar grows from bottom to top. The Y position adjusts upward as height increases.
  • Checked — bar grows from top to bottom. The Y position stays fixed.

Width:

  • Unchecked (default) — bar grows from left to right. The X position stays fixed.
  • Checked — bar grows from right to left. The X position adjusts leftward as width increases.

Element's ID

Select a <rect> element from the dropdown. Only rectangles are available — this connection type requires width, height, x, and y attributes.

There is no Strict search option here: the converter binds every element whose ID starts with the selected ID. If you select tankFill, a second rectangle tankFill2 is bound to the same property too. Give each bar a unique ID that is not the beginning of another one (e.g. fillA, fillB).

WinCC Property

The property name that appears in WinCC Unified. The converter suggests Process. Rules:

  • Must not be empty
  • Letters and digits only — no spaces, underscores or special characters
  • Must start with a letter

Examples: TankLevel, Progress, BarValue

Default Value

Initial value for the property, 75 by default. This is a number in the range between Min and Max (which default to 0 and 100).

Text Field's ID

Optional. Select a <text> or <textPath> element to display the current value at runtime.

What Is NormalizedValue in SVGHMI?

If you have looked inside WinCC Unified dynamic widgets, you may have met LocalProps.NormalizedValue. It is not a built-in WinCC Unified property — it is a naming convention: a local variable, declared with hmi:localDef in the widget's <defs>, that holds the process value converted to the range 0.0 … 1.0:

<defs>
  <hmi:localDef name="NormalizedValue" type="number"
    hmi-bind:value="{{ Converter.Bounds((ParamProps.Value - ParamProps.MinRange) / (ParamProps.MaxRange - ParamProps.MinRange), 0.0, 1.0) }}" />
</defs>

Every dynamic part of the widget then reads LocalProps.NormalizedValue: a gauge needle uses rotate({{ -143 + LocalProps.NormalizedValue * 286.5 }}, 200, 200), a bar uses {{ 100 * LocalProps.NormalizedValue }}. A normalized value of 0 means "at Min", 1 means "at Max", 0.5 means "halfway".

The SVGHMI Converter uses exactly the same normalization for height and width, but it does not create a NormalizedValue local variable. It writes the expression directly into each binding:

Converter.Bounds((ParamProps.Level-ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0)

This is the normalized value of Level. The result is self-contained: no <hmi:localDef> to maintain, and the bindings work right after import into TIA Portal. If you later edit the file by hand and need the same value in many places, you can move the expression into an hmi:localDef and reference it as LocalProps.<name>.

Generated SVGHMI Code

Height Binding (Normal Direction)

For a <rect> with x="50", y="50", width="30", height="100" and property name Level:

<rect id="tankFill" width="30" x="50"
      hmi-bind:height="{{ 100 * Converter.Bounds((ParamProps.Level-ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0)}}"
      hmi-bind:y="{{ 50 + 100 - 100 * Converter.Bounds((ParamProps.Level - ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0) }}"
      .../>

The static height and y attributes are removed — the bindings replace them.

How the formula works:

  1. Normalize the value: (value - min) / (max - min) → produces a number between 0.0 and 1.0
  2. Clamp with Converter.Bounds(..., 0.0, 1.0) to prevent overflow
  3. Scale: originalHeight × normalizedValue → the actual height
  4. Adjust Y: originalY + originalHeight - scaledHeight → the rectangle "grows from bottom"

When Level = LevelMin, height = 0 and Y = original bottom edge. When Level = LevelMax, height = original full height and Y = original top edge. Values outside the range are clamped: the bar never grows beyond the rectangle you drew.

Height Binding (Inverse Direction)

With inverse: true, the Y position stays fixed — the bar grows downward:

<rect id="tankFill" width="30" x="50"
      hmi-bind:height="{{ 100 * Converter.Bounds((ParamProps.Level-ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0)}}"
      hmi-bind:y="{{ 50 }}"
      .../>

Width Binding (Normal Direction)

For a <rect> with x="10", width="200" and property name Progress:

<rect id="progressFill"
      hmi-bind:width="{{ 200 * Converter.Bounds((ParamProps.Progress-ParamProps.ProgressMin)/(ParamProps.ProgressMax-ParamProps.ProgressMin), 0.0, 1.0)}}"
      hmi-bind:x="{{ 10 }}"
      .../>

Width Binding (Inverse Direction)

With inverse: true, the bar grows from right to left:

<rect id="progressFill"
      hmi-bind:width="{{ 200 * Converter.Bounds((ParamProps.Progress-ParamProps.ProgressMin)/(ParamProps.ProgressMax-ParamProps.ProgressMin), 0.0, 1.0)}}"
      hmi-bind:x="{{ 10 + 200 - 200 * Converter.Bounds((ParamProps.Progress-ParamProps.ProgressMin)/(ParamProps.ProgressMax-ParamProps.ProgressMin), 0.0, 1.0) }}"
      .../>

Auto-Generated Parameters

Each height/width connection creates three hmi:paramDef entries:

<hmi:paramDef name="Level" type="number" default="75"/>
<hmi:paramDef name="LevelMin" type="number" default="0"/>
<hmi:paramDef name="LevelMax" type="number" default="100"/>

In WinCC Unified, you can remap Min and Max to match your process range. For example, set LevelMin = 0 and LevelMax = 1000 to map a 0–1000 liter range to the rectangle's full height — the normalized value stays 0…1, only the input range changes.

Bars With Complex Shapes: Rectangle + ClipPath

A rectangle is the natural base for a bar: its width and height are easy to drive. But what about a bar shaped like a bottle, a silo or a rounded tank? You don't need to animate the complex shape itself — clip the rectangle with it.

  1. Draw the container outline (the bottle) as usual.
  2. Create a <clipPath> with the interior shape of the container.
  3. Draw a <rect> that covers the whole interior, give it an ID (e.g. liquid) and apply clip-path="url(#bottle)" to it.
  4. In the converter, add a Height connection to liquid.

The rectangle grows and shrinks as usual, and the clip path cuts it to the bottle shape. The converter keeps the <clipPath> and the clip-path attribute untouched:

<defs>
  <clipPath id="bottle">
    <path d="M40 10H60V50C90 60 90 70 90 90V190H10V90C10 70 10 60 40 50Z"/>
  </clipPath>
</defs>
<rect id="liquid" width="100" x="0" fill="#39f" clip-path="url(#bottle)"
      hmi-bind:height="{{ 180 * Converter.Bounds((ParamProps.Level-ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0)}}"
      hmi-bind:y="{{ 10 + 180 - 180 * Converter.Bounds((ParamProps.Level - ParamProps.LevelMin)/(ParamProps.LevelMax-ParamProps.LevelMin), 0.0, 1.0) }}"/>

WinCC Unified supports a narrower subset of clipping than a web browser, so keep the clip path simple:

  • One shape per <clipPath>. In our tests WinCC used only the first shape of a multi-shape clip path, while browsers combine all of them. Merge the interior into a single <path> in your editor (Path → Union).
  • No transform on the clip shape. Older WinCC Unified versions ignore a transform inside <clipPath> and the bar is not clipped correctly (in V21 it worked in our tests). Bake the transform into the path coordinates before export.
  • Always check the moving bar in the runtime or simulation, not only in the browser preview.

Examples

Height: Bottom-to-Top Fill

Height: Top-to-Bottom Fill (Inverse)

Width: Left-to-Right Fill

Width: Right-to-Left Fill (Inverse)

Troubleshooting

Element not appearing in the dropdown:

  • Only <rect> elements are listed. Other shapes (circles, paths) cannot use height/width binding — use a rectangle clipped by the shape instead (see above).

Bar not moving as expected:

  • Check the Min and Max values in WinCC properties. Max must be greater than Min: with Min = Max the normalization divides by zero.
  • Verify the inverse setting matches your intended direction.

Another bar moves together with this one:

  • Its ID starts with the ID you selected (e.g. bar and bar2). Rename one of them so neither ID is the beginning of the other.

Connection Config Reference

FieldTypeDefaultDescription
typestring—"height" or "width"
propstringProcessProperty name (generates <prop>, <prop>Min, <prop>Max)
elemIdstring—Target <rect> element ID (prefix match)
valuenumber75Default value between Min and Max
inversebooleanfalseInvert growth direction
bindTextbooleanfalseDisplay value in a text element
textFieldstring—ID of a <text> element for value display

Additional Resources

FAQ

What is NormalizedValue in WinCC Unified SVGHMI?

It is not a built-in property but a naming convention: a local variable declared with hmi:localDef that holds the process value scaled to 0.0–1.0 between Min and Max. The SVGHMI converter writes the same expression straight into each height or width binding instead of declaring a local variable.

How does the converter scale the bar between Min and Max?

It computes (value − Min) / (Max − Min), clamps the result to 0.0–1.0 with Converter.Bounds() and multiplies it by the height or width of the rectangle you drew. Min and Max are generated as WinCC properties, so you can map any process range, for example 0–1000 liters, to the full bar.

Can the bar fill from top to bottom or from right to left?

Yes. Check Inverse direction: a height bar then grows from top to bottom and a width bar from right to left. The converter adjusts the y or x binding accordingly.

How do I make a bar in the shape of a bottle or tank?

Bind a rectangle and clip it with the container shape: put the interior outline into a clipPath and set clip-path on the rectangle. Use one shape per clipPath and no transform inside it, because WinCC Unified supports less clipping than a browser.

Related Posts :
WinCC: svg to svghmi widget converter article preview
WinCC: svg to svghmi widget converter

How to automatically convert a vector svg image into a dynamic widget?

4th August, 2023
WinCC Unified: hide svghmi elements article preview
WinCC Unified: hide svghmi elements

How to hide parts of your svghmi widget in three different ways.

12th September, 2024

Have a Question? Get in touch!

Start working with SVGHMI.pro that can provide you with effective tools to create SCADA HMIs and reduce maintenance costs.

Can I purchase as a business?

Yes! Our payment system supports business purchases with Wire Transfer, Purchase Order options, VAT ID registration, and proper invoicing for your accounting department. All transactions are securely processed by PayProGlobal, our trusted e-commerce partner.

Contact us