Snippets

Piotr Szrajber Smart M.App - make the BI circles smaller/bigger

Created by Piotr Szrajber
//# sourceURL=Customizations.js

/**
 * Modify BI map behavior, so that the circles are smaller/bigger
 * 2017-07-28 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
 */

let CIRCLE_SIZE = 5;

/**
 * Modify painter's behavior
 */
function changeMapBehavior(attempts) {
    // find the choropleth
    $GP.bi.stage.findWidgets({
        descriptors: [{
            chartM: {
                chart: "choropleth"
            }
        }]
    }, function(widgets) {
        if (!widgets || !widgets[0]) {
            setTimeout(function() {
                if (attempts > 0) {
                    changeMapBehavior(attempts - 1);
                }
            }, 300);
            return;
        }
        
        // main logic
        let painter = widgets[0].chart.painter(),
            origPaintStyle = painter.paintStyle();
        
        painter.paintStyle((feature) => {
            let style = origPaintStyle.call(this, feature);
            style.radius = CIRCLE_SIZE;
            return style;
        });

        painter.paint();
    });
}

// launch the customization
changeMapBehavior(100);

Comments (0)

HTTPS SSH

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