{poll_share[:max]}

Description

Inside a poll answer template (Polls module), gives this answer share of all votes in its poll - round of votes-for-this-answer divided by total-votes, times max. The max parameter defaults to 100, so plain poll_share is a percentage (0-100); pass a max to scale the number, e.g. 200 to drive a results-bar width in pixels. Returns 0 when the poll has no votes. The answer alias _#ANS_PERC is just poll_share with the default max. It only produces a value in the answer section of a poll design, where the current item is one poll answer carrying its votes and poll_id; used anywhere else there is no answer to measure.

Parameters

max optional default 100

The number the full (100%) share maps to. With the default the result is a percentage (0-100); set it to scale the value - e.g. 200 to use poll_share directly as a bar width in pixels (width:200px at 100%).

Examples

virtual<div class="bar" style="width:{poll_share:200}px"></div>
Expected(a results bar whose width in px equals the answer share of 200; the real-world Polls usage)
Actual
The common pattern from real poll designs: feed poll_share into a CSS px width so each answer shows a horizontal bar sized to its share. With max 200 a 50% answer renders width:100px.
virtual{poll_share}
Expected(0 - a poll with no votes yet, or used outside a poll answer, has no share to compute)
Actual{poll_share}
When the poll total is zero (no votes cast, or poll_share is used where there is no current answer) the result is 0 rather than an error in real poll output. Note: this expression only resolves inside the Polls module render; on its own a template engine leaves the token untouched.
virtual{poll_share:500}
Expected(this answer share scaled to 0-500; e.g. 125 for 30 of 120 votes)
Actual{poll_share:500}
Pass a max to map the full share to a different number instead of 100. Here 30 of 120 votes gives round of 30/120 times 500 = 125.
virtual{poll_share} percent (also _#ANS_PERC)
Expected(e.g. 25 percent; _#ANS_PERC is defined as {poll_share})
Actual{poll_share} percent (also _#ANS_PERC)
The Polls answer alias _#ANS_PERC is just poll_share with the default max, so {poll_share} and _#ANS_PERC print the same percentage. Use whichever reads clearer in your template.
virtual{poll_share}
Expected(this answer percentage, 0-100; e.g. 25 for an answer with 30 of 120 votes)
Actual{poll_share}
The default max is 100, so plain poll_share is the percentage this answer holds of all votes in its poll. Use it inside the answer section of a poll design. Outside a poll answer there is nothing to measure.