Cart Buy Licenses Contact Support Login/Register
v 1.8.18
v 1.8.18
Overview Examples Docs Source Download

Show sortable question answers as chart

Show sortable question answers as chart via a built-in chart visualizer.

loading...

                        


    
        var json = {
  "elements": [
    {
      "type": "sortablelist",
      "name": "lifepriority",
      "title": "Life Priorities ",
      "isRequired": true,
      "choices": [ "family", "work", "pets", "travels", "games" ]
    }
  ]
};
    
SurveyAnalytics.VisualizationManager.registerVisualizer("sortablelist", SurveyAnalytics.SelectBasePlotly);

var survey = new Survey.Model(json);
var allQuestions = survey.getAllQuestions();

var data = [
    {
    "lifepriority": [
        "family",
        "travels"
    ]
    }, {
    "lifepriority": [
        "family",
        "pets"
    ]
    }
];

var panelNode = document.getElementById("vizPanel");
panelNode.innerHTML = "";

var visPanel = new SurveyAnalytics.VisualizationPanel(allQuestions, data, {labelTruncateLength: 27});
visPanel.showHeader = true;
visPanel.render(panelNode);
$("#loadingIndicator").hide();

                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Show sortable question answers as chart via a built-in chart visualizer., jQuery Survey Library Example</title>

<meta name="viewport" content="width=device-width" />
    <script src="https://unpkg.com/jquery"></script>
<script src="/DevBuilds/survey-jquery/survey.jquery.min.js"></script>
    <link rel="stylesheet" href="./index.css">
<script src="https://cdn.rawgit.com/inexorabletash/polyfill/master/typedarray.js"></script>

<script src="https://polyfill.io/v3/polyfill.min.js"></script>

<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

<script src="https://unpkg.com/wordcloud@1.1.0/src/wordcloud2.js"></script>

<script src="https://unpkg.com/sortablejs@1.7.0/Sortable.js"></script>        <link href="/DevBuilds/survey-analytics/survey.analytics.min.css" rel="stylesheet" />
        <script src="/DevBuilds/survey-analytics/survey.analytics.min.js"></script>
    <script src="/DevBuilds/surveyjs-widgets/surveyjs-widgets.js"></script>

</head>
<body>
    
<div id="loadingIndicator">
    <span>
        <div id="loading"><strong>loading...</strong><span></span></div>
    </span>
</div>
<div id="vizPanel"></div>
            <div id="surveyElement" style="display:inline-block;width:100%;">
            </div>
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>

</body>
</html>