dashboard-js-devexpress-dot-dashboard-dot-model.md
A Chart dashboard item that visualizes data in an XY-diagram.
export class ChartItem extends ChartItemBase
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.
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();
}
SerializableModel TypedSerializableModel DashboardItem DataDashboardItem SeriesItem ChartItemBase ChartItem
Initializes a new instance of the ChartItem class.
constructor(
dashboardItemJSON?: any,
serializer?: DevExpress.Analytics.Utils.ModelSerializer
)
| Name | Type | Description |
|---|---|---|
| dashboardItemJSON | any |
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.
|
axisX: DevExpress.Dashboard.Model.ChartAxisX
| Type |
|---|
| ChartAxisX |
indicators: ko.ObservableArray<DevExpress.Dashboard.Model.ChartIndicator>
| Type |
|---|
| ObservableArray<ChartIndicator> |
Provides access to a chart legend.
legend: DevExpress.Dashboard.Model.ChartLegend
| Type | Description |
|---|---|
| ChartLegend |
A ChartLegend object that represents a chart legend.
|
Specifies a collection of panes.
panes: ko.ObservableArray<DevExpress.Dashboard.Model.ChartPane>
| Type | Description |
|---|---|
| ObservableArray<ChartPane> |
A collection of ChartPane objects that represent panes.
|
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.
Specifies whether the chart is rotated.
rotated: ko.Observable<boolean>
| Type | Description |
|---|---|
| Observable<boolean> |
true , to rotate the chart; otherwise, false.
|
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.