SoftwareDriven.SurveyJs.Analytics.Blazor
2.0.0
dotnet add package SoftwareDriven.SurveyJs.Analytics.Blazor --version 2.0.0
NuGet\Install-Package SoftwareDriven.SurveyJs.Analytics.Blazor -Version 2.0.0
<PackageReference Include="SoftwareDriven.SurveyJs.Analytics.Blazor" Version="2.0.0" />
<PackageVersion Include="SoftwareDriven.SurveyJs.Analytics.Blazor" Version="2.0.0" />
<PackageReference Include="SoftwareDriven.SurveyJs.Analytics.Blazor" />
paket add SoftwareDriven.SurveyJs.Analytics.Blazor --version 2.0.0
#r "nuget: SoftwareDriven.SurveyJs.Analytics.Blazor, 2.0.0"
#:package SoftwareDriven.SurveyJs.Analytics.Blazor@2.0.0
#addin nuget:?package=SoftwareDriven.SurveyJs.Analytics.Blazor&version=2.0.0
#tool nuget:?package=SoftwareDriven.SurveyJs.Analytics.Blazor&version=2.0.0
SoftwareDriven.SurveyJs.Analytics.Blazor
A Blazor WebAssembly wrapper for the SurveyJS Dashboard — visualize collected survey answers as charts. The SurveyJS JavaScript and its charting engine are shipped inside the package as minified bundles, loaded on demand; no script tag or npm install is required in your app.
Targets .NET 10 (net10.0) and wraps SurveyJS Dashboard 3.0.
Commercial license: The SurveyJS Dashboard is not free for commercial use. Without a license key, the dashboard shows an alert banner. Pass your key via the
LicenseKeyparameter.
Installation
dotnet add package SoftwareDriven.SurveyJs.Analytics.Blazor
Add the namespace (e.g. in _Imports.razor):
@using SoftwareDriven.SurveyJs.Analytics.Blazor
Usage
Pass the survey definition and the collected answers (an array of answer
objects). Json, Results, and Options accept a POCO, a JsonElement, or a
JSON string.
<SurveyAnalyticsHost Json="surveyJson"
Results="results"
LicenseKey="YOUR-SURVEYJS-LICENSE-KEY" />
@code {
private readonly object surveyJson = new
{
elements = new object[]
{
new { type = "radiogroup", name = "mood", title = "Mood",
choices = new[] { "Good", "Neutral", "Bad" } }
}
};
private readonly object[] results = new object[]
{
new { mood = "Good" },
new { mood = "Neutral" },
new { mood = "Good" },
};
}
Changing Results after the first render updates the charts live (no rebuild).
Capture the user's dashboard customizations via OnStateChanged and restore them
later through the State parameter or SetStateAsync.
Charting engine
SurveyJS 3.0 made Chart.js the default engine; Plotly.js remains supported. Each engine ships as its own bundle, so only the one you select is downloaded — the Chart.js bundle is about a third the size of the Plotly one.
<SurveyAnalyticsHost Json="surveyJson" Results="results"
Engine="SurveyAnalyticsEngine.Plotly" />
Engine is read when the dashboard is created. To switch it at runtime, give the
component a @key so Blazor builds a new instance:
<SurveyAnalyticsHost @key="engine" Engine="engine" Json="surveyJson" Results="results" />
Declarative configuration
A dashboard is configured through one options object. Items picks which
questions appear, in which order, and how each is visualized — including the
chart types added in v3, "radar" (for Ranking questions) and "pivot":
<SurveyAnalyticsHost Json="surveyJson" Results="results"
Items="items"
LegendPosition="SurveyLegendPosition.Bottom"
DefaultChartType="@("doughnut")" />
@code {
private readonly object[] items =
[
"mood",
new { name = "priorities", type = "radar" },
new { name = "region", type = "pivot", title = "Responses per region" },
];
}
Anything not surfaced as a parameter can still be passed through Options; the
typed parameters win over equally named entries there. SetItemTypeAsync and
SetItemVisibleAsync change a single item at runtime, and GetItemNamesAsync
lists the item names.
Date filtering
Point DateFieldName at the field in your results that holds the response date
to get the date panel, which filters the whole dashboard:
<SurveyAnalyticsHost Json="surveyJson" Results="results"
DateFieldName="@("submittedAt")"
DatePeriod="SurveyDatePeriod.LastQuarter"
OnDateRangeChanged="HandleDateRangeChanged" />
SurveyDatePeriod covers the SurveyJS presets (Last7Days, Last30Days,
LastMonth, LastQuarter, LastYear, YearToDate, MonthToDate,
QuarterToDate, …). AvailableDatePeriods narrows the list offered to the user,
DateRange sets an explicit start/end, and ShowDatePanel hides the panel while
keeping the field bound.
Cross-filtering
Clicking a chart segment filters every other chart on the dashboard. This is on
by default; set AllowSelection="false" to turn it off. SetFilterAsync applies
a filter from code and ResetFilterAsync clears all of them.
Component reference
SurveyAnalyticsHost
Parameters
| Parameter | Type | Description |
|---|---|---|
Json |
object (required) |
Survey definition in SurveyJS JSON format (POCO, JsonElement, or string). |
Results |
object (required) |
Array of collected answer objects. A new instance updates the charts. |
Options |
object? |
SurveyJS IDashboardOptions passthrough. A new instance rebuilds the dashboard. |
Engine |
SurveyAnalyticsEngine |
ChartJs (default) or Plotly. Selects the bundle to download. |
Items |
object? |
Explicit dashboard item configuration (which questions, order, visualization). |
DateFieldName |
string? |
Result field holding the response date; enables the date panel. |
DatePeriod |
SurveyDatePeriod? |
Preselected date range. Requires DateFieldName. |
AvailableDatePeriods |
IReadOnlyList<SurveyDatePeriod>? |
Ranges offered in the date panel. |
DateRange |
(DateTimeOffset, DateTimeOffset)? |
Explicit range; takes precedence over DatePeriod. |
ShowDatePanel |
bool |
Show the date panel when DateFieldName is set. Default true. |
ShowToolbar |
bool |
Show the dashboard toolbar. Default true. |
AllowSelection |
bool |
Cross-filter all charts when a segment is clicked. Default true. |
LegendPosition |
SurveyLegendPosition? |
Legend placement (Left, Right, Top, Bottom). |
DefaultChartType |
string? |
Visualization used where the question type allows a choice. |
State |
object? |
Initial dashboard state to restore (from OnStateChanged). |
Locale |
string? |
Dashboard UI language (e.g. "de"). |
LicenseKey |
string? |
SurveyJS commercial license key. |
Events
| Event | Type | Description |
|---|---|---|
OnStateChanged |
EventCallback<string> |
Dashboard state changed (chart types, layout, sorting, filtering) — JSON string to persist. |
OnElementShown / OnElementHidden / OnElementMoved |
EventCallback<string?> |
An item was shown / hidden / reordered (item name). |
OnDateRangeChanged |
EventCallback<SurveyDateRangeChange> |
The user changed the range in the date panel. |
Methods
| Method | Description |
|---|---|
ValueTask UpdateDataAsync(object results) |
Replace the visualized answers without rebuilding. |
ValueTask RefreshAsync() |
Redraw the dashboard. |
ValueTask<string?> GetStateAsync() |
Current dashboard state as a JSON string. |
ValueTask SetStateAsync(object state) |
Restore a saved state. |
ValueTask ResetStateAsync() |
Reset the state to defaults. |
ValueTask SetFilterAsync(string question, object? value) |
Cross-filter charts (pass null to clear). |
ValueTask ResetFilterAsync() |
Clear every cross-filter. |
ValueTask<IReadOnlyList<string>> GetItemNamesAsync() |
Item names in display order. |
ValueTask<bool> SetItemTypeAsync(string name, string type) |
Switch an item's visualization. |
ValueTask<bool> SetItemVisibleAsync(string name, bool visible) |
Show or hide an item. |
ValueTask SetLocaleAsync(string? locale) |
Set the dashboard locale. |
Context types
SurveyDateRangeChange(Start, End, Period)
License
Wrapper code: see repository. Bundled survey-analytics (with Chart.js and
Plotly): commercial SurveyJS license required — https://surveyjs.io/licensing.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 166 | 9/3/2026 |