dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-f1f346ae.md
Gets or sets whether to calculate totals for the hidden data items.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
[DefaultValue(false)]
public bool CalculateHiddenTotals { get; set; }
<DefaultValue(False)>
Public Property CalculateHiddenTotals As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true , to calculate hidden totals; otherwise, false.
|
Set the CalculateHiddenTotals property to true to calculate totals for the hidden measures.
For displayed values, you can obtain hidden measures values regardless of the CalculateHiddenTotals property’s value.
This following code snippet calculates a total value (distinct count) for a hidden measure and display it in the dashboard item’s caption.
using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;
using DevExpress.DashboardWin;
using System.Data;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace CalculateHIddenTotalsExample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
dashboardViewer1.CalculateHiddenTotals = true;
dashboardViewer1.ConfigureDataConnection += DashboardViewer1_ConfigureDataConnection;
dashboardViewer1.CustomizeDashboardItemCaption += DashboardViewer1_CustomizeDashboardItemCaption;
// Load the dashboard after all DashboardViewer options are set.
dashboardViewer1.DashboardSource = typeof(Dashboard1);
}
private void DashboardViewer1_CustomizeDashboardItemCaption(object sender, CustomizeDashboardItemCaptionEventArgs e)
{
DashboardViewer viewer = (DashboardViewer)sender;
if (e.DashboardItemName == "pieDashboardItem1")
{
DashboardToolbarItem infoButton = new DashboardToolbarItem();
MultiDimensionalData mData = viewer.GetItemData(e.DashboardItemName);
var orderCount = mData.GetValue(mData.GetMeasures().Where(m => m.DataMember == "OrderID").First()).Value ?? 0;
e.FilterText += string.Format("{0:N0} distinct orders are displayed", orderCount);
}
}
private void DashboardViewer1_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
{
ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;
if (parameters != null) parameters.FileName = Path.GetFileName(parameters.FileName);
}
}
}
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardCommon.ViewerData
Imports DevExpress.DashboardWin
Imports System.Data
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Namespace CalculateHIddenTotalsExample
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
dashboardViewer1.CalculateHiddenTotals = True
AddHandler dashboardViewer1.ConfigureDataConnection, AddressOf DashboardViewer1_ConfigureDataConnection
AddHandler dashboardViewer1.CustomizeDashboardItemCaption, AddressOf DashboardViewer1_CustomizeDashboardItemCaption
' Load the dashboard after all DashboardViewer options are set.
dashboardViewer1.DashboardSource = GetType(Dashboard1)
End Sub
Private Sub DashboardViewer1_CustomizeDashboardItemCaption(ByVal sender As Object, ByVal e As CustomizeDashboardItemCaptionEventArgs)
Dim viewer As DashboardViewer = DirectCast(sender, DashboardViewer)
If e.DashboardItemName = "pieDashboardItem1" Then
Dim infoButton As New DashboardToolbarItem()
Dim mData As MultiDimensionalData = viewer.GetItemData(e.DashboardItemName)
Dim orderCount = If(mData.GetValue(mData.GetMeasures().Where(Function(m) m.DataMember = "OrderID").First()).Value, 0)
e.FilterText &= String.Format("{0:N0} distinct orders are displayed", orderCount)
End If
End Sub
Private Sub DashboardViewer1_ConfigureDataConnection(ByVal sender As Object, ByVal e As DashboardConfigureDataConnectionEventArgs)
Dim parameters As ExtractDataSourceConnectionParameters = TryCast(e.ConnectionParameters, ExtractDataSourceConnectionParameters)
If parameters IsNot Nothing Then
parameters.FileName = Path.GetFileName(parameters.FileName)
End If
End Sub
End Class
End Namespace
This example demonstrates how to access the underlying controls used to display the Pie Item and configure their settings to display the Total value in the title. Total values are calculated automatically if the CalculateHiddenTotals property is enabled. Use the DashboardViewer.GetItemData method to get the total value.
using DevExpress.DashboardCommon.ViewerData;
using DevExpress.DashboardWin;
using DevExpress.XtraCharts;
namespace TotalsInChartsExample
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1() {
InitializeComponent();
dashboardViewer1.DashboardItemControlUpdated += Viewer_DashboardItemControlUpdated;
dashboardViewer1.CalculateHiddenTotals = true;
dashboardViewer1.DashboardSource = typeof(Dashboards.Dashboard1);
}
private void Viewer_DashboardItemControlUpdated(object sender, DashboardItemControlEventArgs e) {
if (e.DashboardItemName == "pieDashboardItem1") {
var viewer = (DashboardViewer)sender;
var chart = e.ChartControl;
var data = viewer.GetItemData(e.DashboardItemName);
var measure = data.GetMeasures()[0];
foreach (Series series in chart.Series) {
var axisPoint = series.Tag as AxisPoint;
if (axisPoint != null) {
var total = data.GetSlice(axisPoint).GetValue(measure).DisplayText;
var view = series.View as PieSeriesView;
if (view != null)
view.Titles[0].Text = string.Format("{0} - {1}", series.Name, total);
}
}
}
}
}
}
Imports DevExpress.DashboardCommon.ViewerData
Imports DevExpress.DashboardWin
Imports DevExpress.XtraCharts
Namespace TotalsInChartsExample
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
AddHandler dashboardViewer1.DashboardItemControlUpdated, AddressOf Viewer_DashboardItemControlUpdated
dashboardViewer1.CalculateHiddenTotals = True
dashboardViewer1.DashboardSource = GetType(Dashboards.Dashboard1)
End Sub
Private Sub Viewer_DashboardItemControlUpdated(ByVal sender As Object, ByVal e As DashboardItemControlEventArgs)
If e.DashboardItemName = "pieDashboardItem1" Then
Dim viewer = DirectCast(sender, DashboardViewer)
Dim chart = e.ChartControl
Dim data = viewer.GetItemData(e.DashboardItemName)
Dim measure = data.GetMeasures()(0)
For Each series As Series In chart.Series
Dim axisPoint = TryCast(series.Tag, AxisPoint)
If axisPoint IsNot Nothing Then
Dim total = data.GetSlice(axisPoint).GetValue(measure).DisplayText
Dim view = TryCast(series.View, PieSeriesView)
If view IsNot Nothing Then
view.Titles(0).Text = String.Format("{0} - {1}", series.Name, total)
End If
End If
Next series
End If
End Sub
End Class
End Namespace
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CalculateHiddenTotals property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
how-to-display-the-total-value-above-each-pie-chart/CS/TotalsInChartsExample/Form1.cs#L13
dashboardViewer1.DashboardItemControlUpdated += Viewer_DashboardItemControlUpdated;
dashboardViewer1.CalculateHiddenTotals = true;
dashboardViewer1.DashboardSource = typeof(Dashboards.Dashboard1);
how-to-display-the-total-value-above-each-pie-chart/VB/TotalsInChartsExample/Form1.vb#L13
AddHandler dashboardViewer1.DashboardItemControlUpdated, AddressOf Viewer_DashboardItemControlUpdated
dashboardViewer1.CalculateHiddenTotals = True
dashboardViewer1.DashboardSource = GetType(Dashboards.Dashboard1)
See Also