on or after this date (UTC)
Source on GitHub
Definition: shared/definitions/dashboard.json
Commercial client licence: without SURVEYJS_LICENSE_KEY the component shows a licence banner
shared/client/dashboard.js · sjs:dashboard.client
View on GitHub
import { Model } from "survey-core";
import { VisualizationPanel } from "survey-analytics";
async function showDashboard(from) {
const { definition } = await fetch("/api/forms/feedback").then(r => r.json()); // .definition: GET /api/forms/{id}
const responses = await fetch(`/api/responses?formId=feedback&from=${from}`).then(r => r.json());
const survey = new Model(definition);
const dashboard = new VisualizationPanel(survey.getAllQuestions(), responses);
dashboard.render(document.getElementById("dashboard"));
return dashboard;
}
routes/examples/dashboard.php · sjs:dashboard.server
View on GitHub
// GET /api/responses?formId=&from=&limit=&offset= — the stored answers as an array
Route::get('/api/responses', function (Request $request) {
$documents = DB::table('responses')
->where('form_id', $request->query('formId'))
->where('created_at', '>=', $request->query('from', '1970-01-01')) // ISO-8601 UTC strings compare as dates
->orderBy('created_at')
->limit(min(max((int) $request->query('limit', 500), 1), 5000)) // filter or page on the server for large volumes
->offset(max((int) $request->query('offset', 0), 0))
->pluck('data');
return response('['.$documents->implode(',').']') // documents as stored, not re-encoded
->header('Content-Type', 'application/json');
});