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({
});

                    

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the Chart widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

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>
import { DxChartModule } from 'devextreme-angular';
// ...
export class AppComponent {
    fruits = [
        { fruit: 'Oranges', yield: 10, consumed: 7 },
        { fruit: 'Apples', yield: 15, consumed: 14 },
        { fruit: 'Bananas', yield: 9, consumed: 9 }  
    ];
}
@NgModule({
    imports: [
        // ...
        DxChartModule
    ],
    // ...
})
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(new[] {
        new { Fruit = "Oranges", Yield = 10, Consumed = 7 },
        new { Fruit = "Apples", Yield = 15, Consumed = 14 },
        new { Fruit = "Bananas", Yield = 9, Consumed = 9 }
    })
    .CommonSeriesSettings(c => c
        .ArgumentField("Fruit")
        .Type(SeriesType.Bar)
    )
    .Series(series => {
        series.Add().ValueField("Yield");
        series.Add().ValueField("Consumed");
    })
)
@(Html.DevExtreme().Chart() _
    .ID("chart") _
    .DataSource({
        New With { .Fruit = "Oranges", .Yield = 10, .Consumed = 7 },
        New With { .Fruit = "Apples", .Yield = 15, .Consumed = 14 },
        New With { .Fruit = "Bananas", .Yield = 9, .Consumed = 9 }
    }) _
    .CommonSeriesSettings(Sub(c)
        c.ArgumentField("Fruit") _
            .Type(SeriesType.Bar)
    End Sub) _
    .Series(Sub(series)
        series.Add().ValueField("Yield")
        series.Add().ValueField("Consumed")
    End Sub)
)

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.

Type:

Object

Chart Elements

This section describes chart elements.