Cart Buy Licenses Contact Integrate into App Docs Support Login/Register
v 1.8.47
v 1.8.47
Overview Examples Docs Source Download

Survey Analytics + SurveyJS.IO service

You can visualize any published survey results from the https://surveyjs.io service

loading...

                        


    
        var json = {
  "questions": [
    {
      "type": "checkbox",
      "name": "langs",
      "title": "What language(s) are you currently using?",
      "colCount": 4,
      "isRequired": true,
      "choices": [ "Javascript", "Java", "Python", "CSS", "PHP", "Ruby", "C++", "C", "Shell", "C#", "Objective-C", "R", "VimL", "Go", "Perl", "CoffeeScript", "TeX", "Swift", "Scala", "Emacs List", "Haskell", "Lua", "Clojure", "Matlab", "Arduino", "Makefile", "Groovy", "Puppet", "Rust", "PowerShell" ],
      "validators": [
        {
          "type": "answercountvalidator",
          "maxCount": 3,
          "text": "Please select maximum three languges."
        }
      ]
    }
  ]
};
    
    // You can set JSON directly
    // var survey = new Survey.Model(json);

    // Or get survey JSON from our service by survey Id
    var jsonWithIds = {
        surveyId: '5af48e08-a0a5-44a5-83f4-1c90e8e98de1',
        surveyPostId: '3ce10f8b-2d8a-4ca2-a110-2994b9e697a1'
    };
    var survey = new Survey.Model(jsonWithIds);

    var surveyResultNode = document.getElementById("surveyResult");
    surveyResultNode.innerHTML = "";

    // Published survey results can be obtained via the https://surveyjs.io/Help/Api/GET-api-MySurveys-getSurveyPublicResults-id_from_till?apiType=private API method using survey ID
    $.get("https://surveyjs.io/api/MySurveys/getSurveyPublicResults/5af48e08-a0a5-44a5-83f4-1c90e8e98de1", function (data) {
        var visPanel = new SurveyAnalytics.VisualizationPanel(
            survey.getAllQuestions(),
            data.Data,
            { labelTruncateLength: 27 }
        );
        visPanel.showHeader = true;

        $("#loadingIndicator").hide();

        visPanel.render(surveyResultNode);
    });

                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>You can visualize any published survey results from the https://surveyjs.io service, 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>        <link href="/DevBuilds/survey-analytics/survey.analytics.min.css" rel="stylesheet" />
        <script src="/DevBuilds/survey-analytics/survey.analytics.min.js"></script>

</head>
<body>
    
<div>

</div>

<div id="loadingIndicator">
    <span>
        <div id="loading"><strong>loading...</strong><span></span></div>
    </span>
</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>