Back to Devexpress

ChartItem Class

dashboard-js-devexpress-dot-dashboard-dot-model.md

latest9.9 KB
Original Source

ChartItem Class

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

Declaration

ts
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.

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.

javascript
// 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

arguments

colorScheme

coloringOptions

componentName

customProperties

dataItems

dataMember

dataSource

disposed

filterString

formatRules

hiddenDimensions

hiddenMeasures

interactivityOptions

isDisposed

isMasterFilterCrossDataSource

itemType

name

parentContainer

seriesDimensions

showCaption

visibleDataFilterString

dispose

getInfo

getUniqueNamePrefix

Inheritance

SerializableModel TypedSerializableModel DashboardItem DataDashboardItem SeriesItem ChartItemBase ChartItem

constructor

Initializes a new instance of the ChartItem class.

Declaration

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

Parameters

NameTypeDescription
dashboardItemJSONany

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

| | serializer | ModelSerializer |

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

|

Properties

axisX Property

Declaration

ts
axisX: DevExpress.Dashboard.Model.ChartAxisX

Property Value

Type
ChartAxisX

indicators Property

Declaration

ts
indicators: ko.ObservableArray<DevExpress.Dashboard.Model.ChartIndicator>

Property Value

Type
ObservableArray<ChartIndicator>

legend Property

Provides access to a chart legend.

Declaration

ts
legend: DevExpress.Dashboard.Model.ChartLegend

Property Value

TypeDescription
ChartLegend

A ChartLegend object that represents a chart legend.

|

panes Property

Specifies a collection of panes.

Declaration

ts
panes: ko.ObservableArray<DevExpress.Dashboard.Model.ChartPane>

Property Value

TypeDescription
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

ts
rotated: ko.Observable<boolean>

Property Value

TypeDescription
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.