Skip to main content
The nxCoverageBar Velocity macro renders a traffic-light progress bar with automatic color coding (green ≥80%, yellow ≥50%, red <50%) to visualize coverage percentages across traceability analysis, FMEA completion, and compliance metrics. It combines a percentage display, colored bar, and optional clickable link to uncovered work items in the Tracker.

Overview

nxCoverageBar is a dashboard component used throughout TestAuto2 — Automotive Safety Solution to provide visual feedback on coverage metrics at a glance. It implements the traffic-light pattern familiar from automotive quality dashboards: green (acceptable), yellow (caution), red (action required). The macro is typically used in:
  • Traceability dashboards (Customer → System Reqs, System → Design Reqs, Requirements → Test Cases)
  • FMEA coverage reports (System elements with/without DFMEA documents)
  • Compliance scorecards (ISO 26262 Part coverage, AIAG-VDA FMEA completion)
  • Risk control tracking (Risk controls with post-mitigation assessment)

Macro Signature

#nxCoverageBar($covered $total $gapQuery)
ParameterTypeDescription
$coveredIntegerCount of covered items (items WITH the link/classification/assessment)
$totalIntegerTotal item count (denominator for percentage calculation)
$gapQueryStringOptional Lucene query that identifies uncovered items; if provided, makes the bar clickable to drill down to gaps in Work Items Tracker

Output

The macro produces:
<div class="nx-coverage-bar">
  <div class="nx-coverage-percentage">85%</div>
  <div class="nx-coverage-bar-container">
    <div class="nx-coverage-bar-fill" style="width: 85%; background-color: #4caf50;"></div>
  </div>
  <a href="[Tracker deep link with $gapQuery]" class="nx-coverage-gap-link">
    (3 gaps)
  </a>
</div>
Rendered as:
  • Percentage (e.g., “85%”) displayed as bold text left of bar
  • Progress bar with width proportional to coverage percentage
  • Color band (top border) indicating traffic-light status
  • Gap count link (right of bar) when $gapQuery is provided, showing “(N gaps)” as a hyperlink to Tracker filtered on uncovered items

Color Logic

The macro applies automatic color selection based on coverage percentage:
CoverageColorHexStatus
≥80%Green#4caf50Acceptable
50%–79%⚠️ Yellow#ff9800Caution
<50%❌ Red#f44336Action Required
Example decision matrix:
Coverage %  │ Color  │ Interpretation
─────────────────────────────────────
    95%     │ 🟢    │ Strong coverage
    70%     │ 🟡    │ Gaps exist, monitor progress
    30%     │ 🔴    │ Critical gaps, remediation needed

Common Usage Patterns

Pattern 1: Traceability Coverage (Customer → System Requirements)

#nxInit()
#set($customerReqs = $query.query('type:customerRequirement'))
#set($traceable = $query.query('type:customerRequirement AND backlinkedWorkItems:refines=TA*'))
#set($covered = $traceable.size())
#set($total = $customerReqs.size())
#set($gapQuery = 'type:customerRequirement AND NOT backlinkedWorkItems:refines=TA*')

## Display coverage for customer requirements refined to system requirements
#nxCoverageBar($covered $total $gapQuery)
Produces:
85% [████████████████████░░░░░] (3 gaps)
Clicking “(3 gaps)” opens the Tracker with the gap query applied, showing the 3 uncovered customer requirements.

Pattern 2: System Element FMEA Coverage

#nxInit()
#set($systemElements = $query.query('type:systemElement'))
#set($elementsWithFmea = $query.query('type:systemElement AND linkedWorkItems:analyzedBy'))
#set($covered = $elementsWithFmea.size())
#set($total = $systemElements.size())
#set($gapQuery = 'type:systemElement AND NOT linkedWorkItems:analyzedBy')

## Display coverage for system elements that have been analyzed in FMEA documents
#nxCoverageBar($covered $total $gapQuery)

Pattern 3: Risk Control Effectiveness (Pre/Post Mitigation)

#nxInit()
#set($failureModes = $query.query('type:failureMode'))
#set($mitigated = $query.query('type:failureMode AND postmitigationAP != null'))
#set($covered = $mitigated.size())
#set($total = $failureModes.size())
#set($gapQuery = 'type:failureMode AND postmitigationAP == null')

## Display coverage for failure modes with post-mitigation assessment
#nxCoverageBar($covered $total $gapQuery)

