Click or drag to resize

ClassBreak Class

A class break object used to categorize a group of values that fall within a range of values. It represents a unique value or combination of values and a matching symbol in a ClassBreaksRenderer.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.SymbologyClassBreak

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class ClassBreak : INotifyPropertyChanged

The ClassBreak type exposes the following members.

Constructors
  NameDescription
Public methodClassBreak
Initializes a new instance of the ClassBreak class.
Public methodCode exampleClassBreak(String, String, Double, Double, Symbol)
Initializes a new instance of the ClassBreak class with initial values.
Top
Properties
  NameDescription
Public propertyDescription
Gets or sets the renderer description for this class of values.
Public propertyLabel
Gets or sets the renderer label for this class of values.
Public propertyMaxValue
The maximum value of the range that defines the break.
Public propertyMinValue
The minimum value of the range that defines the break.
Public propertySymbol
A symbol used to represent elements in the class break.
Top
Methods
  NameDescription
Public methodClone
Returns a clone of this ClassBreak.
Public methodStatic memberFromJson
Creates an instance of a class break by deserializing JSON.
Public methodToJson
Returns a string containing the JSON representation of the class break.
Top
Events
  NameDescription
Public eventPropertyChanged
Occurs when a property value changes.
Top
Remarks

The ClassBreak is used to categorize a group of values that fall within a range of MinValue and MaxValue settings. When defining this categorization group, the value to be categorized must be greater than the MinValue but less than or equal to the MaxValue. When written as an algebraic equation, it would look like ('MinValue' < value <= 'MaxValue').

For example, assume you wanted to create a set of ClassBreak categories based on the following integers (0, 0, 1, 1, 2, 4, 6, 6, 7, 10).

The following table would be helpful in defining the ClassBreak range settings
Categorized group of valuesCountLabelMinValueMaxValue
02zero-10
1 - 23one to two02
3 - 51three to five25
6 - 104six to ten510

Examples

WPF

Example Name: ChangeSublayerRenderer

Apply a renderer to a sublayer.

Code example screen shot.

C#
// Copyright 2018 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using System.Collections.Generic;
using System.Windows;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using System.Drawing;

namespace ArcGISRuntime.WPF.Samples.ChangeSublayerRenderer
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Change sublayer renderer",
        category: "Layers",
        description: "Apply a renderer to a sublayer.",
        instructions: "Wait for the map image layer to load. Click the button to apply a unique value renderer to see different population ranges in the counties sub-layer data.",
        tags: new[] { "class breaks", "dynamic layer", "dynamic rendering", "renderer", "sublayer", "symbology", "visualization" })]
    public partial class ChangeSublayerRenderer
    {
        // ArcGIS map image layer that contains four Census sub-layers.
        private ArcGISMapImageLayer _arcGISMapImageLayer;

        public ChangeSublayerRenderer()
        {
            InitializeComponent();

            // Load the initial datasets in the map.
            Initialize();
        }

        private void Initialize()
        {
            // Create a new map based on the streets base map.
            Map newMap = new Map(BasemapStyle.ArcGISStreets);

            // Create an envelope that covers the continental US in the web Mercator spatial reference.
            Envelope continentalUSEnvelope = new Envelope(-14193469.5655232, 2509617.28647268, -7228772.04749191, 6737139.97573925 , SpatialReferences.WebMercator);

            // Zoom the map to the extent of the envelope.
            newMap.InitialViewpoint = new  Viewpoint(continentalUSEnvelope);

            // Assign the map to the MapView.
            MyMapView.Map = newMap;

            // Create an ArcGIS map image layer based on the Uri to that points to an ArcGIS Server map service that contains four Census sub-layers.
            // NOTE: sub-layer[0] = Census Block Points, sub-layer[1] = Census Block Group, sub-layer[3] = Counties, sub-layer[3] = States. 
            _arcGISMapImageLayer = new ArcGISMapImageLayer(new System.Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"));

            // Add the ArcGIS map image layer to the map's operation layers collection.
            newMap.OperationalLayers.Add(_arcGISMapImageLayer);
        }

        private ClassBreaksRenderer CreateClassBreaksRenderer()
        {
            // Define the colors that will be used by the unique value renderer.
            Color gray = Color.FromArgb(255, 153, 153, 153);
            Color blue1 = Color.FromArgb(255, 227, 235, 207);
            Color blue2 = Color.FromArgb(255, 150, 194, 191);
            Color blue3 = Color.FromArgb(255, 97, 166, 181);
            Color blue4 = Color.FromArgb(255, 69, 125, 150);
            Color blue5 = Color.FromArgb(255, 41, 84, 120);

            // Create a gray outline and five fill symbols with different shades of blue.
            SimpleLineSymbol outlineSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, gray, 1);
            SimpleFillSymbol simpleFileSymbol1 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue1, outlineSimpleLineSymbol);
            SimpleFillSymbol simpleFileSymbol2 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue2, outlineSimpleLineSymbol);
            SimpleFillSymbol simpleFileSymbol3 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue3, outlineSimpleLineSymbol);
            SimpleFillSymbol simpleFileSymbol4 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue4, outlineSimpleLineSymbol);
            SimpleFillSymbol simpleFileSymbol5 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue5, outlineSimpleLineSymbol);

            // Create a list of five class breaks for different population ranges.
            List<ClassBreak> listClassBreaks = new List<ClassBreak>
            {
                new ClassBreak("-99 to 8560", "-99 to 8560", -99, 8560, simpleFileSymbol1),
                new ClassBreak("> 8,560 to 18,109", "> 8,560 to 18,109", 8560, 18109, simpleFileSymbol2),
                new ClassBreak("> 18,109 to 35,501", "> 18,109 to 35,501", 18109, 35501, simpleFileSymbol3),
                new ClassBreak("> 35,501 to 86,100", "> 35,501 to 86,100", 35501, 86100, simpleFileSymbol4),
                new ClassBreak("> 86,100 to 10,110,975", "> 86,100 to 10,110,975", 86100, 10110975, simpleFileSymbol5)
            };

            // Create and return the a class break renderer for use with the POP2007 field in the counties sub-layer.
            return new ClassBreaksRenderer("POP2007", listClassBreaks);
        }

        private void ChangeSublayerRendererButton_Click(object sender, RoutedEventArgs e)
        {
            // Get the counties sub-layer (the 3rd layer) from the ArcGIS map image layer.
            ArcGISMapImageSublayer countiesArcGISMapImageSubLayer = (ArcGISMapImageSublayer)_arcGISMapImageLayer.Sublayers[2];

            // Set the renderer of the ArcGIS map image sub-layer to a class break renderer based on population.
            countiesArcGISMapImageSubLayer.Renderer = CreateClassBreaksRenderer();

            // Disable the button after has been used.
            ChangeSublayerRendererButton.IsEnabled = false;
        }

    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ChangeSublayerRenderer.ChangeSublayerRenderer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock x:Name="ChangeSublayerRendererInstructionsLabel"
                           Text="Click 'Change sublayer renderer' to apply a unique value renderer to the counties sub-layer."
                           TextWrapping="Wrap" FontWeight="SemiBold"
                           Margin="0,0,0,5" />
                <Button x:Name="ChangeSublayerRendererButton"
                        Content="Change sublayer renderer"
                        Click="ChangeSublayerRendererButton_Click" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
ChangeSublayerRendererApply a renderer to a sublayer.