Chart

The Chart is a widget that visualizes data from a local or remote storage using a great variety of series types along with different interactive elements, such as tooltips, crosshair pointer, legend, etc.

Included in: dx.viz.js, dx.viz-web.js, dx.all.js
Module: viz/chart
Export: default
Chart interactive configuration
Copy Code
Copy to Codepen
$("#chart").dxChart({
});

You can create the Chart widget using one of the following approaches.

jQuery
JavaScript
HTML
var fruits = [
    { fruit: 'Oranges', yield: 10, consumed: 7 },
    { fruit: 'Apples', yield: 15, consumed: 14 },
    { fruit: 'Bananas', yield: 9, consumed: 9 }
];
$(function() {
    $("#chart").dxChart({
        dataSource: fruits,
        commonSeriesSettings: {
            argumentField: "fruit",
            type: "bar"
        },
        series: [
            { valueField: "yield" },
            { valueField: "consumed" }
        ]
    });
});
<div id="chart"></div>
Angular
HTML
TypeScript
<dx-chart [dataSource]="fruits">
    <dxo-common-series-settings
        argumentField="fruit"
        type="bar">
    </dxo-common-series-settings>
    <dxi-series valueField="yield"></dxi-series>
    <dxi-series valueField="consumed"></dxi-series>
</dx-chart>
export class AppComponent {
    fruits = [
        { fruit: 'Oranges', yield: 10, consumed: 7 },
        { fruit: 'Apples', yield: 15, consumed: 14 },
        { fruit: 'Bananas', yield: 9, consumed: 9 }  
    ];
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-chart="{
        dataSource: fruits,
        commonSeriesSettings: {
            argumentField: 'fruit',
            type: 'bar'
        },
        series: [
            { valueField: 'yield' },
            { valueField: 'consumed' }
        ]
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.fruits = [
            { fruit: 'Oranges', yield: 10, consumed: 7 },
            { fruit: 'Apples', yield: 15, consumed: 14 },
            { fruit: 'Bananas', yield: 9, consumed: 9 } 
        ];
    });
Knockout
HTML
JavaScript
<div data-bind="dxChart: {
    dataSource: fruits,
    commonSeriesSettings: {
        argumentField: 'fruit',
        type: 'bar'
    },
    series: [
        { valueField: 'yield' },
        { valueField: 'consumed' }
    ]
}"></div>
var viewModel = {
    fruits: [
        { fruit: 'Oranges', yield: 10, consumed: 7 },
        { fruit: 'Apples', yield: 15, consumed: 14 },
        { fruit: 'Bananas', yield: 9, consumed: 9 }
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Chart()
    .ID("chart")
    .DataSource(Fruits)
    .CommonSeriesSettings(c => c
        .ArgumentField("fruit")
        .Type(SeriesType.Bar)
    )
    .Series(series => {
        series.Add().ValueField("yield");
        series.Add().ValueField("consumed");
    })
)
@(Html.DevExtreme().Chart() _
    .ID("chart") _
    .DataSource(Fruits) _
    .CommonSeriesSettings(Sub(c)
        c.ArgumentField("fruit") _
            .Type(SeriesType.Bar)
    End Sub) _
    .Series(Sub(series)
        series.Add().ValueField("yield")
        series.Add().ValueField("consumed")
    End Sub)
)

All DevExtreme widgets require linking the jQuery library. Linking the Knockout or AngularJS library is optional. For detailed information on how to link the needed libraries, refer to the topics in the Installation section.

View Demo

See Also

Configuration

This section describes properties that configure the contents, behavior and appearance of the Chart widget.

Methods

This section describes the methods that can be used in code to manipulate the widget.

See Also

Events

This section describes events fired by this widget.

See Also

Series Types

This section lists objects that define options used to configure series of specific types.

Chart Elements

This section describes chart elements.