How to use smart mapping classBreaks in JS API 4.5?

434
0
12-11-2017 07:57 AM
BrianFrizzelle
New Contributor II

Can somebody help me understand how to use the classBreaks function under esri/renderers/smartMapping/statistics in JS API 4.5? The documentation gives an example but I cannot figure out how to feed the results into the classBreaksRenderer.

I've pasted my JS code below that contains a modification of the code example plus my attempt to feed the output from classBreaks into a renderer. I know it's wrong but I'm not clear how to fix it. Any help would be appreciated.

require([
    'dojo/dom',
    'dojo/number',
    'dojo/on',
    'esri/Map',
    'esri/views/MapView',
    'esri/layers/FeatureLayer',
    'esri/renderers/smartMapping/statistics/classBreaks',
    'dojo/domReady!'
], function(dom, number, on, Map, MapView, FeatureLayer, classBreaks) {
    // Create the Map element
    var map = new Map({
        basemap: 'oceans'
    });

    var viewProperties = {
        center: [-77.3936, 35.1377],
        zoom: 8
    };

    // Create the MapView element that will hold the map
    var view = new MapView({
        container: "viewDiv",
        map: map
    });

    view.center = viewProperties.center;
    view.zoom = viewProperties.zoom;

    var renderer = {
        type: 'class-breaks',
        field: 'Alligator'
    };

    renderer.addClassBreakInfo(breakInfos);

    function genClassBreaks () {
        classBreaks({
            layer: featureLayer,
            field: "Alligator",
            classificationMethod: "quantile",
            numClasses: 4
        }).then(function(response){
            var breakInfos = response.classBreakInfos;
        });
    }

    var featureLayer = new FeatureLayer({
        url: "https://services.arcgis.com/ycIuRaoIC4UuCDAS/arcgis/rest/services/Alligator%20Sightings%20by%20Count...",
        renderer: renderer,
        outFields: ["*"],
        definitionExpression: "Alligator > 0"
    });

    // Add featureLayer to the map
    map.add(featureLayer);

});
0 Kudos
0 Replies