All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.assets.rjzjh.echarts.src.component.brush.preprocessor.js Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/**
 * @file brush preprocessor
 */
define(function(require) {

    var zrUtil = require('zrender/core/util');

    var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];

    return function (option) {
        var btns = findToolboxNeededByBrush(option);

        if (!btns.length) {
            return;
        }

        var toolbox = option && option.toolbox;

        if (zrUtil.isArray(toolbox)) {
            toolbox = toolbox[0];
        }
        if (!toolbox) {
            toolbox = {feature: {}};
            option.toolbox = [toolbox];
        }

        (toolbox.feature || (toolbox.feature = {})).brush = {type: btns};
    };

    function findToolboxNeededByBrush(option) {
        var brush = option && option.brush;
        var btns = [];

        if (!zrUtil.isArray(brush)) {
            brush = brush ? [brush] : [];
        }

        zrUtil.each(brush, function (brushOpt) {
            var tbs = brushOpt.hasOwnProperty('toolbox')
                ? brushOpt.toolbox
                : DEFAULT_TOOLBOX_BTNS; // Default value

            if (tbs instanceof Array) {
                btns = btns.concat(tbs);
            }
        });

        return btns;
    }

});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy