Number Scale
The NumberScale question type allows respondents to select a single numeric rating on a scale, typically used to measure attitudes or opinions.
Basic Usage
Parameters
Unique identifier for the question.
The main question text or statement to be rated.
Additional text to provide context or instructions.
Whether the question is required.
The minimum value on the scale.
The maximum value on the scale.
Label for the minimum value on the scale.
Label for the maximum value on the scale.
A custom validation function that takes the response as input and returns true if valid, or an error message string if invalid.
Custom styles to apply to the question. Available keys are:
root
innerContainer
textContainer
text
subText
scaleContainer
scaleItem
scaleInput
scaleCircle
scaleNumber
scaleLabels
errorMessage
Data
Response Format
The NumberScale question type returns a single number representing the selected rating:
Validation
The NumberScale question validates that:
- A rating is selected when required is true.
- The selected rating is within the specified range (min to max).
- Any custom validation provided in the
customValidation
function passes.
If validation fails, it displays an error message.
Methods
The NumberScale question type inherits methods from the base Element class and implements some specific methods:
Set the response for the question.
Parameters:
value
(number): The selected rating
Validate the current response against the question’s rules.
Returns:
- An object with
isValid
(boolean) anderrorMessage
(string) properties.
Update the styles of the selected rating option. This is called automatically when a response is set.
Example
Here’s an example of how to create a customized Number Scale question: