var json = {
"elements": [
{
"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>Survey Analytics + SurveyJS.IO service, Reactjs Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/jquery"></script>
<script src="https://unpkg.com/react@17.0.1/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.1/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
<script src="/DevBuilds/survey-core/survey.core.min.js"></script>
<script src="/DevBuilds/survey-core/survey.i18n.min.js"></script>
<script src="/DevBuilds/survey-react-ui/survey-react-ui.min.js"></script>
<link href="/DevBuilds/survey-core/defaultV2.min.css" type="text/css" rel="stylesheet" />
<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/babel" src="./index.js"></script>
</body>
</html>