Mango SVG gauge data follows a short path: a data point updates an Angular scope object, the page directive evaluates the binding, ma-selector locates an existing node in the imported SVG, and the browser renders the resulting attribute or style. When movement works but element creation fails, follow that path and identify whether the operation modifies an existing SVG node or attempts to insert a new one.
How does page data reach an imported SVG?
The SVG file supplies the document structure. For example, ng-include="'/modules/mangoUI/web/dev/img/Bar_Gauge_v2.svg'" loads the gauge, while ma-selector="#Arrow" targets the element whose SVG ID is Arrow. The selector element in the page acts as a configuration bridge; it is not itself the triangle.
The complete path is:
-
ma-get-point-valuereads a Mango data point into a scope object such asbreaker1. - An Angular expression reads
breaker1.valueor another scope property. -
ma-selectorfinds an existing SVG element such as#Arrowor#Breaker1. - The binding changes an SVG attribute, CSS style, class, or text value.
- The browser recomputes the affected geometry and paints the SVG.
Start with document structure before debugging bindings. Confirm that the included file loaded, the target ID exists exactly once, and the selector reaches that node. A valid data value cannot move an element that was never imported or whose ID does not match.
Which SVG manipulation approach fits the operation?
| Requirement | Approach | Where the element must exist | Decision factor |
|---|---|---|---|
| Move an existing triangle or bar | Apply an SVG transform
|
In the imported SVG | Preserves the element's original geometry and avoids recalculating every vertex |
| Change a polygon's shape | Change its points attribute |
In the imported SVG | Use only when the vertices themselves must change |
| Switch between fixed positions | Bind transform through ng-style
|
In the imported SVG | Useful for state-driven equipment symbols |
| Create repeated text or symbols | Put ng-repeat inside the SVG file |
The repeat template must be in the SVG | The SVG renderer creates one native SVG node per item |
| Add independent sensor graphics | Repeat smaller SVG instances on the page | Each instance comes from its own SVG template | Useful when new sensors do not need to become children of one site SVG |
Place raw <text> under ma-svg in page HTML |
Not a supported insertion path in this setup | The node is outside the imported SVG structure |
ma-svg selectors modify imported nodes; they do not treat arbitrary HTML children as new SVG primitives |
For a gauge indicator, use a transform. For a changing population of site objects, place a repeatable SVG template inside the SVG or render separate small SVGs from the page. Select between those two creation approaches based on whether the objects must share the site SVG's coordinate system.
Why is transform preferable for the gauge triangle?
A polygon stores its geometry in the points attribute. The triangle points="72,114 2,149 2,79" contains three coordinate pairs. Recomputing those six values for every process change mixes shape definition with position control and creates more binding work.
The attempted expression ng-style="{'points': '72,114 2,149 2,79'}" treats points as a CSS style. Polygon points are SVG geometry data rather than a CSS presentation property in this use, so that path does not reposition the triangle. A transform operates on the completed shape:
<div ma-selector="#Arrow" transform="translate(30)"></div>
Here, translate(30) moves the selected element 30 coordinate units on the x-axis and leaves its y displacement at zero. The more elaborate confirmed syntax also accepts chained transforms:
<div ma-selector="#Arrow"
transform="translate(30) rotate(45 50 50)"></div>
Transform order matters because each operation changes the coordinate system used by the next operation. A sliding gauge does not require rotation, so keep only the translation. Preserve the original polygon points as the triangle's local shape definition.
How should the indicator movement be configured?
- Give the triangle a stable ID in the source SVG, such as
Arrow. IDs used byma-selectormust remain unchanged when the graphic is edited or exported. - Load the source through
ma-svgandng-include. - Add a selector for
#Arrow. First apply a fixed translation to prove the DOM path and coordinate direction. - Replace the fixed displacement with an Angular expression derived from the process value. Keep the engineering-unit-to-position calculation separate from the polygon's vertex list.
- Apply color independently with
fill. Position, shape, and appearance then remain separate controls. - Test the lower limit, midpoint, and upper limit. Confirm that the triangle remains aligned with the gauge scale and does not leave the intended travel range.
A binary symbol can switch between known positions with the demonstrated conditional pattern:
<div ma-selector="#Breaker1"
ng-style="{transform: 'translateX(' +
(breaker1.value ? 0 : 30) + 'px)'}">
</div>
<div ma-selector="#Breaker3"
ng-style="{transform: 'translateY(' +
(breaker3.value ? 0 : -30) + 'px)'}">
</div>
The first binding selects either 0 or 30 pixels on the x-axis. The second selects either 0 or -30 pixels on the y-axis. For an analog gauge, substitute a calculated displacement for the conditional result, using the SVG scale's measured start and end positions.
How can components be created dynamically?
ma-selector requires a target already present in the imported SVG. Placing <text> directly between the opening and closing ma-svg tags does not add that text node to the included SVG document in this arrangement. Define the SVG primitive in the SVG file, then let Angular repeat or update it.
A confirmed pattern places ng-repeat on a native SVG element:
<svg viewBox="0 0 240 80"
xmlns="http://www.w3.org/2000/svg">
<text x="{{$index*95}}" y="25"
class="Rrrrr"
ng-repeat="item in seedText">{{item}}</text>
</svg>
With seedText=['foo','bar'], $index*95 places the first item at x=0 and the second at x=95. For site sensors, the repeated object should carry the information needed to render each instance: display value, position, state, and any selector-independent styling. When position reflects a physical site layout rather than a regular row, store coordinates with each sensor instead of deriving them from $index.
This approach changes maintenance ownership. A graphics editor may rewrite or remove Angular attributes during export. Preserve a controlled SVG template or establish an export step that retains ng-repeat and bindings. If the website designer must keep the site SVG free of application code, repeat independent small SVG components on top of the site graphic from the page. That approach keeps application markup outside the designer's file but requires page-level positioning and alignment.
How should values, colors, and classes be bound?
Use one binding mechanism per concern. Read the data point into scope, bind geometry through a transform, and bind visual state through fill or ng-class. The demonstrated data-point path is:
<ma-get-point-value
point-xid="DP_TestData_Breaker1"
point="breaker1">
</ma-get-point-value>
The scope object then drives the selected SVG node. A class can change descendant strokes without rewriting each child:
<div ma-selector="#Breaker1Power"
ng-class="{'power-off':
!breaker1.value &&
(!breaker3.value || !breaker2.value)}">
</div>
<style>
.power-off > * { stroke: green; }
</style>
The expression applies power-off when breaker1.value is false and either breaker3.value or breaker2.value is also false. The child selector > * applies the stroke to immediate descendants of the selected group. For text, use ng-bind against an existing node such as #grump; SVG text color uses fill, not the HTML color property.
Why does a binding appear to run without changing the graphic?
| Symptom | Likely stop in the path | Check | Correction |
|---|---|---|---|
| No selected element changes | The SVG did not load or the ID does not match | Inspect the rendered SVG and locate the target ID | Correct ng-include or the ma-selector value |
| Fill changes but triangle position does not |
points was sent through ng-style
|
Inspect the target's computed style and SVG attributes | Apply transform to the selected polygon |
| Movement occurs on the wrong axis | The translation function or sign is wrong | Test a small fixed positive displacement | Use translateX, translateY, or a two-axis SVG translation as required |
| New page-level text never appears inside the SVG | The raw child was not inserted into the imported SVG | Inspect whether the node exists under the rendered svg element |
Put the primitive and ng-repeat in the SVG, or repeat separate SVG instances |
| Repeated items overlap | Every instance received the same coordinates | Inspect each rendered element's x and y values | Calculate position from $index or store coordinates with each item |
| A class is present but child lines retain their stroke | The CSS selector does not reach the drawn descendants | Inspect the selected group and its child hierarchy | Target the appropriate descendants, as in .power-off > *
|
Verify from the bottom of the path upward: SVG loaded, target node present, selector matched, scope value current, expression evaluated, attribute or class written, and geometry repainted.
FAQ
Why does changing polygon points with ng-style fail?
points is polygon geometry, not the CSS style used by the demonstrated binding. Keep points="72,114 2,149 2,79" for the triangle shape and move #Arrow with transform="translate(30)".
Why does a new text element inside ma-svg not appear?
Page-level children are not inserted as native elements of the included SVG in this setup. Put the <text> template and ng-repeat inside the SVG file, or render separate smaller SVGs from the page.
Why does my repeated SVG text overlap?
Every repeated element is using the same coordinates. Assign position from the item data or use an index expression such as x="{{$index*95}}".
How do I verify a Mango SVG movement binding?
Apply a fixed translation first, inspect the rendered target for the new transform, then toggle or vary the bound data value and confirm the element reaches each commanded position.