DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Vue Charts - Bar Color Customization

The Chart assigns one color to one series. To color bars differently, create a separate series for each bar.

Assign the age field to the argumentField property of the commonSeriesSettings object to specify a common argument for the series. Then specify the valueField property.

Choose a data field and assign it to the seriesTemplate.nameField property. Each value from this data field generates a separate series.

To learn more about this type of data binding, refer to the following demo: Dynamic Series from the DataSource.

Backend API
<template> <DxChart id="chart" :data-source="dataSource" palette="Soft" > <DxCommonSeriesSettings :ignore-empty-points="true" argument-field="age" value-field="number" type="bar" /> <DxSeriesTemplate name-field="age"/> <DxTitle text="Age Breakdown of Facebook Users in the U.S." subtitle="as of January 2024" /> </DxChart> </template> <script setup lang="ts"> import { DxChart, DxSeriesTemplate, DxCommonSeriesSettings, DxTitle, } from 'devextreme-vue/chart'; import { dataSource } from './data.ts'; </script> <style> #chart { height: 440px; } </style>
export const dataSource = [ { age: '13-17', number: 6869661 }, { age: '18-24', number: 40277957 }, { age: '25-34', number: 53481235 }, { age: '35-44', number: 40890002 }, { age: '45-54', number: 31916371 }, { age: '55-64', number: 13725406 }, { age: '65+', number: 16732183 }, ];
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app');
<!DOCTYPE html> <html lang="en"> <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=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="./bundle.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> </div> </div> <script src="bundles/vendor/vue.vendor.js"></script> <script src="./bundle.js"></script> </body> </html>