Skip to main content
A newer version of this page is available. .

ChartItem Class

A Chart dashboard item that visualizes data in an XY-diagram.

Declaration

export class ChartItem extends ChartItemBase

Remarks

The chart dashboard item visualizes data in an XY-diagram, allowing you to render a wide range of diagram types - from simple bar or line charts to financial Open-High-Low-Close graphs.

wdd-dashboard-items-chart

Refer to Web Dashboard - Creating a Chart to learn more about Charts.

Example

The following example shows how to create the Chart dashboard item, bind it to data and add to the existing dashboard.

Create data items (measures and dimensions) and use the DataItem.dataMember property to bind them to the existing data source’s columns. Then use the created measures and dimensions in the dashboard item to bind it to data.

After you add the created dashboard item to the Dashboard.items collection, call the Dashboard.rebuildLayout method to rebuild the dashboard layout and display changes.

// Use the line below for a modular approach:
// import * as Model from 'devexpress-dashboard/model'
// Use the line below for an approach with global namespaces:
// var Model = DevExpress.Dashboard.Model;

// ...
public createChartItem() { 
    // Create data items for the Chart dashboard item.
    var chartCategoryName = new Model.Dimension();
    chartCategoryName.dataMember("CategoryName");
    var chartCountry = new Model.Dimension();
    chartCountry.dataMember("Country");
    var chartUnitPrice = new Model.Measure();
    chartUnitPrice.dataMember("UnitPrice");

    // Create the Chart dashboard item and bind it to data.
    var chartItem = new Model.ChartItem();
    chartItem.name('chart');
    chartItem.dataSource(sqlDataSource.componentName());
    chartItem.dataMember(sqlDataSource.queries()[0].name());

    chartItem.arguments.push(chartCategoryName);
    var pane = chartItem.panes()[0];
    var chartSeries = new Model.SimpleSeries(chartItem);
    chartSeries.seriesType("Bar");
    chartSeries.value(chartUnitPrice);
    pane.series.push(chartSeries);
    chartItem.seriesDimensions.push(chartCountry);

    control.dashboard().items.push(chartItem);
    // ...
    control.dashboard().rebuildLayout();
}

Inherited Members

DevExpress.Dashboard.Model.DataDashboardItem.componentName
DevExpress.Dashboard.Model.DataDashboardItem.name
DevExpress.Dashboard.Model.DataDashboardItem.parentContainer
DevExpress.Dashboard.Model.DataDashboardItem.showCaption
DevExpress.Dashboard.Model.DataDashboardItem.getUniqueNamePrefix

constructor

Initializes a new instance of the ChartItem class.

Declaration

constructor(
    dashboardItemJSON?: any,
    serializer?: DxDesigner.Analytics.Utils.ModelSerializer
)

Parameters

Name Type Description
dashboardItemJSON any

A JSON object used for a dashboard deserialization. Do not pass this parameter directly.

serializer DxDesigner.Analytics.Utils.ModelSerializer

An object used for a dashboard deserialization. Do not pass this parameter directly.

Properties

axisX Property

Declaration

axisX: ChartAxisX

Property Value

Type
ChartAxisX

legend Property

Provides access to a chart legend.

Declaration

legend: ChartLegend

Property Value

Type Description
ChartLegend

A ChartLegend object that represents a chart legend.

panes Property

Specifies a collection of panes.

Declaration

panes: ko.ObservableArray<ChartPane>

Property Value

Type Description
ObservableArray<ChartPane>

A collection of ChartPane objects that represent panes.

Remarks

Use the panes property to access the collection of panes. You can add new panes to this collection to create a multi-pane chart.

ChartPane objects contained in the panes collection are used to access a collection of series plotted on the corresponding pane. To do this, use the ChartPane.series property.

Each pane has its own Y-axis, so that the corresponding ChartPane object provides the ChartPane.primaryAxisY property that allows you to customize the axis settings.

rotated Property

Specifies whether the chart is rotated.

Declaration

rotated: ko.Observable<boolean>

Property Value

Type Description
Observable<boolean>

true, to rotate the chart; otherwise, false.

Remarks

By default, a chart has its X-axis oriented horizontally and its Y-axis oriented vertically. Set the rotated property to true to rotate the chart so that the Y-axis renders horizontally and the X-axis renders vertically.

Methods

getInfo Method

For internal use.

Declaration

getInfo(): DxDesigner.Analytics.Utils.ISerializationInfo[]

Returns

Type
DxDesigner.Analytics.Utils.ISerializationInfo[]