corelibraries-devexpress-dot-xtracharts-dot-seriesviewbase.md
Gets or sets the Series Point Colorizer that paints series points.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)]
public IColorizer Colorizer { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)>
Public Property Colorizer As IColorizer
| Type | Description |
|---|---|
| IColorizer |
A colorizer that implements the IColorizer interface.
|
You can use the following colorizers to specify the Colorizer property:
The Chart Control also provides Segment Colorizers for line and area series views.
To use the Range Colorizer, perform the following steps:
Create a RangeColorizer object and assign it to the SeriesViewBase.Colorizer property.
Populate the RangeColorizer.RangeStops collection.
Specify the ChartPaletteColorizerBase.Palette property if you want to use a non-default palette to colorize the chart.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Xml.Linq;
using DevExpress.XtraCharts;
namespace RangeColorizerExample {
public partial class Form1 : Form {
const string filepath = @"..//..//Data//HPI.xml";
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
#region #BarSeries
// Create and customize a bar series.
Series barSeries = new Series() {
DataSource = LoadData(filepath),
ArgumentDataMember = "Country",
ColorDataMember = "Hpi",
View = new SideBySideBarSeriesView()
};
barSeries.View.Colorizer = CreateColorizer();
barSeries.ValueDataMembers.AddRange(new string[] { "Product" });
#endregion #BarSeries
// Add the series to the ChartControl's Series collection.
chartControl1.Series.Add(barSeries);
// Show a title for the values axis.
((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "GDP per capita, $";
((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
}
#region #RangeColorizer
// Creates a range colorizer.
ChartColorizerBase CreateColorizer() {
Palette palette = new Palette("Custom");
palette.Add(Color.FromArgb(255, 255, 90, 25), Color.FromArgb(255, 255, 90, 25));
palette.Add(Color.FromArgb(255, 229, 227, 53), Color.FromArgb(255, 229, 227, 53));
palette.Add(Color.FromArgb(255, 110, 201, 92), Color.FromArgb(255, 110, 201, 92));
RangeColorizer colorizer = new RangeColorizer() {
LegendItemPattern = "{V1} - {V2} HPI",
Palette = palette
};
colorizer.RangeStops.AddRange(new double[] { 22, 30, 38, 46, 54, 64 });
return colorizer;
}
#endregion #RangeColorizer
#region #DataLoad
class HpiPoint {
public string Country { get; set; }
public double Product { get; set; }
public double Hpi { get; set; }
}
// Loads data from an XML data source.
static List<HpiPoint> LoadData(string filepath) {
XDocument doc = XDocument.Load(filepath);
List<HpiPoint> points = new List<HpiPoint>();
foreach (XElement element in doc.Element("G20HPIs").Elements("CountryStatistics")) {
points.Add(new HpiPoint() {
Country = element.Element("Country").Value,
Product = Convert.ToDouble(element.Element("Product").Value),
Hpi = Convert.ToDouble(element.Element("HPI").Value),
});
}
return points;
}
#endregion #DataLoad
}
}
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Xml.Linq
Imports DevExpress.XtraCharts
Namespace RangeColorizerExample
Partial Public Class Form1
Inherits Form
Private Const filepath As String = "..//..//Data//HPI.xml"
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
' #Region "#BarSeries"
' Create and customize a bar series.
Dim barSeries As New Series() With {
.DataSource = LoadData(filepath),
.ArgumentDataMember = "Country",
.ColorDataMember = "Hpi",
.View = New SideBySideBarSeriesView()
}
barSeries.View.Colorizer = CreateColorizer()
barSeries.ValueDataMembers.AddRange(New String() { "Product" })
' #End Region ' #BarSeries
' Add the series to the ChartControl's Series collection.
chartControl1.Series.Add(barSeries)
' Show a title for the values axis.
CType(chartControl1.Diagram, XYDiagram).AxisY.Title.Text = "GDP per capita, $"
CType(chartControl1.Diagram, XYDiagram).AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True
End Sub
#Region "#RangeColorizer"
' Creates a range colorizer.
Private Function CreateColorizer() As ChartColorizerBase
Dim palette As New Palette("Custom")
palette.Add(Color.FromArgb(255, 255, 90, 25), Color.FromArgb(255, 255, 90, 25))
palette.Add(Color.FromArgb(255, 229, 227, 53), Color.FromArgb(255, 229, 227, 53))
palette.Add(Color.FromArgb(255, 110, 201, 92), Color.FromArgb(255, 110, 201, 92))
Dim colorizer As New RangeColorizer() With {.LegendItemPattern = "{V1} - {V2} HPI", .Palette = palette}
colorizer.RangeStops.AddRange(New Double() { 22, 30, 38, 46, 54, 64 })
Return colorizer
End Function
#End Region ' #RangeColorizer
#Region "#DataLoad"
Private Class HpiPoint
Public Property Country() As String
Public Property Product() As Double
Public Property Hpi() As Double
End Class
' Loads data from an XML data source.
Private Shared Function LoadData(ByVal filepath As String) As List(Of HpiPoint)
Dim doc As XDocument = XDocument.Load(filepath)
Dim points As New List(Of HpiPoint)()
For Each element As XElement In doc.Element("G20HPIs").Elements("CountryStatistics")
points.Add(New HpiPoint() With {.Country = element.Element("Country").Value, .Product = Convert.ToDouble(element.Element("Product").Value), .Hpi = Convert.ToDouble(element.Element("HPI").Value)})
Next element
Return points
End Function
#End Region ' #DataLoad
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the Colorizer property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-charts-create-model-for-custom-chart-element/CS/CustomChartElementModel/Form1.cs#L113
view.Colorizer = new CustomPointColorizer() {
Value = 60,
};
barSeries.View.Colorizer = new ColorObjectColorizer();
barSeries.ValueDataMembers.AddRange(new string[] { "Product" });
winforms-charts-create-model-for-custom-chart-element/VB/CustomChartElementModel/Form1.vb#L178
Dim view As SideBySideBarSeriesView = CType(series.View, SideBySideBarSeriesView)
view.Colorizer = New CustomPointColorizer() With {.Value = 60, .LowerValuePointColor = Color.Red, .UpperValuePointColor = Color.Green}
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True
Dim barSeries As Series = New Series() With {.DataSource = LoadData(filepath), .ArgumentDataMember = "Country", .ColorDataMember = "NationalColor", .View = New SideBySideBarSeriesView()}
barSeries.View.Colorizer = New ColorObjectColorizer()
barSeries.ValueDataMembers.AddRange(New String() {"Product"})
See Also