Chart

The dxChart 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.chartjs.js, dx.all.js
Chart interactive configuration
Copy Code
Copy to Codepen
$("#chart").dxChart({
});

                    

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

  • jQuery
    Use the dxChart jQuery plug-in.

    HTML
    <div id="chartContainer"></div>
    JavaScript
    $("#chartContainer").dxChart({
        dataSource: dataSource,
        commonSeriesSettings: {
            argumentField: "state",
            type: "bar"
        },
        series: [
            { valueField: "year2004", name: "2004" },
            { valueField: "year2001", name: "2001" },
            { valueField: "year1998", name: "1998" }
        ]
    });
  • Knockout
    Add a div element and apply the dxChart binding to this element.

    HTML
    <div data-bind="dxChart: {
        dataSource: dataSource,
        commonSeriesSettings: {
            argumentField: 'state',
            type: 'bar'
        },
        series: [
            { valueField: 'year2004', name: '2004' },
            { valueField: 'year2001', name: '2001' },
            { valueField: 'year1998', name: '1998' }
        ]
    }"></div>
  • AngularJS
    Add a div element and apply the dx-chart directive to this element.

    HTML
    <div dx-chart="{
        dataSource: dataSource,
        commonSeriesSettings: {
            argumentField: 'state',
            type: 'bar'
        },
        series: [
            { valueField: 'year2004', name: '2004' },
            { valueField: 'year2001', name: '2001' },
            { valueField: 'year1998', name: '1998' }
        ]
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on how to link the needed libraries, refer to the Installation article.

To learn how to provide data for the dxChart widget, refer to the Data Binding article.

The dxChart widget contains multiple visual elements (axes, titles, labels, strips, grid, etc.) that are configured within the widget's configuration object. To learn more about the widget's visual elements, refer to the Chart Elements help article.

View Demo Watch Video

See Also

To learn the widget's concepts and overview features, refer to the Charts section within the Data Visualization Guides.

Configuration

An object defining configuration options for the dxChart widget.

Name Description
adaptiveLayout

Specifies adaptive layout options.

adjustOnZoom

Indicates whether or not to adjust a value axis to the current minimum and maximum values of a zoomed chart.

animation

Specifies animation options.

argumentAxis

Specifies argument axis options for the dxChart widget.

barWidth

Specifies a common bar width as a percentage from 0 to 1.

commonAxisSettings

An object defining the configuration options that are common for all axes of the dxChart widget.

commonPaneSettings

An object defining the configuration options that are common for all panes in the dxChart widget.

commonSeriesSettings

An object defining the configuration options that are common for all series of the dxChart widget.

containerBackgroundColor

Specifies the color of the parent page element.

crosshair

An object that specifies the appearance options of the chart crosshair.

customizeLabel

Specifies a callback function that returns an object with options for a specific point label.

customizePoint

Specifies a callback function that returns an object with options for a specific point.

dataPrepareSettings

An object providing options for managing data from a data source.

dataSource

Specifies a data source for the chart.

defaultPane

Specifies a default pane for the chart series.

equalBarWidth

Specifies whether all bars in a series must have the same width, or may have different widths if any points in other series are missing.

legend

Specifies the options of a chart's legend.

loadingIndicator

Specifies the appearance of the loading indicator.

margin

Specifies the blank space between the chart's extreme elements and the boundaries of the area provided for the widget (see size) in pixels.

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.

onDone

A handler for the done event.

onDrawn

A handler for the drawn event.

onIncidentOccurred

A handler for the incidentOccurred event.

onInitialized

A handler for the initialized event.

onLegendClick

A handler for the legendClick event.

onOptionChanged

A handler for the optionChanged event.

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.

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

Defines the dxChart widget's pane(s).

pathModified

Notifies a widget that it is embedded into an HTML page that uses a path modifier.

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 round so that the value axis becomes horizontal and the argument axes becomes 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 dxChart 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 a title for the chart.

tooltip

Specifies tooltip options.

useAggregation

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

valueAxis

Specifies value axis options for the dxChart widget.

zoomingMode

Enables zooming in your chart.

Methods

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

Name Description
beginUpdate()

Prevents the component from refreshing until the endUpdate method is called.

clearSelection()

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

element()

Returns the root HTML element of the widget.

endUpdate()

Enables the component to refresh after the beginUpdate method call.

getAllSeries()

Returns an array of all series in the chart.

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 an instance of this component class.

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()

Returns the configuration options of this component.

option(optionName)

Gets the value of the specified configuration option of this component.

option(optionName, optionValue)

Sets a value to the specified configuration option of this component.

option(options)

Sets one or more options of this component.

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.

Use the dxChart registered method to access the dxChart object as demonstrated in the code below.

JavaScript
var chart = $("#chartContainer").dxChart("instance");

Events

This section describes events fired by this widget.

Name Description
argumentAxisClick

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

disposing

Fires when the widget is being removed.

done

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

drawn

Fires when the widget has finished drawing itself.

incidentOccurred

Fires when an error or warning appears in a widget.

initialized

Fires when the widget is initialized.

legendClick

Fires when an item on the chart legend is clicked.

optionChanged

Fires after an option of the component 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.

Series Types

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

Chart Elements

This section lists the methods and fields of chart elements.