Problem/Motivation
The Webform Statistics module reports submission counts correctly in numeric form (e.g. 7,000 or 2,000), but the D3.js chart renders truncated values instead (e.g. 7 or 2).
This is caused by the comma (,) being used as a thousands separator in the formatted number string.
When this string is passed to D3, it is parsed as a floating-point number, and the comma is interpreted as
a decimal separator (or causes early parsing termination), resulting in only the integer part before the
comma being rendered on the chart.

Steps to reproduce
- Install and enable the Webform Statistics module.
- Create a webform and collect more than 999 submissions (or seed the database with dummy submissions).
- Navigate to the webform statistics page that renders the D3 chart.
- Observe that the Y-axis or data values in the chart show
2or7instead of2,000or7,000. - Compare with the numeric summary displayed outside the chart, which shows the correct value.
Proposed resolution
Before passing submission count values to D3, ensure they are cast to a plain integer or float
without locale-specific formatting (i.e. strip thousands separators or avoid formatting the number
before it reaches the JavaScript layer). The server-side code or Twig template should pass raw
numeric values to the chart data, and formatting for display should be handled separately by D3
or a JavaScript number formatter after rendering.
Remaining tasks
- Identify the exact template or PHP function that formats the submission count before passing it to D3.
- Apply the fix and verify the chart renders correct values for counts above 999.
- Add a test case covering submission counts with values that would include a thousands separator.
User interface changes
The D3 chart will now display correct submission counts (e.g. 7,000 instead of 7).
No visual layout changes are expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | webform_fix.png | 75.04 KB | eduardo morales alberti |
| webform_statistics.png | 69.04 KB | eduardo morales alberti |
Issue fork webform_statistics-3581567
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
eduardo morales albertiThe problem comes from webform_statistics/src/Plugin/views/style/D3Chart.php, method getRenderedFieldValue, it returns the number already rendered.
The right approach is to call
$this->view->field[$field_id]->getValue($row)to bypass Drupal's number formatting, rather than reading from$this->rendered_fieldsComment #4
eduardo morales albertiReady to review, tested on our tests environments
Comment #6
juanjolLooks good to me, thank you Eduardo, Merging for next release