windowsforms-400714-controls-and-libraries-chart-control-series-segment-colorizers.md
Segment Colorizers allow you to paint segments of the LineSeriesView, AreaSeriesView and their descendants.
Line Series View
Area Series View
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.
Create one of the SegmentColorizerBase descendants that are listed below:
Configure the colorizer object’s settings and assign it to the LineSeriesView.SegmentColorizer property.
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:
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;
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:
| Member | Description |
|---|---|
| TrendSegmentColorizer | The colorizer that changes a line‘s color when a point value increases or decreases. |
| TrendSegmentColorizer.FallingTrendColor | Gets or sets the color used to draw the falling value segments. |
| TrendSegmentColorizer.RisingTrendColor | Gets or sets the color used to draw the rising value segments. |
| TrendSegmentColorizer.FallingTrendLegendText | Gets or sets the text the legend uses to identify the falling trend segments. |
| TrendSegmentColorizer.RisingTrendLegendText | Gets or sets the text the legend uses to identify the rising trend segments. |
| LineSeriesView.SegmentColorizer | Gets or sets the colorizer that colors the line view segments. |
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:
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;
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:
| Member | Description |
|---|---|
| RangeSegmentColorizer | The colorizer that allows you to color a line segment based on a its value range. |
| RangeSegmentColorizer.RangeStops | Provides access to the collection of double values that define color range boundaries. |
| RangeSegmentColorizer.Palette | Gets or sets the palette that provides colors for the colorizer. |
| RangeSegmentColorizer.PaletteName | Gets or sets a name of the palette that provides colors for the colorizer. |
| RangeSegmentColorizer.LegendItemPattern | Gets or sets the pattern to format the text the legend shows for a color range. |
| RangeSegmentColorizer.ShowInLegend | Gets or sets the value whether to show the colorizer items in the legend. |
| LineSeriesView.SegmentColorizer | Gets or sets the colorizer that colors the line view segments. |
This example creates a step line chart with the capability to change the series line color when the value is under a predefined level.
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:
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;
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:
| Member | Description |
|---|---|
| PointBasedSegmentColorizer | The colorizer that uses the point marker colors to paint line/area segments. |
| PointBasedSegmentColorizer.Direction | Gets or sets the direction that is used to distribute the point marker color. |
| ColorDistributionDirection | Lists values that define the direction used by point markers to distribute a color among segments. |
| LineSeriesView.SegmentColorizer | Gets or sets the colorizer that colors the line view segments. |
See Also