Pattern 4: Verification Coverage (Requirements → Test Cases)

#nxInit()
#set($sysReqs = $query.query('type:sysReq'))
#set($verified = $query.query('type:sysReq AND backlinkedWorkItems:verifies=TA*'))
#set($covered = $verified.size())
#set($total = $sysReqs.size())
#set($gapQuery = 'type:sysReq AND NOT backlinkedWorkItems:verifies=TA*')

## Display coverage for system requirements verified by test cases
#nxCoverageBar($covered $total $gapQuery)

Implementation Notes

Percentage Calculation

The macro computes coverage percentage as:
coverage% = round(($covered / $total) * 100)
If $total is 0, the macro returns “0%” (no division-by-zero error).

Color-Coded Border

The macro injects a colored top border into the progress bar container. This border uses CSS custom properties:
.nx-coverage-bar {
  border-top: 4px solid var(--nx-coverage-color);
  padding: 8px 0;
}
The --nx-coverage-color variable is set dynamically by JavaScript based on the calculated percentage.

Gap Query Deep-Linking

When $gapQuery is non-empty, the macro generates a Tracker URL with the query as a filter parameter:
https://polarion.demo.nextedy.com/polarion/#/project/TA/tracker?query=[URL-encoded gapQuery]
The link text displays the gap count: ($total - $covered) gaps (or “1 gap” if singular).

Responsive Sizing

The progress bar scales responsively:
.nx-coverage-bar-container {
  width: 100%;
  max-width: 400px;
  height: 24px;
  background-color: #f5f5f5;
  border-radius: 2px;
}

.nx-coverage-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}
Cards containing nxCoverageBar typically use a 2-column or 3-column grid layout; the bar width is constrained to prevent stretching.

Integration with Other Nextedy Macros

nxCoverageBar is often paired with other coverage-related macros:
MacroRelationshipUse Case
nxLinkCoverageCompanionnxLinkCoverage counts links and sets $nxLcCovered; pass result to nxCoverageBar for visualization
nxKpiCardSiblingBoth used in compliance scorecards; nxKpiCard shows raw count, nxCoverageBar shows percentage
nxDocInventoryTreeParent contextTree shows documents; each row may include an nxCoverageBar for that document’s traceability
nxFmeaElementBlockRow componentFMEA coverage report rows use nxCoverageBar to show Action Priority distribution
Example integration:
#nxInit()
## Get customer → system requirement coverage using nxLinkCoverage
#nxLinkCoverage('customerRequirement' 'sysReq' 'refines' 'back')
## Visualize the result
#nxCoverageBar($nxLcCovered $nxLcTotal $nxLcGapQuery)

Troubleshooting

Cause: The gap query may be using the wrong work item type or link role. Solution: Verify the $gapQuery string matches your data model. Test the query in the Tracker search box first to confirm it returns the expected results.
## Verify the query works
$query.query('type:sysReq AND NOT backlinkedWorkItems:verifies=TA*').size()

Problem: Gap count is always “(0 gaps)” even for incomplete coverage

Cause: The $gapQuery parameter is missing or malformed. Solution: Ensure the query uses correct syntax and project prefix:
#set($gapQuery = 'type:sysReq AND NOT backlinkedWorkItems:verifies=TA*')  ## Correct
#set($gapQuery = 'sysReq without verifies')  ## Wrong — not valid Lucene syntax
Cause: Project prefix in the gap query doesn’t match the actual project. Solution: Replace TA with your actual project prefix from the Polarion URL (e.g., GANTT, AUTO, etc.):
#set($gapQuery = 'type:sysReq AND NOT backlinkedWorkItems:verifies={{PROJECT_PREFIX}}*')

Problem: Bar color is always red even for high coverage

Cause: JavaScript color injection may be disabled or CSS is not loading. Solution: Verify that the nxCommonStyles() macro is called once per page before nxCoverageBar. Check browser console for CSS errors.
#nxCommonStyles()  ## Must be called once per page
#nxCoverageBar($covered $total $gapQuery)

Visual Appearance

nxCoverageBar uses the Siemens iX Design System for color, typography, and spacing. The bar integrates seamlessly with nxKpiCard, nxStatCard, and other Nextedy dashboard components.
diagram The bar typically appears within card components (nxKpiCard or section divs) on compliance dashboards, traceability reports, and space homepages. The optional gap link provides direct navigation to remediation work.