Back to Devexpress

Segment Colorizers

windowsforms-400714-controls-and-libraries-chart-control-series-segment-colorizers.md

latest15.4 KB
Original Source

Segment Colorizers

  • Jul 11, 2025
  • 5 minutes to read

Segment Colorizers allow you to paint segments of the LineSeriesView, AreaSeriesView and their descendants.

Line Series View

Area Series View

Run Demo: Segment Colorizer

Overview

Segment colorizers only paint segments that form a line or area. Use the Series Point Colorizers to paint point markers.

You can use the Segment Colorizers with the following series views:

Follow the steps below to apply a segment colorizer to a series.

Trend Segment Colorizer

The Trend Segment colorizer changes a line/area’s color when a point value increases or decreases. You can specify the colors used to paint increasing and decreasing value segments.

The following code shows how to configure and apply the Trend Segment colorizer:

csharp
TrendSegmentColorizer colorizer = new TrendSegmentColorizer();
colorizer.FallingTrendColor = Color.RoyalBlue;
colorizer.RisingTrendColor = Color.Firebrick;
colorizer.FallingTrendLegendText = "Temperature Decrease";
colorizer.RisingTrendLegendText = "Temperature Rise";
colorizer.ShowInLegend = true;
LineSeriesView lineSeriesView = chartControl.Series[0].View as LineSeriesView;
lineSeriesView.SegmentColorizer = colorizer;
vb
Dim colorizer As TrendSegmentColorizer = New TrendSegmentColorizer
colorizer.FallingTrendColor = Color.RoyalBlue
colorizer.RisingTrendColor = Color.Firebrick
colorizer.FallingTrendLegendText = "Temperature Decrease"
colorizer.RisingTrendLegendText = "Temperature Rise"
colorizer.ShowInLegend = true
Dim lineSeriesView As LineSeriesView = CType(chartControl.Series(0).View,LineSeriesView)
lineSeriesView.SegmentColorizer = colorizer

The following table lists the related API members:

MemberDescription
TrendSegmentColorizerThe colorizer that changes a line‘s color when a point value increases or decreases.
TrendSegmentColorizer.FallingTrendColorGets or sets the color used to draw the falling value segments.
TrendSegmentColorizer.RisingTrendColorGets or sets the color used to draw the rising value segments.
TrendSegmentColorizer.FallingTrendLegendTextGets or sets the text the legend uses to identify the falling trend segments.
TrendSegmentColorizer.RisingTrendLegendTextGets or sets the text the legend uses to identify the rising trend segments.
LineSeriesView.SegmentColorizerGets or sets the colorizer that colors the line view segments.

Range Segment Colorizer

The Range Segment colorizer allows you to paint line/area segments based on their value range.

The following code shows how to configure and apply the Range Segment colorizer:

csharp
RangeSegmentColorizer colorizer = new RangeSegmentColorizer();
colorizer.RangeStops.AddRange(new double[] { -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30 });
colorizer.Palette = new Palette("TemperaturePalette", new PaletteEntry[] { new PaletteEntry(Color.DarkBlue),
                                                                           new PaletteEntry(Color.SteelBlue),
                                                                           new PaletteEntry(Color.LightBlue),
                                                                           new PaletteEntry(Color.Yellow),
                                                                           new PaletteEntry(Color.OrangeRed) });
// Alternatively, you can use PaletteName to specify a palette.
// colorizer.PaletteName = Palettes.Slipstream.DisplayName;
colorizer.ShowInLegend = true;
colorizer.LegendItemPattern = "{V1:F0}°C — {V2:F0}°C";
LineSeriesView lineSeriesView = chartControl.Series[0].View as LineSeriesView;
lineSeriesView.SegmentColorizer = colorizer;
vb
Dim colorizer As RangeSegmentColorizer = New RangeSegmentColorizer
colorizer.RangeStops.AddRange(New Double() {-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30})
colorizer.Palette = New Palette("TemperaturePalette", New PaletteEntry() { New PaletteEntry(Color.DarkBlue), 
                                                                           New PaletteEntry(Color.SteelBlue), 
                                                                           New PaletteEntry(Color.LightBlue), 
                                                                           New PaletteEntry(Color.Yellow), 
                                                                           New PaletteEntry(Color.OrangeRed)})
