Back to Devexpress

RangeColorizer3D.RangeStops Property

wpf-devexpress-dot-xpf-dot-charts-dot-rangecolorizer3d-0f4cea03.md

latest9.7 KB
Original Source

RangeColorizer3D.RangeStops Property

Gets or sets the range stops of the colorizer.

Namespace : DevExpress.Xpf.Charts

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

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public DoubleCollection RangeStops { get; set; }
vb
Public Property RangeStops As DoubleCollection

Property Value

TypeDescription
DoubleCollection

The collection of value stops.

|

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.

xaml
<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>
csharp
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;
        }
    }
}
vb
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Windows
Imports System.Windows.Resources
Imports System.Xml.Linq

Namespace RangeColorizer3DExample.ViewModel
    Public Class Gdp
        Private privateCountry As String
        Public Property Country() As String
            Get
                Return privateCountry
            End Get
            Private Set(ByVal value As String)
                privateCountry = value
            End Set
        End Property
        Private privateYear As Integer
        Public Property Year() As Integer
            Get
                Return privateYear
            End Get
            Private Set(ByVal value As Integer)
                privateYear = value
            End Set
        End Property
        Private privateValue As Double
        Public Property Value() As Double
            Get
                Return privateValue
            End Get
            Private Set(ByVal value As Double)
                privateValue = value
            End Set
        End Property
        Private privateRegion As String
        Public Property Region() As String
            Get
                Return privateRegion
            End Get
            Private Set(ByVal value As String)
                privateRegion = value
            End Set
        End Property

        Public Sub New(ByVal country As String, ByVal year As Integer, ByVal value As Double, ByVal region As String)
            Me.Country = country
            Me.Year = year
            Me.Value = value
            Me.Region = region
        End Sub
    End Class

    Public Class GdpViewModel
        Private privateGdps As IEnumerable(Of Gdp)
        Public Property Gdps() As IEnumerable(Of Gdp)
            Get
                Return privateGdps
            End Get
            Private Set(ByVal value As IEnumerable(Of Gdp))
                privateGdps = value
            End Set
        End Property

        Public Sub New()
            Gdps = (New GdpResourceLoader("Data/GdpStatistics.xml")).Load()
        End Sub
    End Class

    Public Class GdpResourceLoader
        Private Property Filepath() As String

        Public Sub New(ByVal filepath As String)
            Me.Filepath = filepath
        End Sub

        Public Function Load() As IEnumerable(Of Gdp)
            Dim result As New Collection(Of Gdp)()

            Dim resourceUri As New Uri(Filepath, UriKind.RelativeOrAbsolute)
            Dim resourceInfo As StreamResourceInfo = Application.GetResourceStream(resourceUri)
            Dim xDoc As XDocument = XDocument.Load(resourceInfo.Stream)
            For Each 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))
            Next xGdp
            Return result
        End Function
    End Class
End Namespace

See Also

RangeColorizer3D Class

RangeColorizer3D Members

DevExpress.Xpf.Charts Namespace