I'm trying to access some extra data I attached to answers and prepended to questions array before initialising a VisualizationPanel. After checking the docs and some examples it seemed to there was no callback for filtered data.
So I have added a custom visualizer for accessing filtered data by this example Custom visualizers
But after filtering by another input data provided to the visualizer is not filtered. So I'm not sure what to do in this scenario.
Basically what I did was,
Add an id to answer objects,
Add a question with name: "id"
and type: "id"
Added a visualizer for type: "id"
What I want to do is after filtering data by any chart or something, getting a callback with the filtered data.
Hello,
Sorry, but I don't understand - what do you want to achieve. Could you describe your business case in greater details - what exact data do you want to pass into visualization panel and how do you want to use them?
Thanks, Serge
SurveyJS Team
I would like to access who is the filtered people. I can add information about who they are in question and answers jsons and this information is visualized by word cloud or list if I left the default visualizers.
Filtering a chart by an option also filters other charts by default. I checked if there is a default callback for this filtered data and there was none. Then I tried to circumvent and created a visualizer for accessing data passed around VisualizerPanel which I thought was filtered by previous action. But data provided to this visualizer was not filtered out.
Editing survey
SurveyQuestions = { ...SurveyQuestions, pages: [ { name: "page0", elements: [{ "type": "id", "name": "id", "title": "ID", "visible": true },] }, ...SurveyQuestions.pages ] }
Editing answers
rawAnswers->map(answer => ({id: answer.id, ...answer.json}));
Adding Visualizer
Survey.Serializer.addClass('id', [], null, "text"); function CustomVisualizer(question, data) { const getData = (visualizer) => { return visualizer.data.length; } const renderContent = (contentContainer, visualizer) => { const p = document.createElement('p'); p.textContent = getData(visualizer); contentContainer.appendChild(p); } return new VisualizerBase(question, data, { renderContent: renderContent }, 'idVisualizer'); } VisualizationManager.registerVisualizer('id', CustomVisualizer);
My problem is visualizer.data or visalizer.filteredData(?) provided to renderContent callback is not filtered by general filtering done to the VisualizationPanel
Hello,
I'll see what we can do here and update this thread as soon as I'll get any results.
Thanks, Serge
SurveyJS Team