' Alternatively, you can use PaletteName to specify a palette.  
' colorizer.PaletteName = Palettes.Slipstream.DisplayName                                                                         
colorizer.ShowInLegend = true
colorizer.LegendItemPattern = "{V1:F0}°C — {V2:F0}°C"
Dim lineSeriesView As LineSeriesView = CType(chartControl.Series(0).View,LineSeriesView)
lineSeriesView.SegmentColorizer = colorizer

The following table lists the related API members:

MemberDescription
RangeSegmentColorizerThe colorizer that allows you to color a line segment based on a its value range.
RangeSegmentColorizer.RangeStopsProvides access to the collection of double values that define color range boundaries.
RangeSegmentColorizer.PaletteGets or sets the palette that provides colors for the colorizer.
RangeSegmentColorizer.PaletteNameGets or sets a name of the palette that provides colors for the colorizer.
RangeSegmentColorizer.LegendItemPatternGets or sets the pattern to format the text the legend shows for a color range.
RangeSegmentColorizer.ShowInLegendGets or sets the value whether to show the colorizer items in the legend.
LineSeriesView.SegmentColorizerGets or sets the colorizer that colors the line view segments.

Example: Change the Series Line Color when the Value is under a Predefined Level

This example creates a step line chart with the capability to change the series line color when the value is under a predefined level.

View Example

Point Based Segment Colorizer

The Point Based Segment Colorizer paints line/area segments into the point marker colors. Use a series point colorizer or specify the SeriesPoint.Color property directly to provide markers with colors.

The following code shows how to configure and apply the Point Based Segment colorizer:

csharp
LineSeriesView lineSeriesView = chartControl.Series[0].View as LineSeriesView;
lineSeriesView.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True;

// Specify the colorizer that paints the series markers.
RangeColorizer rangeColorizer = new RangeColorizer();
rangeColorizer.Palette = new Palette("TemperaturePalette", new PaletteEntry[] { new PaletteEntry(Color.DarkBlue),
                                                                                new PaletteEntry(Color.SteelBlue),
                                                                                new PaletteEntry(Color.LightBlue),
                                                                                new PaletteEntry(Color.Yellow),
                                                                                new PaletteEntry(Color.OrangeRed) });

rangeColorizer.LegendItemPattern = "{V1: F0}°C — {V2: F0}°C";
rangeColorizer.RangeStops.AddRange(new double[] { -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30 });
chartControl.Series[0].Colorizer = rangeColorizer;

// Specify the colorizer that paints the line segments.
PointBasedSegmentColorizer segmentColorizer = new PointBasedSegmentColorizer();
segmentColorizer.Direction = ColorDistributionDirection.Forward;
lineSeriesView.SegmentColorizer = segmentColorizer;
vb
Dim lineSeriesView As LineSeriesView = CType(chartControl.Series(0).View,LineSeriesView)
lineSeriesView.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True
' Specify the colorizer that paints the series markers.
Dim rangeColorizer As RangeColorizer = New RangeColorizer
rangeColorizer.Palette = New Palette("TemperaturePalette", New PaletteEntry() {New PaletteEntry(Color.DarkBlue), 
                                                                               New PaletteEntry(Color.SteelBlue), 
                                                                               New PaletteEntry(Color.LightBlue), 
                                                                               New PaletteEntry(Color.Yellow), 
                                                                               New PaletteEntry(Color.OrangeRed)})
rangeColorizer.LegendItemPattern = "{V1: F0}°C — {V2: F0}°C"
rangeColorizer.RangeStops.AddRange(New Double() {-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30})
chartControl.Series(0).Colorizer = rangeColorizer
' Specify the colorizer that paints the line segments.
Dim segmentColorizer As PointBasedSegmentColorizer = New PointBasedSegmentColorizer
segmentColorizer.Direction = ColorDistributionDirection.Forward
lineSeriesView.SegmentColorizer = segmentColorizer

The following table lists the related API members:

MemberDescription
PointBasedSegmentColorizerThe colorizer that uses the point marker colors to paint line/area segments.
PointBasedSegmentColorizer.DirectionGets or sets the direction that is used to distribute the point marker color.
ColorDistributionDirectionLists values that define the direction used by point markers to distribute a color among segments.
LineSeriesView.SegmentColorizerGets or sets the colorizer that colors the line view segments.

See Also

Series Point Colorizer

Series Colorizer