Class GradientTheme
The GradientTheme class defines a gradient color thematic rendering of features based by a numeric attribute.
Inherited Members
Namespace: Mapsui.Styles.Thematics
Assembly: Mapsui.dll
Syntax
public class GradientTheme : Style, IThemeStyle, IStyle
Constructors
| Edit this page View SourceGradientTheme(string, double, double, IStyle, IStyle)
Initializes a new instance of the GradientTheme class
Declaration
public GradientTheme(string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
Parameters
Type | Name | Description |
---|---|---|
string | columnName | Name of column to extract the attribute |
double | minValue | Minimum value |
double | maxValue | Maximum value |
IStyle | minStyle | Color for minimum value |
IStyle | maxStyle | Color for maximum value |
Remarks
The gradient theme interpolates linearly between two styles based on a numerical attribute in the data source. This is useful for scaling symbols, line widths, line and fill colors from numerical attributes.
Colors are interpolated between two colors, but if you want to interpolate through more colors (fx. a rainbow), set the TextColorBlend, LineColorBlend and FillColorBlend properties to a custom ColorBlend.
The following properties are scaled (properties not mentioned here are not interpolated):
Property | Remarks |
---|---|
Color | Red, Green, Blue and Alpha values are linearly interpolated. |
Pen | The color, width, color of pens are interpolated. MiterLimit,StartCap,EndCap,LineJoin,DashStyle,DashPattern,DashOffset,DashCap,CompoundArray, and Alignment are switched in the middle of the min/max values. |
Brush | Brush color are interpolated. Other brushes are not supported. |
VectorStyle | MaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values. |
LabelStyle | FontSize, BackColor, ForeColor, MaxVisible, MinVisible, Offset are scaled linearly. All other properties use min-style. |
//Create two vector styles to interpolate between
Mapsui.Styles.VectorStyle min = new Mapsui.Styles.VectorStyle();
Mapsui.Styles.VectorStyle max = new Mapsui.Styles.VectorStyle();
min.Outline.Width = 1f; //Outline width of the minimum value
max.Outline.Width = 3f; //Outline width of the maximum value
//Create a theme interpolating population density between 0 and 400
Mapsui.Rendering.Thematics.GradientTheme popdens = new Mapsui.Rendering.Thematics.GradientTheme("POPDENS", 0, 400, min, max);
//Set the fill-style colors to be a rainbow blend from red to blue.
popdens.FillColorBlend = Mapsui.Rendering.Thematics.ColorBlend.Rainbow5;
myVectorLayer.Styles.Add(popdens);
Properties
| Edit this page View SourceColumnName
Gets or sets the column name from where to get the attribute value
Declaration
public string ColumnName { get; set; }
Property Value
Type | Description |
---|---|
string |
FillColorBlend
Gets or sets the ColorBlend used as Fill
Declaration
public ColorBlend? FillColorBlend { get; set; }
Property Value
Type | Description |
---|---|
ColorBlend |
LineColorBlend
Gets or sets the ColorBlend used on lines
Declaration
public ColorBlend? LineColorBlend { get; set; }
Property Value
Type | Description |
---|---|
ColorBlend |
Max
Gets or sets the maximum value of the gradient
Declaration
public double Max { get; set; }
Property Value
Type | Description |
---|---|
double |
MaxStyle
Gets or sets the style for the maximum value
Declaration
public IStyle MaxStyle { get; set; }
Property Value
Type | Description |
---|---|
IStyle |
Min
Gets or sets the minimum value of the gradient
Declaration
public double Min { get; set; }
Property Value
Type | Description |
---|---|
double |
MinStyle
Gets or sets the style for the minimum value
Declaration
public IStyle MinStyle { get; set; }
Property Value
Type | Description |
---|---|
IStyle |
TextColorBlend
Gets or sets the ColorBlend used on labels
Declaration
public ColorBlend? TextColorBlend { get; set; }
Property Value
Type | Description |
---|---|
ColorBlend |
Methods
| Edit this page View SourceGetStyle(IFeature)
Returns the style based on a numeric DataColumn, where style properties are linearly interpolated between max and min values.
Declaration
public IStyle? GetStyle(IFeature row)
Parameters
Type | Name | Description |
---|---|---|
IFeature | row | Feature |
Returns
Type | Description |
---|---|
IStyle | Style calculated by a linear interpolation between the min/max styles |