Skip to main content

RangeColorizer3D Class

Colorizer that colors all points by values.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v24.2.dll

NuGet Package: DevExpress.Wpf.Charts

Declaration

public class RangeColorizer3D :
    PaletteColorizer3DBase

Remarks

The following image demonstrates 3D bars colored using this colorizer.

KeyColorColorizer3D-Example

Use the following properties to configure the RangeColorizer3D:

Example

This example demonstrates how to colorize series point markers based on range values. To do this, assign a RangeColorizer3D object to the Series3DViewBase.Colorizer property. Then, configure range stops using the RangeColorizer3D.RangeStops property and optionally, configure required colors using the PaletteColorizer3DBase.Palette property.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:view="clr-namespace:RangeColorizer3DExample"
        xmlns:viewModel="clr-namespace:RangeColorizer3DExample.ViewModel"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
        x:Class="RangeColorizer3DExample.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow"
        Height="309"
        Width="496">
    <Window.DataContext>
        <viewModel:GdpViewModel />
    </Window.DataContext>
    <Grid>

        <dxc:Chart3DControl AspectRatio="5,3,3"
                            Padding="0">
            <dxc:Chart3DControl.Legends>
                <dxc:Legend HorizontalPosition="Right"
                            VerticalPosition="Top"
                            Orientation="Horizontal"/>
            </dxc:Chart3DControl.Legends>
            <dxc:Series3DStorage>
                <!--region #Series-->
                <dxc:Series3D DisplayName="Gdps"
                              YArgumentScaleType="Qualitative">
                    <dxc:Series3D.View>
                        <dxc:Bar3DSeriesView>
                            <dxc:Bar3DSeriesView.Colorizer>
                                <dxc:RangeColorizer3D ApproximateColors="True"
                                                      RangeStops="2000 4000 8000 16000 32000">
                                    <dxc:RangeColorizer3D.Palette>
                                        <dxc:CustomPalette>
                                            <dxc:CustomPalette.Colors>
                                                <Color>#FD5915</Color>
                                                <Color>#F09D25</Color>
                                                <Color>#E2E232</Color>
                                                <Color>#A5D648</Color>
                                                <Color>#6EC95C</Color>
                                            </dxc:CustomPalette.Colors>
                                        </dxc:CustomPalette>
                                    </dxc:RangeColorizer3D.Palette>
                                </dxc:RangeColorizer3D>
                            </dxc:Bar3DSeriesView.Colorizer>
                            <dxc:Bar3DSeriesView.BarModel>
                                <dxc:Bar3DBoxPointModel ShowFacets="False" />
                            </dxc:Bar3DSeriesView.BarModel>
                        </dxc:Bar3DSeriesView>
                    </dxc:Series3D.View>
                    <dxc:SeriesPoint3DDataSourceAdapter DataSource="{Binding Path=Gdps}"
                                                        XArgumentDataMember="Country"
                                                        YArgumentDataMember="Year"
                                                        ValueDataMember="Value"/>
                </dxc:Series3D>
                <!--endregion #Series-->
            </dxc:Series3DStorage>
        </dxc:Chart3DControl>

    </Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Resources;
using System.Xml.Linq;

namespace RangeColorizer3DExample.ViewModel {
    public class Gdp {
        public string Country { get; private set; }
        public int Year { get; private set; }
        public double Value { get; private set; }
        public string Region { get; private set; }

        public Gdp(string country, int year, double value, string region) {
            Country = country;
            Year = year;
            Value = value;
            Region = region;
        }
    }

    public class GdpViewModel {
        public IEnumerable<Gdp> Gdps { get; private set; }

        public GdpViewModel() {
            Gdps = new GdpResourceLoader("Data/GdpStatistics.xml").Load();
        }
    }

    public class GdpResourceLoader {
        string Filepath { get; set; }

        public GdpResourceLoader(string filepath) {
            Filepath = filepath;
        }

        public IEnumerable<Gdp> Load() {
            Collection<Gdp> result = new Collection<Gdp>();

            Uri resourceUri = new Uri(Filepath, UriKind.RelativeOrAbsolute);
            StreamResourceInfo resourceInfo = Application.GetResourceStream(resourceUri);
            XDocument xDoc = XDocument.Load(resourceInfo.Stream);
            foreach (var xGdp in xDoc.Element("Statistics").Elements("Gdp")) {
                result.Add(new Gdp(
                    country: xGdp.Attribute("Country").Value,
                    year: Convert.ToInt32(xGdp.Attribute("Year").Value),
                    value: Convert.ToDouble(xGdp.Attribute("Value").Value),
                    region: xGdp.Attribute("Region").Value
                ));
            }
            return result;
        }
    }
}
See Also