ankane/pghero · error · Error

noUiSlider: 'values' (>= 2) required for mode 'count'.

Error message

noUiSlider: 'values' (>= 2) required for mode 'count'.

What it means

When pips are requested with mode Count, noUiSlider's getGroup() divides the 0-100 range into pips.values - 1 intervals to compute pip positions. A count of 1 or 0 would mean zero or negative intervals, so values < 2 throws this Error while generating pips.

Source

Thrown at app/assets/javascripts/pghero/nouislider.js:1117

                    // Map to slider range values
                    min = scope_Spectrum.fromStepping(min).toFixed(1);
                    max = scope_Spectrum.fromStepping(max).toFixed(1);
                    now = scope_Spectrum.fromStepping(now).toFixed(1);
                    handle.children[0].setAttribute("aria-valuemin", min);
                    handle.children[0].setAttribute("aria-valuemax", max);
                    handle.children[0].setAttribute("aria-valuenow", now);
                    handle.children[0].setAttribute("aria-valuetext", text);
                });
            });
        }
        function getGroup(pips) {
            // Use the range.
            if (pips.mode === exports.PipsMode.Range || pips.mode === exports.PipsMode.Steps) {
                return scope_Spectrum.xVal;
            }
            if (pips.mode === exports.PipsMode.Count) {
                if (pips.values < 2) {
                    throw new Error("noUiSlider: 'values' (>= 2) required for mode 'count'.");
                }
                // Divide 0 - 100 in 'count' parts.
                var interval = pips.values - 1;
                var spread = 100 / interval;
                var values = [];
                // List these parts and have them handled as 'positions'.
                while (interval--) {
                    values[interval] = interval * spread;
                }
                values.push(100);
                return mapToRange(values, pips.stepped);
            }
            if (pips.mode === exports.PipsMode.Positions) {
                // Map all percentages to on-range values.
                return mapToRange(pips.values, pips.stepped);
            }
            if (pips.mode === exports.PipsMode.Values) {
                // If the value must be stepped, it needs to be converted to a percentage first.

View on GitHub (pinned to 7edb57986f)

Solutions

  1. Use a count of 2 or more: pips: {mode: noUiSlider.PipsMode.Count, values: 5}
  2. Clamp dynamic counts: values: Math.max(2, myCount)
  3. If you actually want specific positions, switch to PipsMode.Positions with a values array like [0, 25, 50, 75, 100]

Example fix

// before
noUiSlider.create(el, { start: [50], pips: { mode: noUiSlider.PipsMode.Count, values: 1 } });

// after
noUiSlider.create(el, { start: [50], pips: { mode: noUiSlider.PipsMode.Count, values: 5 } });
Defensive patterns

Strategy: validation

Validate before calling

if (pips && pips.mode === noUiSlider.PipsMode.Count && !(Number(pips.values) >= 2)) {
  pips.values = 2; // or skip pips entirely
}

Prevention

When it happens

Trigger: noUiSlider.create(el, {start: [50], pips: {mode: noUiSlider.PipsMode.Count, values: 1}}) or values: 0. Frequently the value is computed dynamically (a filter count, a data series length) and can legitimately be 0 or 1.

Common situations: Dashboards that draw a pip per bucket where the bucket count depends on data; confusing PipsMode.Count (number of intervals + 1) with PipsMode.Positions (percent positions) or PipsMode.Values (explicit values).

Related errors


AI-assisted analysis of ankane/pghero@7edb57986f (2026-08-21). Data as JSON: /api/errors/76027451214e0ab6. Report an issue: GitHub.