Your search did not match any results.
Pie Charts

Palette

The PieChart, like other DevExtreme Data Visualization components, allows you to apply multiple predefined palettes. In this demo, you can use two drop-down menus under the PieChart to choose a palette and change the way it is extended when the number of colors is insufficient to paint each series point differently.

Specify a Palette

A palette is a set of colors that mix well with each other. To apply the needed color scheme, you can assign it to the palette property. It accepts either the name of a predefined palette or an array of colors. In this demo, you can use the "Palette" selector to apply a new set of colors.

Extend a Palette

When the number of palette colors is less than the number of series points, you can use the paletteExtensionMode property to specify how to extend the palette. This property can accept one of the following values:

  • "blend"
    Create a blend of two neighboring colors and insert it between these colors in the palette.

  • "alternate"
    Repeat the full set of palette colors, alternating their normal, lightened, and darkened shades in that order.

  • "extrapolate"
    Repeat the full set of palette colors, changing their shade gradually from dark to light.

In this demo, you can use the "Palette Extension Mode" selector to apply one of these modes.

Backend API
Copy to CodePen
Apply
Reset
window.onload = function () { const palette = ko.observable(paletteCollection[0]); const paletteExtensionMode = ko.observable('Blend'); const viewModel = { chartOptions: { palette, dataSource, series: {}, paletteExtensionMode, legend: { visible: false, }, }, paletteSelectBoxOptions: { items: paletteCollection, value: palette, }, extensionModeSelectBoxOptions: { items: paletteExtensionModes, value: paletteExtensionMode, }, baseColors: ko.computed(() => DevExpress.viz.getPalette(palette()).simpleSet), }; ko.applyBindings(viewModel, document.getElementById('chart-demo')); };
<!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> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.2.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/22.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"> <div id="chart-demo"> <div class="flex-container"> <div id="pie" class="flex-block" data-bind="dxPieChart: chartOptions"></div> <div class="palette-container flex-block" data-bind="foreach: {data: baseColors, as: 'color'}"> <div class="palette-item" data-bind="style: {backgroundColor: color}"></div> </div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <span>Palette</span> <div data-bind="dxSelectBox: paletteSelectBoxOptions"></div> </div> <div class="option"> <span>Palette Extension Mode</span> <div data-bind="dxSelectBox: 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; }
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, }); }