Snippets

Piotr Szrajber Smart M.App - modify choropleth's stroke color to black

Created by Piotr Szrajber
/**
 * Modify choropleth's stroke color to black
 * 2017-07-25 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
 */
// helper 
function waitForMap(callback, errback, attempts) {
    gsp.bi.stage.findWidgets({
        descriptors: [{
            chartM: {
                chart: "choropleth"
            }
        }]
    }, function(widgets) {
        if (!widgets || !widgets[0]) {
            setTimeout(function() {
                if (attempts > 0) {
                    waitForMap(callback, errback, attempts - 1);
                } else {
                    if (typeof errback === "function") errback("Still no choropleth");
                }
            }, 300);
            return;
        }
        if (typeof callback === "function") callback(widgets[0]);
    });
}

// modify the paintstyle
function modifyMapColors(map) {
    let origPaintStyle = map.chart.painter().paintStyle(),
        paintStyle = function(arg0) {
            var ret = origPaintStyle(arg0);
            ret.color = "#000"; // TODO: modify the paint style
            return ret;
        };
    map.chart.painter().paintStyle(paintStyle);
    map.chart.painter().paint();
}

// execute
waitForMap(modifyMapColors, function(err) {
    console.error(err);
}, 100);

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.