Bar Chart for Poll Data
A poll is a method of collecting opinions or feedback from a group of people. Polls help data analysts gain relevant insights into the attitudes, behaviors, and preferences of individuals within the surveyed group. To facilitate poll data analysis, you can create a visual representation of poll data. This demo shows how to implement a custom poll data visualizer using the SurveyJS Dashboard library.
Any data visualizer consists of two parts: a data provider, which calculates data to be displayed, and a rendering function, which displays the data. When you implement a custom data visualizer, you should base it on a built-in visualizer, but replace one or both of these parts depending on your task. In this example, a custom visualizer is based on a built-in SelectBase
visualizer. SelectBase
already calculates values and returns them in a suitable format. We only need to implement a custom rendering function that would display these values as required.
To create a data visualizer with a custom rendering function, follow the steps below:
Implement a rendering function.
Within this function, configure the HTML markup that the visualizer should render.Instantiate the visualizer.
Create an instance of a built-in visualizer (SelectBase
in this example). Pass the question to be visualized, survey results, rendering function, and your visualizer's name to the constructor.Register the visualizer.
Use theVisualizationManager.registerVisualizer(questionType, constructor, index)
method to register your custom visualizer for use with a required question type.Specify the visualizer's display name.
This name will be displayed in the chart drop-down list. Use localization capabilities for this step.
Refer to the code listing and find comments that mark sections of code corresponding to each step.
If you are looking for information on how to create a data visualizer with a custom data provider, view the following demo: