src/echarts.js
function prepareView(ecIns, type, ecModel, scheduler) {
    var isComponent = type === 'component';
    var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
    var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
    var zr = ecIns._zr;
    var api = ecIns._api;

    for (var i = 0; i < viewList.length; i++) {
        viewList[i].__alive = false;
    }

    isComponent
        ? ecModel.eachComponent(function (componentType, model) {
            componentType !== 'series' && doPrepare(model);
        })
        : ecModel.eachSeries(doPrepare);

    function doPrepare(model) {
        // Consider: id same and type changed.
        var viewId = '_ec_' + model.id + '_' + model.type;
        var view = viewMap[viewId];
        if (!view) {
            var classType = parseClassType(model.type);
            var Clazz = isComponent
                ? ComponentView.getClass(classType.main, classType.sub)
                : ChartView.getClass(classType.sub);

            if (__DEV__) {
                assert(Clazz, classType.sub + ' does not exist.');
            }

            view = new Clazz();
            view.init(ecModel, api);
            viewMap[viewId] = view;
            viewList.push(view);
            zr.add(view.group);
        }

        model.__viewId = view.__id = viewId;
        view.__alive = true;
        view.__model = model;
        view.group.__ecComponentInfo = {
            mainType: model.mainType,
            index: model.componentIndex
        };
        !isComponent && scheduler.prepareView(view, model, ecModel, api);
    }

    for (var i = 0; i < viewList.length;) {
        var view = viewList[i];
        if (!view.__alive) {
            !isComponent && view.renderTask.dispose();
            zr.remove(view.group);
            view.dispose(ecModel, api);
            viewList.splice(i, 1);
            delete viewMap[view.__id];
            view.__id = view.group.__ecComponentInfo = null;
        }
        else {
            i++;
        }
    }
}
function prepareView(ecIns, type, ecModel, scheduler) {
    var isComponent = type === 'component';
    var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
    var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
    var zr = ecIns._zr;
    var api = ecIns._api;

    for (var i = 0; i < viewList.length; i++) {
        viewList[i].__alive = false;
    }

    isComponent
        ? ecModel.eachComponent(function (componentType, model) {
            componentType !== 'series' && doPrepare(model);
        })
        : ecModel.eachSeries(doPrepare);

    function doPrepare(model) {
        // Consider: id same and type changed.
        var viewId = '_ec_' + model.id + '_' + model.type;
        var view = viewMap[viewId];
        if (!view) {
            var classType = parseClassType(model.type);
            var Clazz = isComponent
                ? ComponentView.getClass(classType.main, classType.sub)
                : ChartView.getClass(classType.sub);

            if (__DEV__) {
                assert(Clazz, classType.sub + ' does not exist.');
            }

            view = new Clazz();
            view.init(ecModel, api);
            viewMap[viewId] = view;
            viewList.push(view);
            zr.add(view.group);
        }

        model.__viewId = view.__id = viewId;
        view.__alive = true;
        view.__model = model;
        view.group.__ecComponentInfo = {
            mainType: model.mainType,
            index: model.componentIndex
        };
        !isComponent && scheduler.prepareView(view, model, ecModel, api);
    }

    for (var i = 0; i < viewList.length;) {
        var view = viewList[i];
        if (!view.__alive) {
            !isComponent && view.renderTask.dispose();
            zr.remove(view.group);
            view.dispose(ecModel, api);
            viewList.splice(i, 1);
            delete viewMap[view.__id];
            view.__id = view.group.__ecComponentInfo = null;
        }
        else {
            i++;
        }
    }
}
function prepareView ( ecIns , type , ecModel , scheduler ) { var isComponent = type === 'component' ; var viewList = isComponent ? ecIns . _componentsViews : ecIns . _chartsViews ; var viewMap = isComponent ? ecIns . _componentsMap : ecIns . _chartsMap ; var zr = ecIns . _zr ; var api = ecIns . _api ; for ( var i = 0 ; i < viewList . length ; i ++ ) { viewList [ i ] . __alive = false ; } isComponent ? ecModel . eachComponent ( function ( componentType , model ) { componentType !== 'series' && doPrepare ( model ) ; } ) : ecModel . eachSeries ( doPrepare ) ; function doPrepare ( model ) { // Consider: id same and type changed. var viewId = '_ec_' + model . id + '_' + model . type ; var view = viewMap [ viewId ] ; if ( ! view ) { var classType = parseClassType ( model . type ) ; var Clazz = isComponent ? ComponentView . getClass ( classType . main , classType . sub ) : ChartView . getClass ( classType . sub ) ; if ( __DEV__ ) { assert ( Clazz , classType . sub + ' does not exist.' ) ; } view = new Clazz ( ) ; view . init ( ecModel , api ) ; viewMap [ viewId ] = view ; viewList . push ( view ) ; zr . add ( view . group ) ; } model . __viewId = view . __id = viewId ; view . __alive = true ; view . __model = model ; view . group . __ecComponentInfo = { mainType : model . mainType , index : model . componentIndex } ; ! isComponent && scheduler . prepareView ( view , model , ecModel , api ) ; } for ( var i = 0 ; i < viewList . length ; ) { var view = viewList [ i ] ; if ( ! view . __alive ) { ! isComponent && view . renderTask . dispose ( ) ; zr . remove ( view . group ) ; view . dispose ( ecModel , api ) ; viewList . splice ( i , 1 ) ; delete viewMap [ view . __id ] ; view . __id = view . group . __ecComponentInfo = null ; } else { i ++ ; } } }
Prepare view instances of charts and components
@param  {module:echarts/model/Global} ecModel
@private
Prepare view instances of charts and components