Your search did not match any results.
Bar Charts

Customize Points and Labels

This demo shows how you can customize individual points and labels in the Chart component.

Customize Points

Use the customizePoint function to change the appearance of individual series points. This function should return an object with properties that you want to change in a point configuration. This demo uses this function to color all points with values above the "High Average" in red, and points with values below the "Low Average" in blue.

Customize Labels

To customize the appearance of individual point labels, implement the customizeLabel function. This function should also return an object with properties that need to be changed for a certain label. This demo specifies custom labels for the red points.

Create Constant Lines

To create constant lines, follow the steps below:

  1. Choose a direction for the line. You can specify horizontal lines in the valueAxis object, and vertical - in the argumentAxis object.

  2. Specify the constantLines object. In this object, declare an object for each line with the properties you want to change.

Note that it's necessary to specify the value property for the line to display correctly.

Backend API
Copy to CodePen
Apply
Reset
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { const highAverage = 77; const lowAverage = 58; $scope.chartOptions = { dataSource, customizePoint() { if (this.value > highAverage) { return { color: '#ff7c7c', hoverStyle: { color: '#ff7c7c' } }; } if (this.value < lowAverage) { return { color: '#8c8cff', hoverStyle: { color: '#8c8cff' } }; } return null; }, customizeLabel() { if (this.value > highAverage) { return { visible: true, backgroundColor: '#ff7c7c', customizeText() { return `${this.valueText}&#176F`; }, }; } return null; }, export: { enabled: true, }, valueAxis: { visualRange: { startValue: 40, }, maxValueMargin: 0.01, label: { customizeText() { return `${this.valueText}&#176F`; }, }, constantLines: [{ label: { text: 'Low Average', }, width: 2, value: lowAverage, color: '#8c8cff', dashStyle: 'dash', }, { label: { text: 'High Average', }, width: 2, value: highAverage, color: '#ff7c7c', dashStyle: 'dash', }], }, series: [{ argumentField: 'day', valueField: 'temperature', type: 'bar', color: '#e7d19a', }], title: { text: 'Daily Temperature in May', }, legend: { visible: false, }, }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.4/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.4/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/22.1.4/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div id="chart" dx-chart="chartOptions"></div> </div> </body> </html>
#chart { height: 440px; }
const dataSource = [{ day: '1', temperature: 57, }, { day: '2', temperature: 58, }, { day: '3', temperature: 57, }, { day: '4', temperature: 59, }, { day: '5', temperature: 63, }, { day: '6', temperature: 63, }, { day: '7', temperature: 63, }, { day: '8', temperature: 64, }, { day: '9', temperature: 64, }, { day: '10', temperature: 64, }, { day: '11', temperature: 69, }, { day: '12', temperature: 72, }, { day: '13', temperature: 75, }, { day: '14', temperature: 78, }, { day: '15', temperature: 76, }, { day: '16', temperature: 70, }, { day: '17', temperature: 65, }, { day: '18', temperature: 65, }, { day: '19', temperature: 68, }, { day: '20', temperature: 70, }, { day: '21', temperature: 73, }, { day: '22', temperature: 73, }, { day: '23', temperature: 75, }, { day: '24', temperature: 78, }, { day: '25', temperature: 76, }, { day: '26', temperature: 76, }, { day: '27', temperature: 80, }, { day: '28', temperature: 76, }, { day: '29', temperature: 75, }, { day: '30', temperature: 75, }, { day: '31', temperature: 74, }];