Your search did not match any results.
Pie Charts

Palette

Documentation

The PieChart, like other DevExtreme Data Visualization JavaScript components, provides several built-in palettes. In this demo, you can use the drop-down menus under the PieChart to choose a palette and change how it is extended when it has an insufficient number of colors.

Backend API
Copy to CodePen
Apply
Reset
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { $scope.palette = paletteCollection[0]; $scope.paletteExtensionMode = 'Blend'; $scope.baseColors = []; $scope.chartOptions = { dataSource, series: {}, legend: { visible: false, }, bindingOptions: { palette: 'palette', paletteExtensionMode: 'paletteExtensionMode', }, onDrawn(e) { const paletteName = e.component.option('palette'); const palette = DevExpress.viz.getPalette(paletteName).simpleSet; $scope.baseColors = palette; }, }; $scope.paletteSelectBoxOptions = { items: paletteCollection, bindingOptions: { value: 'palette', }, }; $scope.extensionModeSelectBoxOptions = { items: paletteExtensionModes, bindingOptions: { value: 'paletteExtensionMode', }, }; });
<!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/21.2.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.2.3/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/21.2.3/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 class="flex-container"> <div id="pie" class="flex-block" dx-pie-chart="chartOptions"></div> <div class="palette-container flex-block"> <div class="palette-item" ng-repeat="(index, color) in baseColors" ng-style="{'background-color': color}"></div> </div> </div> <div class="options"> <div class="caption">Options</div> <div class="options-container"> <div class="option"> <span>Palette</span> <div dx-select-box="paletteSelectBoxOptions"></div> </div> <div class="option"> <span>Palette Extension Mode</span> <div dx-select-box="extensionModeSelectBoxOptions"></div> </div> </div> </div> </div> </body> </html>
.flex-container { display: flex; justify-content: center; align-items: center; flex-direction: row; } #pie { height: 350px; width: 500px; margin: 20px; } .palette-container { float: left; } .palette-item { width: 40px; height: 40px; } .options { padding: 20px; background-color: rgba(191, 191, 191, 0.15); margin-top: 20px; } .caption { font-size: 18px; font-weight: 500; } .option { display: inline-block; min-width: 320px; margin-top: 5px; } .option > span { margin: 0 10px 0 0; } .option > .dx-widget { display: inline-block; vertical-align: middle; } .options-container { display: flex; align-items: center; } .options-container > .option { display: flex; align-items: baseline; }
const paletteCollection = ['Material', 'Soft Pastel', 'Harmony Light', 'Pastel', 'Bright', 'Soft', 'Ocean', 'Office', 'Vintage', 'Violet', 'Carmine', 'Dark Moon', 'Soft Blue', 'Dark Violet', 'Green Mist']; const paletteExtensionModes = ['Alternate', 'Blend', 'Extrapolate']; const dataSource = []; let i; for (i = 0; i < 20; i += 1) { dataSource.push({ arg: `item${i}`, val: 1, }); }