Chart API Reference
This page documents every public class, interface, and enum in the PowerPortalsPro charting library.
Components
The Blazor components that render charts.
FluentUIChart
A theme-aware wrapper around the base Chart component. Reads colors from the active Fluent UI design tokens, auto-fills dataset colors from a Fluent-derived palette, and re-themes the chart when the user toggles between light and dark mode.
FluentUIChart Class
Parameters
Name | Type | Default | Description |
|---|---|---|---|
Datasets | List<ChartDataset> | Gets or sets the datasets to plot. Any dataset that leaves ChartDataset.BackgroundColor or ChartDataset.BorderColor null will be auto-filled from the active Fluent palette. | |
EnableAnimation | bool | True | Whether chart animations are enabled. Defaults to |
Height | string? | 400px | Gets or sets the optional CSS height applied to the chart container. Defaults to |
Labels | List<string> | Gets or sets the category labels rendered along the chart's primary axis. | |
LegendPosition | ChartLegendPosition? | Legend placement relative to the chart area, or ChartLegendPosition.Hidden to hide it entirely. When ChartLegendPosition.Top) is used. | |
Orientation | ChartOrientation? | Chart orientation. When ChartOrientation.Horizontal, categories appear on the Y axis and values on the X axis. Funnel charts default to horizontal for a top-down funnel. When | |
ShowBorder | bool | True | Whether to wrap the chart in a themed border with rounded corners. Defaults to |
Stacked | bool | False | Whether to stack datasets on top of each other rather than side-by-side. Applies to bar and line charts. |
Title | string? | Chart title displayed above the chart. When null, no title is shown. | |
Type | ChartType | Bar | Gets or sets the chart type to render (for example ChartType.Bar, ChartType.Line, ChartType.Pie, ChartType.Doughnut). |
Width | string? | Gets or sets the optional CSS width applied to the chart container. | |
XAxisPrefix | string? | Optional string prepended to each X-axis tick label. | |
XAxisSuffix | string? | Optional string appended to each X-axis tick label. | |
YAxisPrefix | string? | Optional string prepended to each Y-axis tick label and tooltip value (for example | |
YAxisSuffix | string? | Optional string appended to each Y-axis tick label and tooltip value (for example |
DatasetsChartDataset.BackgroundColor or ChartDataset.BorderColor null will be auto-filled from the active Fluent palette.EnableAnimationHeightLabelsLegendPositionChartLegendPosition.Hidden to hide it entirely. When ChartLegendPosition.Top) is used.OrientationChartOrientation.Horizontal, categories appear on the Y axis and values on the X axis. Funnel charts default to horizontal for a top-down funnel. When ShowBorderStackedTitleTypeChartType.Bar, ChartType.Line, ChartType.Pie, ChartType.Doughnut).WidthXAxisPrefixXAxisSuffixYAxisPrefixYAxisSuffixEvents
Name | Type | Description |
|---|---|---|
OnElementClick | EventCallback<ChartClickEventArgs> | Raised when the user clicks on a rendered chart element (a bar, slice, point, etc.). Forwarded to the underlying Components.Chart; clicks on the chart background are ignored. |
OnElementClickComponents.Chart; clicks on the chart background are ignored.Methods
Name | Parameters | Type | Description |
|---|---|---|---|
ExportAsImageAsync | Task<string> | Exports the current chart as a PNG image and returns the data as a Base64-encoded data URI (e.g. |
ExportAsImageAsyncDataverseChart
A convenience component that wraps FluentUIChart and owns the data-loading lifecycle. Accepts a DataverseChartDataSource, handles loading state, error display, and provides an optional refresh button.
DataverseChart Class
Parameters
Name | Type | Default | Description |
|---|---|---|---|
AggregationIndex | int | 0 | Which entry in ViewDataSource.AggregationResults to render. Defaults to DataverseChart.Source is used instead. |
CrossFilterMode | ChartCrossFilterMode | Highlight | Slice-click behavior when a DataverseChart.DataSource is supplied. Defaults to ChartCrossFilterMode.Highlight — soft cross-filter that emphasizes the matched slice and dims sibling non-matching rows without re-fetching. The consumer-supplied DataverseChart.OnElementClick still fires alongside, for layered telemetry / drill-through behavior. Ignored when DataverseChart.Source is used. |
DataSource | ViewDataSource? | Shared Data.ViewDataSource instance (typically also driving a paired DataverseChart.Source. The chart reads its data reactively from ViewDataSource.AggregationResults and dispatches cross-filter state on slice clicks per DataverseChart.CrossFilterMode. One server round-trip then keeps the grid's row page and the chart's aggregation atomically consistent. | |
DefaultViewId | Guid? | Optional default view ID to pre-select in the view dropdown. If not set, the first view in DataverseChart.ViewIds (or the table's default view) is selected. | |
EnableAnimation | bool | True | Whether chart animations are enabled. Defaults to |
Height | string? | 400px | Optional CSS height applied to the entire component (including the view selector dropdown and themed border, when shown). The internal chart fills whatever space remains after the toolbar and selector. Defaults to |
LegendPosition | ChartLegendPosition? | Legend placement relative to the chart area, or ChartLegendPosition.Hidden to hide it entirely. When ChartLegendPosition.Top) is used. | |
Orientation | ChartOrientation? | Chart orientation. Funnel charts default to ChartOrientation.Horizontal for a top-down funnel. When | |
ShowBorder | bool | True | Whether to wrap the chart in a themed border with rounded corners. Defaults to |
ShowExportButton | bool | True | Whether to show a download button that exports the chart as a PNG image. Defaults to |
ShowRefreshButton | bool | True | Whether to show a refresh button in the top-right corner of the chart. Defaults to |
Source | DataverseChartDataSource? | Stand-alone class-based data source. Mutually exclusive with DataverseChart.DataSource — exactly one of the two must be supplied. With DataverseChart.Source, this component owns the load + refresh lifecycle and dispatches through Services.IChartService directly. Use when a chart owns its own fetch (no paired grid). | |
Stacked | bool | False | Whether to stack datasets on top of each other rather than side-by-side. |
Title | string? | Chart title displayed above the chart. When null, no title is shown. | |
Type | ChartType | Bar | The chart type to render. |
ViewIds | List<Guid>? | Optional list of Dataverse view IDs to display in a dropdown above the chart. When the user selects a view, its filter conditions are merged into the data source and the chart reloads. Works with Components.AggregateDataverseChartDataSource and Components.ViewDataverseChartDataSource. | |
Width | string? | Optional CSS width applied to the chart container. | |
XAxisPrefix | string? | Optional string prepended to each X-axis tick label. | |
XAxisSuffix | string? | Optional string appended to each X-axis tick label. | |
YAxisPrefix | string? | Optional string prepended to each Y-axis tick label and tooltip value (e.g. | |
YAxisSuffix | string? | Optional string appended to each Y-axis tick label and tooltip value (e.g. |
AggregationIndexViewDataSource.AggregationResults to render. Defaults to DataverseChart.Source is used instead.CrossFilterModeDataverseChart.DataSource is supplied. Defaults to ChartCrossFilterMode.Highlight — soft cross-filter that emphasizes the matched slice and dims sibling non-matching rows without re-fetching. The consumer-supplied DataverseChart.OnElementClick still fires alongside, for layered telemetry / drill-through behavior. Ignored when DataverseChart.Source is used.DataSourceData.ViewDataSource instance (typically also driving a paired DataverseChart.Source. The chart reads its data reactively from ViewDataSource.AggregationResults and dispatches cross-filter state on slice clicks per DataverseChart.CrossFilterMode. One server round-trip then keeps the grid's row page and the chart's aggregation atomically consistent.DefaultViewIdDataverseChart.ViewIds (or the table's default view) is selected.EnableAnimationHeightLegendPositionChartLegendPosition.Hidden to hide it entirely. When ChartLegendPosition.Top) is used.OrientationChartOrientation.Horizontal for a top-down funnel. When ShowBorderShowExportButtonShowRefreshButtonSourceDataverseChart.DataSource — exactly one of the two must be supplied. With DataverseChart.Source, this component owns the load + refresh lifecycle and dispatches through Services.IChartService directly. Use when a chart owns its own fetch (no paired grid).StackedTitleTypeViewIdsComponents.AggregateDataverseChartDataSource and Components.ViewDataverseChartDataSource.WidthXAxisPrefixXAxisSuffixYAxisPrefixYAxisSuffixEvents
Name | Type | Description |
|---|---|---|
OnElementClick | EventCallback<ChartClickEventArgs> | Raised when the user clicks on a rendered chart element. |
OnElementClickChart Types & Enums
Enumerations for chart type selection and date bucketing.
ChartType
The set of chart types supported by the underlying Chart.js library: Bar, Line, Pie, Doughnut, PolarArea, Radar, Bubble, and Scatter.
ChartType Enum
Values
Name | Value | Description |
|---|---|---|
Bar | 0 | Vertical bar chart (Chart.js |
Line | 1 | Line chart (Chart.js |
Pie | 2 | Pie chart (Chart.js |
Doughnut | 3 | Doughnut chart (Chart.js |
PolarArea | 4 | Polar area chart (Chart.js |
Radar | 5 | Radar chart (Chart.js |
Bubble | 6 | Bubble chart (Chart.js |
Scatter | 7 | Scatter chart (Chart.js |
Funnel | 8 | Funnel chart (via |
Bar0Line1Pie2Doughnut3PolarArea4Radar5Bubble6Scatter7Funnel8ChartDateGrouping
Date bucketing intervals for grouping datetime columns in aggregate queries. Includes simple values (Day, Month, Year) and combined values (MonthAndYear, QuarterAndYear, etc.) that produce formatted labels like "Jan 2024".
ChartDateGrouping Enum
Values
Name | Value | Description |
|---|---|---|
None | 0 | No date grouping — the column is grouped by its raw value. |
Day | 1 | Group by day ( |
Week | 2 | Group by ISO week ( |
Month | 3 | Group by calendar month ( |
Quarter | 4 | Group by calendar quarter ( |
Year | 5 | Group by calendar year ( |
MonthAndYear | 6 | Group by month + year. Label: |
DayAndMonth | 7 | Group by day + month. Label: |
DayAndMonthAndYear | 8 | Group by day + month + year. Label: |
WeekAndYear | 9 | Group by ISO week + year. Label: |
QuarterAndYear | 10 | Group by quarter + year. Label: |
None0Day1Week2Month3Quarter4Year5MonthAndYear6DayAndMonth7DayAndMonthAndYear8WeekAndYear9QuarterAndYear10Data Model
The classes and interfaces that represent chart data, data points, theming, and click event payloads.
ChartData
Bundles the fully-shaped data needed to render a chart: a list of category labels (X axis) and one or more datasets. Returned by data source LoadAsync methods.
ChartData Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
Datasets | List<ChartDataset> | Datasets to plot. Each dataset's ChartDataset.Data length should match ChartData.Labels; missing buckets are zero-filled by the server so positional alignment is preserved across series. | |
Labels | List<string> | Category labels rendered along the primary axis. |
DatasetsChartDataset.Data length should match ChartData.Labels; missing buckets are zero-filled by the server so positional alignment is preserved across series.LabelsChartDataset
Represents a single dataset (series) in a chart. Contains data points, a legend label, and optional color overrides for background and border.
ChartDataset Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
BackgroundColor | string? | Default background color for every element in this dataset for cartesian chart types. For radial chart types per-point DataPoint.BackgroundColor overrides win. When | |
BorderColor | string? | Default border color. Same precedence semantics as ChartDataset.BackgroundColor. | |
BorderWidth | double | 1 | Element border width in pixels. Fractional values are supported (e.g. |
Data | List<DataPoint> | Data points in this dataset. Items are Models.DataPoint or a subclass (Models.DataverseDataPoint when the data source is Dataverse-backed). The polymorphic `$type` discriminator is preserved through JSON. | |
Label | string | Legend label for this dataset (e.g. |
BackgroundColorDataPoint.BackgroundColor overrides win. When BorderColorChartDataset.BackgroundColor.BorderWidthDataModels.DataPoint or a subclass (Models.DataverseDataPoint when the data source is Dataverse-backed). The polymorphic `$type` discriminator is preserved through JSON.LabelDataPoint
Default implementation of IDataPoint. Subclass to attach caller-defined context (record id, region, etc.) that will be available to click handlers.
DataPoint Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
BackgroundColor | string? | Per-point background color. Used by radial chart types (pie, doughnut, polarArea) to color individual segments distinctly. When | |
BorderColor | string? | Per-point border color. Same semantics as DataPoint.BackgroundColor. | |
Value | double | 0 | The numeric value plotted by Chart.js. |
BackgroundColorBorderColorDataPoint.BackgroundColor.ValueDataverseDataPoint
An IDataPoint implementation that retains the underlying Dataverse TableRecord it was projected from. Click handlers can pattern-match on this type to access the row's id, table name, and column values.
DataverseDataPoint Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
BackgroundColor | string? | Per-point background color. Used by radial chart types (pie, doughnut, polarArea) to color individual segments distinctly. When | |
BorderColor | string? | Per-point border color. Same semantics as DataPoint.BackgroundColor. | |
Record | TableRecord? | The Dataverse row this data point was projected from. Nullable because zero-filled buckets in a multi-series pivot don't have an originating record. | |
Value | double | 0 | The numeric value plotted by Chart.js. |
BackgroundColorBorderColorDataPoint.BackgroundColor.RecordValueChartTheme
Theme and formatting overrides applied to a chart instance — text color, gridline color, Y-axis value formatting (prefix/suffix), chart title, stacked mode, and legend position.
ChartTheme Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
EnableAnimation | bool | True | Gets or sets whether chart animations are enabled. Defaults to |
GridColor | string? | Gets or sets the color used for axis gridlines and borders. | |
IndexAxis | ChartIndexAxis? | The Chart.js category-axis direction. Set by the component layer from the caller's Components.ChartOrientation via Components.ChartOrientation); consumers should set Components.ChartIndexAxis). | |
LegendPosition | ChartLegendPosition? | Legend placement relative to the chart area, or ChartLegendPosition.Hidden to hide it entirely. When Components.ChartLegendPosition). | |
Stacked | bool | False | Gets or sets whether the X and Y axes are stacked. When true, datasets are stacked on top of each other rather than displayed side-by-side. Applies to bar and line charts. |
TextColor | string? | Gets or sets the color used for default text, legend labels, axis ticks, and titles. | |
Title | string? | Gets or sets the chart title text displayed above the chart. When null, no title is shown. | |
XAxisPrefix | string? | Gets or sets a string prepended to each X-axis tick label (for example | |
XAxisSuffix | string? | Gets or sets a string appended to each X-axis tick label. When null, no suffix is applied. | |
YAxisPrefix | string? | Gets or sets a string prepended to each Y-axis tick label and tooltip value (for example | |
YAxisSuffix | string? | Gets or sets a string appended to each Y-axis tick label and tooltip value (for example |
EnableAnimationGridColorIndexAxisComponents.ChartOrientation via Components.ChartOrientation); consumers should set Components.ChartIndexAxis).LegendPositionChartLegendPosition.Hidden to hide it entirely. When Components.ChartLegendPosition).StackedTextColorTitleXAxisPrefixXAxisSuffixYAxisPrefixYAxisSuffixChartClickEventArgs
Payload describing a click on a single chart element (bar, slice, point, etc.). Contains the dataset index, data index, label, value, dataset label, and the original IDataPoint instance for pattern matching.
ChartClickEventArgs Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
DataIndex | int | 0 | The zero-based index of the data point within its dataset. |
DataPoint | DataPoint? | The actual Models.DataPoint instance that backs the clicked element. Pattern-match against your custom subclass (e.g. Models.DataverseDataPoint) to access caller-defined context (record id, category, etc.). May be | |
DatasetIndex | int | 0 | The zero-based index of the dataset that contains the clicked element. |
DatasetLabel | string | The label of the dataset the clicked element belongs to (for example | |
Label | string | The category label associated with the clicked element (for example | |
Value | double | 0 | The numeric value of the clicked data point. |
DataIndexDataPointModels.DataPoint instance that backs the clicked element. Pattern-match against your custom subclass (e.g. Models.DataverseDataPoint) to access caller-defined context (record id, category, etc.). May be DatasetIndexDatasetLabelLabelValueData Sources
Data source classes that load chart data from Dataverse via FetchXML queries.
DataverseChartDataSource
Base data source class that accepts raw FetchXML and column mappings. Executes the query via IPowerPortalsProService, handles RelatedRecordValue unwrapping for aggregate results, and shapes rows into single- or multi-series ChartData.
DataverseChartDataSource Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
FetchXml | string? | The FetchXML query to execute. The base class sends this in the request directly; subclasses override Models.ChartDataRequest) to use a different input mode. | |
LabelColumn | string | The result column name to use for chart labels (X axis). For raw FetchXML this is the attribute logical name (or its alias if one was specified in the FetchXML). | |
SeriesColumn | string? | Optional result column name used to split rows into multiple datasets. When set, rows sharing the same series value are grouped into one dataset. | |
SingleSeriesLabel | string | Optional dataset label applied to the single emitted dataset when DataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this. | |
ValueColumn | string | The result column name to read numeric values from. Must reference a numeric column on the returned rows. |
FetchXmlModels.ChartDataRequest) to use a different input mode.LabelColumnSeriesColumnSingleSeriesLabelDataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this.ValueColumnMethods
Name | Parameters | Type | Description |
|---|---|---|---|
LoadAsync | IChartService chartService | Task<ChartData> | Loads chart data via the shared Services.IChartService. |
LoadAsyncServices.IChartService.AggregateDataverseChartDataSource
A subclass that builds an aggregate FetchXML query from simple properties (TableName, GroupByColumn, AggregateColumn, Aggregate) instead of requiring raw FetchXML. Supports date bucketing, multi-series, view-based filtering, inline filter fragments, and linked entity joins.
AggregateDataverseChartDataSource Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
Aggregate | AggregateType | Sum | The aggregate function applied to AggregateDataverseChartDataSource.AggregateColumn. |
AggregateColumn | string | The Dataverse column to aggregate. For AggregateType.Count any column works. Sets DataverseChartDataSource.ValueColumn on the base class so they stay in sync. | |
FetchXml | string? | The FetchXML query to execute. The base class sends this in the request directly; subclasses override Models.ChartDataRequest) to use a different input mode. | |
FilterXml | string? | Optional raw FetchXML filter fragment to inject into the generated query (a complete | |
GroupByColumn | string | The Dataverse column to group by — becomes the chart's X-axis labels. Sets DataverseChartDataSource.LabelColumn on the base class so they stay in sync. | |
GroupByDateGrouping | ChartDateGrouping | None | When AggregateDataverseChartDataSource.GroupByColumn is a datetime column, controls how dates are bucketed. |
GroupByLinkedEntity | ChartLinkedEntity? | Optional linked-entity chain for AggregateDataverseChartDataSource.GroupByColumn. When set, the groupby attribute is placed inside the link-entity in the generated FetchXML. | |
LabelColumn | string | The result column name to use for chart labels (X axis). For raw FetchXML this is the attribute logical name (or its alias if one was specified in the FetchXML). | |
SeriesColumn | string? | Optional result column name used to split rows into multiple datasets. When set, rows sharing the same series value are grouped into one dataset. | |
SeriesDateGrouping | ChartDateGrouping | None | Optional date grouping for the series — applied to the same column as AggregateDataverseChartDataSource.GroupByColumn. Year-over-year charts use ChartDateGrouping.Month on AggregateDataverseChartDataSource.GroupByDateGrouping and ChartDateGrouping.Year on this property. When set, DataverseChartDataSource.SeriesColumn is ignored. |
SeriesLinkedEntity | ChartLinkedEntity? | Optional linked-entity chain for DataverseChartDataSource.SeriesColumn. | |
SingleSeriesLabel | string | Optional dataset label applied to the single emitted dataset when DataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this. | |
TableName | string | The Dataverse table to query (e.g. | |
Top | int? | Optional maximum number of grouped rows to return. | |
ValueColumn | string | The result column name to read numeric values from. Must reference a numeric column on the returned rows. | |
ViewId | Guid? | Optional saved-view id. When set, the view's filter conditions are merged into the generated aggregate query. Determines which records are included; the aggregate config determines how they're grouped. |
AggregateAggregateDataverseChartDataSource.AggregateColumn.AggregateColumnAggregateType.Count any column works. Sets DataverseChartDataSource.ValueColumn on the base class so they stay in sync.FetchXmlModels.ChartDataRequest) to use a different input mode.FilterXmlGroupByColumnDataverseChartDataSource.LabelColumn on the base class so they stay in sync.GroupByDateGroupingAggregateDataverseChartDataSource.GroupByColumn is a datetime column, controls how dates are bucketed.GroupByLinkedEntityAggregateDataverseChartDataSource.GroupByColumn. When set, the groupby attribute is placed inside the link-entity in the generated FetchXML.LabelColumnSeriesColumnSeriesDateGroupingAggregateDataverseChartDataSource.GroupByColumn. Year-over-year charts use ChartDateGrouping.Month on AggregateDataverseChartDataSource.GroupByDateGrouping and ChartDateGrouping.Year on this property. When set, DataverseChartDataSource.SeriesColumn is ignored.SeriesLinkedEntityDataverseChartDataSource.SeriesColumn.SingleSeriesLabelDataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this.TableNameTopValueColumnViewIdMethods
Name | Parameters | Type | Description |
|---|---|---|---|
LoadAsync | IChartService chartService | Task<ChartData> | Loads chart data via the shared Services.IChartService. |
LoadAsyncServices.IChartService.ViewDataverseChartDataSource
A subclass that resolves its FetchXML from a Dataverse saved view (saved query). The caller still sets LabelColumn and ValueColumn to indicate which columns map to labels and values.
ViewDataverseChartDataSource Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
FetchXml | string? | The FetchXML query to execute. The base class sends this in the request directly; subclasses override Models.ChartDataRequest) to use a different input mode. | |
LabelColumn | string | The result column name to use for chart labels (X axis). For raw FetchXML this is the attribute logical name (or its alias if one was specified in the FetchXML). | |
SeriesColumn | string? | Optional result column name used to split rows into multiple datasets. When set, rows sharing the same series value are grouped into one dataset. | |
SingleSeriesLabel | string | Optional dataset label applied to the single emitted dataset when DataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this. | |
ValueColumn | string | The result column name to read numeric values from. Must reference a numeric column on the returned rows. | |
ViewId | Guid | 00000000-0000-0000-0000-000000000000 | The unique identifier of the Dataverse saved view to load. The server fetches its FetchXml on every call (uncached at this layer; ViewMetadataCache handles caching server-side). |
FetchXmlModels.ChartDataRequest) to use a different input mode.LabelColumnSeriesColumnSingleSeriesLabelDataverseChartDataSource.SeriesColumn is not set. Multi-series queries use the formatted series value as the dataset label and ignore this.ValueColumnViewIdMethods
Name | Parameters | Type | Description |
|---|---|---|---|
LoadAsync | IChartService chartService | Task<ChartData> | Loads chart data via the shared Services.IChartService. |
LoadAsyncServices.IChartService.ChartLinkedEntity
Describes a linked entity (join) used by AggregateDataverseChartDataSource to place a groupby or series attribute on a related table. Supports unlimited nesting via the LinkedEntity property for multi-hop joins (e.g. opportunity → account → business unit).
ChartLinkedEntity Class
Properties
Name | Type | Default | Description |
|---|---|---|---|
From | string | Column on the linked table that provides the join key (e.g. | |
JoinType | JoinOperator | Inner | Join type. Defaults to JoinOperator.Inner. |
LinkedEntity | ChartLinkedEntity? | Optional child linked entity for multi-hop joins. The groupby/series attribute is placed on the innermost entity in the chain. | |
TableName | string | Logical name of the linked table (e.g. | |
To | string | Column on the parent table (or parent link-entity) to join to (e.g. |
FromJoinTypeJoinOperator.Inner.LinkedEntityTableNameToSharing one datasource between a grid and a chart
A ViewDataSource can drive a MainGrid and one (or more) DataverseChart components in lockstep. One server round-trip returns the row page and the chart aggregation atomically, so there's no race where the chart shows numbers for an old filter while the grid is on a new one. Search, sort, page, and view changes on either consumer flow through the same datasource.
Construct the datasource in OnInitialized (so the injected IGridService is available) and pass it to both views via DataSource. The grid renders the row page; the chart renders AggregationResults[AggregationIndex]. Multiple aggregations are supported — each entry powers a separate chart pointing at the same datasource.
<DataverseChart DataSource="_ds" Type="ChartType.Pie" />
<MainGrid DataSource="_ds" TableName="opportunity" />
@code {
private ViewDataSource? _ds;
protected override void OnInitialized()
{
_ds = new ViewDataSource(_gridService, new ViewDataSourceOptions
{
ViewId = _openOpportunitiesViewId,
Aggregations = new[]
{
new ChartAggregation
{
GroupBy = new ChartGrouping { Column = "opportunityratingcode" },
AggregateColumn = "opportunityid",
Aggregate = AggregateType.Count,
},
},
});
}
public async ValueTask DisposeAsync()
{
if (_ds is not null) await _ds.DisposeAsync();
}
}
Clicking a chart slice sets the datasource's Highlight, which dims non-matching rows in the paired grid (and non-matching slices in the chart) without re-fetching. Click the same slice again to clear. For drill-through navigation or a hard filter, set CrossFilterMode="ChartCrossFilterMode.None" and handle OnElementClick yourself.
