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.

Name Description
adaptiveLayout

Specifies adaptive layout options.

adjustOnZoom

Specifies whether or not to adjust the value axis when zooming the widget.

animation

Specifies animation options.

argumentAxis

Configures the argument axis.

barWidth

Controls the width of bars in the widget. Applies only to bar-like series and when the equalBarWidth option is true.

commonAxisSettings

Defines common settings for both the argument and value axis in a chart.

commonPaneSettings

Defines common settings for all panes in a chart.

commonSeriesSettings

Specifies settings common for all series in the chart.

containerBackgroundColor

Colors the background of the chart container.

crosshair

Configures the crosshair feature.

customizeLabel

Customizes the appearance of an individual point label.

customizePoint

Customizes the appearance of an individual series point.

dataPrepareSettings

Processes data before visualizing it.

dataSource

Specifies the origin of data for the widget.

defaultPane

Specifies which pane should be used by default.

elementAttr

Specifies the attributes to be attached to the widget's root element.

equalBarWidth

Specifies whether all bars should have equal width, even if some values are missing from a series. Applies only to bar-like series.

export

Configures the exporting and printing features.

legend

Specifies the options of a chart's legend.

loadingIndicator

Configures the loading indicator.

margin

Generates space around the widget.

maxBubbleSize

Specifies a coefficient determining the diameter of the largest bubble.

minBubbleSize

Specifies the diameter of the smallest bubble measured in pixels.

negativesAsZeroes

Forces the widget to treat negative values as zeroes. Applies to stacked-like series only.

onArgumentAxisClick

A handler for the argumentAxisClick event.

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

onDone

A handler for the done event.

onDrawn

A handler for the drawn event.

onExported

A handler for the exported event.

onExporting

A handler for the exporting event.

onFileSaving

A handler for the fileSaving event.

onIncidentOccurred

A handler for the incidentOccurred event.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

onLegendClick

A handler for the legendClick event.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

onPointClick

A handler for the pointClick event.

onPointHoverChanged

A handler for the pointHoverChanged event.

onPointSelectionChanged

A handler for the pointSelectionChanged event.

onSeriesClick

A handler for the seriesClick event.

onSeriesHoverChanged

A handler for the seriesHoverChanged event.

onSeriesSelectionChanged

A handler for the seriesSelectionChanged event.

onTooltipHidden

A handler for the tooltipHidden event.

onTooltipShown

A handler for the tooltipShown event.

onZoomEnd

A handler for the zoomEnd event.

onZoomStart

A handler for the zoomStart event.

palette

Sets the name of the palette to be used in the chart. Alternatively, an array of colors can be set as a custom palette to be used within this chart.

panes

Declares a collection of panes.

pathModified

Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path.

pointSelectionMode

Specifies whether a single point or multiple points can be selected in the chart.

redrawOnResize

Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates.

resolveLabelOverlapping

Specifies how the chart must behave when series point labels overlap.

rotated

Swaps the axes around making the value axis horizontal and the argument axis vertical.

rtlEnabled

Specifies whether or not the widget supports right-to-left representation.

scrollBar

Specifies the settings of the scroll bar.

scrollingMode

Enables scrolling in your chart.

series

Specifies options for Chart widget series.

seriesSelectionMode

Specifies whether a single series or multiple series can be selected in the chart.

seriesTemplate

Defines options for the series template.

size

Specifies the size of the widget in pixels.

synchronizeMultiAxes

Indicates whether or not to synchronize value axes when they are displayed on a single pane.

theme

Sets the name of the theme to be used in the widget.

title

Specifies the widget title.

tooltip

Configures tooltips.

useAggregation

Specifies whether or not to filter the series points depending on their quantity.

valueAxis

Configures the value axis.

zoomingMode

Enables zooming in your chart.

Methods

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

Name Description
beginUpdate()

Prevents the widget from refreshing until the endUpdate() method is called.

clearSelection()

Deselects the chart's selected series. The series is displayed in an initial style.

element()

Gets the root element of the widget.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

exportTo(fileName, format)

Exports the widget into a document with a specified name and format.

getAllSeries()

Returns an array of all series in the chart.

getDataSource()

Returns the DataSource instance.

getSeriesByName(seriesName)

Gets a series within the chart's series collection by the specified name (see the name option).

getSeriesByPos(seriesIndex)

Gets a series within the chart's series collection by its position number.

getSize()

Gets the current size of the widget.

hideLoadingIndicator()

Conceals the loading indicator.

hideTooltip()

Hides all widget tooltips.

instance()

Returns this widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from the specified event.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

on(eventName, eventHandler)

Subscribes to a specified event.

on(events)

Subscribes to the specified events.

option()

Gets the widget's options.

option(optionName)

Gets a specific option value.

option(optionName, optionValue)

Assigns a new value to a specific option.

option(options)

Sets one or more options.

print()

Opens the browser's print window.

render()

Redraws the widget.

render(renderOptions)

Redraws a widget.

showLoadingIndicator()

Displays the loading indicator.

svg()

Returns the widget's SVG markup.

zoomArgument(startValue, endValue)

Sets the specified start and end values for the chart's argument axis.

See Also

Events

This section describes events fired by this widget.

Name Description
argumentAxisClick

Fires when a user clicks a label on the argument axis.

disposing

Raised when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

done

Fires when the Series and Point chart elements are ready to be accessed.

drawn

Fires when the widget has finished drawing itself.

exported

Fires after data from the widget is exported.

exporting

Fires before data from the widget is exported.

fileSaving

Fires before a file with exported data is saved on the user's local storage.

incidentOccurred

Fires when an error or warning appears in a widget.

initialized

Raised only once, after the widget is initialized.

legendClick

Fires when an item on the chart legend is clicked.

optionChanged

Raised after an option of the widget is changed.

pointClick

Fires when a user clicks a series point.

pointHoverChanged

Fires when the hover state of a series point has been changed.

pointSelectionChanged

Fires when the selection state of a series point has been changed.

seriesClick

Fires when a user clicks a series.

seriesHoverChanged

Fires when the hover state of a series has been changed.

seriesSelectionChanged

Fires when the selection state of a series has been changed.

tooltipHidden

Fires when a point's tooltip becomes hidden.

tooltipShown

Fires when a point's tooltip appears.

zoomEnd

Fires when zooming or scrolling ends.

zoomStart

Fires when zooming or scrolling begins.

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.