Back to Devexpress

CardDashboardItem Class

dashboard-devexpress-dot-dashboardcommon-2b708124.md

latest8.5 KB
Original Source

CardDashboardItem Class

A Card dashboard item that displays a series of KPI elements (cards), each illustrating the difference between two values.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class CardDashboardItem :
    KpiDashboardItem<Card>,
    ISparklineArgumentHolder
vb
Public Class CardDashboardItem
    Inherits KpiDashboardItem(Of Card)
    Implements ISparklineArgumentHolder

Remarks

The Card dashboard item displays a series of cards that can show various value types (an actual and target value, the difference between them, etc.) and indicators (such as a delta indicator or sparkline). To visualize a set of cards (contained in the CardDashboardItem.Cards collection), a layout template is required. It is specified using the Card.LayoutTemplate property.

Prior to 17.1 version, the Card dashboard item uses the built-in layout template and the Card.LayoutTemplate property is null. We recommend updating dashboard card item settings to specify new layout templates. For more information, see the Designing Dashboard Items->Cards->Layout topic.

The following documentation sections are available.

Example

The following example shows how to bind a Card dashboard item to data in code.

View Example: How to Bind a Card Dashboard Item to Data in Code

csharp
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.Excel;
using DevExpress.XtraEditors;

namespace DXApplication1
{
    public partial class ViewerForm1 : XtraForm
    {
        public ViewerForm1()
        {
            InitializeComponent();

            dashboardViewer.Dashboard = new Dashboard();

            // Creates a data source and adds it to the dashboard data source collection.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();
            excelDataSource = CreateExcelDataSource();
            dashboardViewer.Dashboard.DataSources.Add(excelDataSource);

            // Creates a card dashboard item with the specified data source 
            // and adds it to the Items collection to display within the dashboard.
            CardDashboardItem cards = CreateCards(excelDataSource);
            dashboardViewer.Dashboard.Items.Add(cards);

            // Reloads data in the data sources.
            dashboardViewer.ReloadData();
        }
        private CardDashboardItem CreateCards(DashboardExcelDataSource dataSource)
        {
            // Creates a card dashboard item and specifies its data source.
            CardDashboardItem cards = new CardDashboardItem();
            cards.DataSource = dataSource;

            // Creates the Card object with measures that provide data for calculating actual and target
            // values, and then adds this object to the Cards collection of the card dashboard item.
            Card card = new Card();
            card.ActualValue = new Measure("RevenueQTD (Sum)");
            card.TargetValue = new Measure("RevenueQTDTarget (Sum)");
            cards.Cards.Add(card);

            // Specifies dimensions that provides data for a card dashboard item series.
            cards.SeriesDimensions.Add(new Dimension("Category"));
            cards.SeriesDimensions.Add(new Dimension("Product"));
            cards.InteractivityOptions.IsDrillDownEnabled = true;

            return cards;
        }
        public DashboardExcelDataSource CreateExcelDataSource()
        {
            // Generates the Excel Data Source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();
            excelDataSource.FileName = @"Data\Sales.xlsx";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Sheet1", "A1:I4166");
            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();

            return excelDataSource;
        }
    }

}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.Excel
Imports DevExpress.XtraEditors

Namespace DXApplication1
    Partial Public Class ViewerForm1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()

            dashboardViewer.Dashboard = New Dashboard()

            ' Creates a data source and adds it to the dashboard data source collection.
            Dim excelDataSource As New DashboardExcelDataSource()
            excelDataSource = CreateExcelDataSource()
            dashboardViewer.Dashboard.DataSources.Add(excelDataSource)

            ' Creates a card dashboard item with the specified data source 
            ' and adds it to the Items collection to display within the dashboard.
            Dim cards As CardDashboardItem = CreateCards(excelDataSource)
            dashboardViewer.Dashboard.Items.Add(cards)

            ' Reloads data in the data sources.
            dashboardViewer.ReloadData()
        End Sub
        Private Function CreateCards(ByVal dataSource As DashboardExcelDataSource) As CardDashboardItem
            ' Creates a card dashboard item and specifies its data source.
            Dim cards As New CardDashboardItem()
            cards.DataSource = dataSource

            ' Creates the Card object with measures that provide data for calculating actual and target
            ' values, and then adds this object to the Cards collection of the card dashboard item.
            Dim card As New Card()
            card.ActualValue = New Measure("RevenueQTD (Sum)")
            card.TargetValue = New Measure("RevenueQTDTarget (Sum)")
            cards.Cards.Add(card)

            ' Specifies dimensions that provides data for a card dashboard item series.
            cards.SeriesDimensions.Add(New Dimension("Category"))
            cards.SeriesDimensions.Add(New Dimension("Product"))
            cards.InteractivityOptions.IsDrillDownEnabled = True

            Return cards
        End Function
        Public Function CreateExcelDataSource() As DashboardExcelDataSource
            ' Generates the Excel Data Source.
            Dim excelDataSource As New DashboardExcelDataSource()
            excelDataSource.FileName = "Data\Sales.xlsx"
            Dim worksheetSettings As New ExcelWorksheetSettings("Sheet1", "A1:I4166")
            excelDataSource.SourceOptions = New ExcelSourceOptions(worksheetSettings)
            excelDataSource.Fill()

            Return excelDataSource
        End Function
    End Class

End Namespace

Implements

ICustomPropertyProvider

Inheritance

Object DashboardItem DataDashboardItem SeriesDashboardItem KpiDashboardItem<Card> CardDashboardItem

See Also

CardDashboardItem Members

DevExpress.DashboardCommon Namespace