Question T8264
Visible to All Users

Saving panel state

created 3 years ago

We wish to save the state of the visualization panel so that the panel can be recreated later on. We've found your example regarding this. However in our case we have disabled dynamic layout and are only interested in saving the dropdown choices from the panels, but this data doesn't seem to be present in the panel state. How can we retrieve and set this data?

(Actually I don't understand at all how the state is supposed to work. When running the example it always prints Which of the following best describes you or your organization?. I'd expect it to be the title of the top-most question. JSON.parse(window.localStorage.getItem('saPanelState')) never seems to change either.)

Answers approved by surveyjs Support

created 3 years ago

Hello,

I've implemented "save visualizers state in panel state" functionality via the https://github.com/surveyjs/survey-analytics/commit/87109f7c3e1eab5b38c3b56323d1f49939852132 commit. It will be released in the nearest minor update 1.9.23 next week.

Thanks, Serge
SurveyJS Team

    created 3 years ago

    Hello,

    Yes at this moment panel state holds the locale, question (visualizer) visibility and question (visualizer) title. It looks like the following JSON:

    JSON
    { "locale":"", "elements":[ { "name":"organization_type", "displayName":"Which of the following best describes you or your organization?", "isVisible":false, "isPublic":true }, { "name":"developer_count", "displayName":"How many software developers are in your organization?", "isVisible":false, "isPublic":true }, { "name":"VerticalMarket", "displayName":"What vertical market does your product serve?", "isVisible":true, "isPublic":true, } ] }

    Elements order isn't used also. Indeed saving visualizer chart type, order and other user-selected information is a good idea. I added this to our plans. And we'll work on it as soon as we'll have resources for it.

    Right now as a workaround you can access panel inner visualizers as:

    JavaScript
    var visualizer = visualizationPanel.visualizers[i] // for chart visualizer you can use the following properties: visualizer.chartType visualizer.answersOrder visuzlizer.hideEmptyAnswers visualizer.topN

    I'll update documentation on our site and this thread after.

    Thanks, Serge
    SurveyJS Team

      Show previous comments (2)
      KP KP
      Kostadin Pavlov 3 years ago

        Thank you!

        The text and comment question types can be visualized either as word cloud or in a table. How do I retrieve this setting?

        KP KP
        Kostadin Pavlov 3 years ago

          Hello again!

          Can you please explain how to retrieve whether text questions are displayed as word cloud or in a table?

            Hello,

            I'm so sorry, Kostadin! My bad. This thread still active and I missed your last comments.

            I created a separate ticket on your behalf: T9136: How to retrieve whether text questions are displayed as word cloud or in a table?. We placed it in our processing queue and will process it shortly.

            Thanks, Serge
            SurveyJS Team