Example #1
0
 zrUtil.each(option.data, function (opt) {
     fromDataArr.push(opt[0]);
     toDataArr.push(opt[1]);
     lineDataArr.push(zrUtil.extend(
         zrUtil.extend({}, zrUtil.isArray(opt[0]) ? null : opt[0]),
         zrUtil.isArray(opt[1]) ? null : opt[1]
     ));
 });
Example #2
0
    var markLineTransform = function (seriesModel, coordSys, baseAxis, valueAxis, precision, item) {
        var data = seriesModel.getData();
        // Special type markLine like 'min', 'max', 'average'
        var mlType = item.type;
        if (!zrUtil.isArray(item)
            && mlType === 'min' || mlType === 'max' || mlType === 'average'
        ) {
            if (item.valueIndex != null) {
                baseAxis = coordSys.getAxis(coordSys.dimensions[1 - item.valueIndex]);
                valueAxis = coordSys.getAxis(coordSys.dimensions[item.valueIndex]);
            }
            var baseAxisKey = baseAxis.dim + 'Axis';
            var valueAxisKey = valueAxis.dim + 'Axis';
            var baseScaleExtent = baseAxis.scale.getExtent();

            var mlFrom = zrUtil.extend({}, item);
            var mlTo = {};

            mlFrom.type = null;

            // FIXME Polar should use circle
            mlFrom[baseAxisKey] = baseScaleExtent[0];
            mlTo[baseAxisKey] = baseScaleExtent[1];

            var value = mlType === 'average'
                ? data.getSum(valueAxis.dim, true) / data.count()
                : data.getDataExtent(valueAxis.dim)[mlType === 'max' ? 1 : 0];

            // Round if axis is cateogry
            value = valueAxis.coordToData(valueAxis.dataToCoord(value));

            mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value;

            item = [mlFrom, mlTo, { // Extra option for tooltip and label
                type: mlType,
                // Force to use the value of calculated value.
                value: +value.toFixed(precision)
            }];
        }
        item = [
            markerHelper.dataTransform(seriesModel, item[0]),
            markerHelper.dataTransform(seriesModel, item[1]),
            zrUtil.extend({}, item[2])
        ];

        // Merge from option and to option into line option
        zrUtil.merge(item[2], item[0]);
        zrUtil.merge(item[2], item[1]);

        return item;
    };
Example #3
0
                each(mapResult, function (resultItem, index) {
                    var componentModel = resultItem.exist;
                    var newCptOption = resultItem.option;

                    zrUtil.assert(
                        isObject(newCptOption) || componentModel,
                        'Empty component definition'
                    );

                    // Consider where is no new option and should be merged using {},
                    // see removeEdgeAndAdd in topologicalTravel and
                    // ComponentModel.getAllClassMainTypes.
                    if (!newCptOption) {
                        componentModel.mergeOption({}, this);
                        componentModel.optionUpdated({}, false);
                    }
                    else {
                        var ComponentModelClass = ComponentModel.getClass(
                            mainType, resultItem.keyInfo.subType, true
                        );

                        if (componentModel && componentModel instanceof ComponentModelClass) {
                            componentModel.name = resultItem.keyInfo.name;
                            componentModel.mergeOption(newCptOption, this);
                            componentModel.optionUpdated(newCptOption, false);
                        }
                        else {
                            // PENDING Global as parent ?
                            var extraOpt = zrUtil.extend(
                                {
                                    dependentModels: dependentModels,
                                    componentIndex: index
                                },
                                resultItem.keyInfo
                            );
                            componentModel = new ComponentModelClass(
                                newCptOption, this, this, extraOpt
                            );
                            zrUtil.extend(componentModel, extraOpt);
                            componentModel.init(newCptOption, this, this, extraOpt);
                            // Call optionUpdated after init.
                            // newCptOption has been used as componentModel.option
                            // and may be merged with theme and default, so pass null
                            // to avoid confusion.
                            componentModel.optionUpdated(null, true);
                        }
                    }

                    componentsMap.get(mainType)[index] = componentModel;
                    option[mainType][index] = componentModel.option;
                }, this);
Example #4
0
        RootClass.extend = function (proto) {

            if (__DEV__) {
                zrUtil.each(mandatoryMethods, function (method) {
                    if (!proto[method]) {
                        console.warn(
                            'Method `' + method + '` should be implemented'
                            + (proto.type ? ' in ' + proto.type : '') + '.'
                        );
                    }
                });
            }

            var superClass = this;
            var ExtendedClass = function () {
                if (!proto.$constructor) {
                    superClass.apply(this, arguments);
                }
                else {
                    proto.$constructor.apply(this, arguments);
                }
            };

            zrUtil.extend(ExtendedClass.prototype, proto);

            ExtendedClass.extend = this.extend;
            ExtendedClass.superCall = superCall;
            ExtendedClass.superApply = superApply;
            zrUtil.inherits(ExtendedClass, this);
            ExtendedClass.superClass = superClass;

            return ExtendedClass;
        };
Example #5
0
            areaData.eachItemGraphicEl(function (polygon, idx) {
                var itemModel = areaData.getItemModel(idx);
                var labelModel = itemModel.getModel('label.normal');
                var labelHoverModel = itemModel.getModel('label.emphasis');
                polygon.useStyle(
                    zrUtil.extend(
                        itemModel.getModel('itemStyle.normal').getItemStyle(),
                        {
                            fill: areaData.getItemVisual(idx, 'color')
                        }
                    )
                );

                polygon.hoverStyle = itemModel.getModel('itemStyle.normal').getItemStyle();

                var defaultValue = areaData.getName(idx) || '';
                graphic.setText(polygon.style, labelModel, polygon.style.fill);
                polygon.style.text = zrUtil.retrieve(
                    maModel.getFormattedLabel(idx, 'normal'),
                    defaultValue
                );

                graphic.setText(polygon.hoverStyle, labelHoverModel, polygon.style.fill);
                polygon.hoverStyle.text = zrUtil.retrieve(
                    maModel.getFormattedLabel(idx, 'emphasis'),
                    defaultValue
                );

                graphic.setHoverStyle(polygon, {});

                polygon.dataModel = maModel;
            });
Example #6
0
        axisLine: function () {
            var opt = this.opt;
            var axisModel = this.axisModel;

            if (!axisModel.get('axisLine.show')) {
                return;
            }

            var extent = this.axisModel.axis.getExtent();

            this.group.add(new graphic.Line({
                shape: {
                    x1: extent[0],
                    y1: 0,
                    x2: extent[1],
                    y2: 0
                },
                style: zrUtil.extend(
                    {lineCap: 'round'},
                    axisModel.getModel('axisLine.lineStyle').getLineStyle()
                ),
                strokeContainThreshold: opt.strokeContainThreshold,
                silent: !!opt.silent,
                z2: 1
            }));
        },
Example #7
0
        axisLine: function () {
            var opt = this.opt;
            var axisModel = this.axisModel;

            if (!axisModel.get('axisLine.show')) {
                return;
            }

            var extent = this.axisModel.axis.getExtent();

            var matrix = this._transform;
            var pt1 = v2ApplyTransform([], [extent[0], 0], matrix);
            var pt2 = v2ApplyTransform([], [extent[1], 0], matrix);

            this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({

                // Id for animation
                anid: 'line',

                shape: {
                    x1: pt1[0],
                    y1: pt1[1],
                    x2: pt2[0],
                    y2: pt2[1]
                },
                style: zrUtil.extend(
                    {lineCap: 'round'},
                    axisModel.getModel('axisLine.lineStyle').getLineStyle()
                ),
                strokeContainThreshold: opt.strokeContainThreshold,
                silent: !!opt.axisLineSilent,
                z2: 1
            })));
        },
Example #8
0
                each(store, function (el, rawIndex) {
                    var last = renderResult.lastsForAnimation[storageName][rawIndex];
                    var target = {};

                    if (!last) {
                        return;
                    }

                    if (storageName === 'nodeGroup') {
                        if (last.old) {
                            target.position = el.position.slice();
                            el.position = last.old;
                        }
                    }
                    else {
                        if (last.old) {
                            target.shape = zrUtil.extend({}, el.shape);
                            el.setShape(last.old);
                        }

                        if (last.fadein) {
                            el.setStyle('opacity', 0);
                            target.style = {opacity: 1};
                        }
                        // When animation is stopped for succedent animation starting,
                        // el.style.opacity might not be 1
                        else if (el.style.opacity !== 1) {
                            target.style = {opacity: 1};
                        }
                    }

                    animationWrap.add(el, target, duration, easing);
                });
Example #9
0
    function createIcon(handleModel, handlers) {
        var iconStr = handleModel.get('icon');
        var style = {
            x: -1, y: -1, width: 2, height: 2
        };
        var opt = zrUtil.extend({
            style: {
                strokeNoScale: true
            },
            rectHover: true,
            cursor: 'move',
            draggable: true
        }, handlers);

        return iconStr.indexOf('image://') === 0
            ? (
                style.image = iconStr.slice(8),
                opt.style = style,
                new graphic.Image(opt)
            )
            : graphic.makePath(
                iconStr.replace('path://', ''),
                opt,
                style,
                'center'
            );
    }
Example #10
0
    graphic.setTextStyle = function (style, textStyleModel, specifiedTextStyle, opt) {
        setTextStyleCommon(style, textStyleModel, opt);
        specifiedTextStyle && zrUtil.extend(style, specifiedTextStyle);
        style.dirty && style.dirty();

        return style;
    };
Example #11
0
    echartsProto.dispatchAction = function (payload, silent) {
        var actionWrap = actions[payload.type];
        if (actionWrap) {

            this._extraEvents = [];

            var actionInfo = actionWrap.actionInfo;
            var updateMethod = actionInfo.update || 'update';

            var payloads = [payload];
            var batched = false;
            // Batch action
            if (payload.batch) {
                batched = true;
                payloads = zrUtil.map(payload.batch, function (item) {
                    item = zrUtil.defaults(zrUtil.extend({}, item), payload);
                    item.batch = null;
                    return item;
                });
            }

            var eventObjBatch = [];
            var eventObj;
            var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay';
            for (var i = 0; i < payloads.length; i++) {
                var batchItem = payloads[i];
                // Action can specify the event by return it.
                eventObj = actionWrap.action(batchItem, this._model);
                // Emit event outside
                eventObj = eventObj || zrUtil.extend({}, batchItem);
                // Convert type to eventType
                eventObj.type = actionInfo.event || eventObj.type;
                eventObjBatch.push(eventObj);

                // Highlight and downplay are special.
                isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem);
            }

            (updateMethod !== 'none' && !isHighlightOrDownplay)
                && updateMethods[updateMethod].call(this, payload);

            if (!silent) {
                // Follow the rule of action batch
                if (batched) {
                    eventObj = {
                        type: actionInfo.event || payload.type,
                        batch: eventObjBatch
                    };
                }
                else {
                    eventObj = eventObjBatch[0];
                }
                this._messageCenter.trigger(eventObj.type, eventObj);
            }

            // FIXME
            // Should controlled by silent?
            triggerExtraEvents.call(this);
        }
    };
Example #12
0
 setLayoutInfo: function (layoutInfo) {
     /**
      * @readOnly
      * @type {Object}
      */
     this.layoutInfo = this.layoutInfo || {};
     zrUtil.extend(this.layoutInfo, layoutInfo);
 },
Example #13
0
 var brushRanges = zrUtil.map(brushModel.brushRanges, function (brushRange) {
     return bindSelector(
         zrUtil.extend(
             {boundingRect: boundingRectBuilders[brushRange.brushType](brushRange)},
             brushRange
         )
     );
 });
Example #14
0
            controller.off('pan').on('pan', function (dx, dy) {
                this._mouseDownFlag = false;

                api.dispatchAction(zrUtil.extend(makeActionBase(), {
                    dx: dx,
                    dy: dy
                }));
            }, this);
Example #15
0
        _fillOption: function (option, mapName) {
            // Shallow clone
            option = zrUtil.extend({}, option);

            option.data = geoCreator.getFilledRegions(option.data, mapName);

            return option;
        },
Example #16
0
        _renderMonthText: function (calendarModel, orient, group) {
            var monthLabel = calendarModel.getModel('monthLabel');

            if (!monthLabel.get('show')) {
                return;
            }

            var monthLabelStyleModel = calendarModel.getModel('monthLabel.textStyle');
            var nameMap = monthLabel.get('nameMap');
            var margin = monthLabel.get('margin');
            var pos = monthLabel.get('position');
            var align = monthLabel.get('align');

            var termPoints = [this._tlpoints, this._blpoints];

            if (zrUtil.isString(nameMap)) {
                nameMap = MONTH_TEXT[nameMap.toUpperCase()] || [];
            }

            var idx = pos === 'start' ? 0 : 1;
            var axis = orient === 'horizontal' ? 0 : 1;
            margin = pos === 'start' ? -margin : margin;
            var isCenter = (align === 'center');

            for (var i = 0; i < termPoints[idx].length - 1; i++) {

                var tmp = termPoints[idx][i].slice();
                var firstDay = this._firstDayOfMonth[i];

                if (isCenter) {
                    var firstDayPoints = this._firstDayPoints[i];
                    tmp[axis] = (firstDayPoints[axis] + termPoints[0][i + 1][axis]) / 2;
                }

                var formatter = monthLabel.get('formatter');
                var name = nameMap[+firstDay.m - 1];
                var params = {
                    yyyy: firstDay.y,
                    yy: (firstDay.y + '').slice(2),
                    MM: firstDay.m,
                    M: +firstDay.m,
                    nameMap: name
                };

                var content = this._formatterLabel(formatter, params);

                var monthText = new graphic.Text({
                    z2: 30,
                    style: zrUtil.extend({
                        text: content,
                        font: monthLabelStyleModel.getFont(),
                        fill: monthLabelStyleModel.getTextColor()
                    }, this._monthTextPositionControl(tmp, isCenter, orient, pos, margin))
                });

                group.add(monthText);
            }
        },
    var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
        var data = seriesModel.getData();
        // Special type markLine like 'min', 'max', 'average'
        var mlType = item.type;

        if (!zrUtil.isArray(item)
            && (mlType === 'min' || mlType === 'max' || mlType === 'average')
        ) {
            var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);

            var baseAxisKey = axisInfo.baseAxis.dim + 'Axis';
            var valueAxisKey = axisInfo.valueAxis.dim + 'Axis';
            var baseScaleExtent = axisInfo.baseAxis.scale.getExtent();

            var mlFrom = zrUtil.clone(item);
            var mlTo = {};

            mlFrom.type = null;

            // FIXME Polar should use circle
            mlFrom[baseAxisKey] = baseScaleExtent[0];
            mlTo[baseAxisKey] = baseScaleExtent[1];

            var value = markerHelper.numCalculate(data, axisInfo.valueDataDim, mlType);

            // Round if axis is cateogry
            value = axisInfo.valueAxis.coordToData(axisInfo.valueAxis.dataToCoord(value));

            var precision = mlModel.get('precision');
            if (precision >= 0) {
                value = +value.toFixed(precision);
            }

            mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value;

            item = [mlFrom, mlTo, { // Extra option for tooltip and label
                type: mlType,
                valueIndex: item.valueIndex,
                // Force to use the value of calculated value.
                value: value
            }];
        }

        item = [
            markerHelper.dataTransform(seriesModel, item[0]),
            markerHelper.dataTransform(seriesModel, item[1]),
            zrUtil.extend({}, item[2])
        ];

        // Avoid line data type is extended by from(to) data type
        item[2].type = item[2].type || '';

        // Merge from option and to option into line option
        zrUtil.merge(item[2], item[0]);
        zrUtil.merge(item[2], item[1]);

        return item;
    };
Example #18
0
        render: function (axisModel, ecModel, api, payload) {
            if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
                return;
            }

            this.axisModel = axisModel;
            this.api = api;

            this.group.removeAll();

            var oldAxisGroup = this._axisGroup;
            this._axisGroup = new graphic.Group();
            this.group.add(this._axisGroup);

            if (!axisModel.get('show')) {
                return;
            }

            var coordSys = ecModel.getComponent(
                'parallel', axisModel.get('parallelIndex')
            ).coordinateSystem;

            var areaSelectStyle = axisModel.getAreaSelectStyle();
            var areaWidth = areaSelectStyle.width;

            var dim = axisModel.axis.dim;
            var axisLayout = coordSys.getAxisLayout(dim);

            // Fetch from axisModel by default.
            var axisLabelShow;
            var axisIndex = zrUtil.indexOf(coordSys.dimensions, dim);

            var axisExpandWindow = axisLayout.axisExpandWindow;
            if (axisExpandWindow
                && (axisIndex <= axisExpandWindow[0] || axisIndex >= axisExpandWindow[1])
            ) {
                axisLabelShow = false;
            }

            var builderOpt = zrUtil.extend(
                {
                    axisLabelShow: axisLabelShow,
                    strokeContainThreshold: areaWidth
                },
                axisLayout
            );

            var axisBuilder = new AxisBuilder(axisModel, builderOpt);

            zrUtil.each(elementList, axisBuilder.add, axisBuilder);

            this._axisGroup.add(axisBuilder.getGroup());

            this._refreshBrushController(builderOpt, areaSelectStyle, axisModel, areaWidth);

            graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
        },
Example #19
0
 elGroup.eachChild(function (child) {
     child.setStyle(zrUtil.extend(
         lineStyleModel.getLineStyle(),
         {
             stroke: data.getItemVisual(idx, 'color'),
             opacity: data.getItemVisual(idx, 'opacity')
         }
     ));
 });
Example #20
0
    var setTextStyle = graphic.setTextStyle = function (
        textStyle, textStyleModel, specifiedTextStyle, opt, isEmphasis
    ) {
        setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
        specifiedTextStyle && zrUtil.extend(textStyle, specifiedTextStyle);
        textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);

        return textStyle;
    };
Example #21
0
    lineProto._updateCommonStl = function (lineData, idx) {
        var seriesModel = lineData.hostModel;

        var line = this.childOfName('line');
        var itemModel = lineData.getItemModel(idx);

        var labelModel = itemModel.getModel('label.normal');
        var textStyleModel = labelModel.getModel('textStyle');
        var labelHoverModel = itemModel.getModel('label.emphasis');
        var textStyleHoverModel = labelHoverModel.getModel('textStyle');

        var defaultText = numberUtil.round(seriesModel.getRawValue(idx));
        if (isNaN(defaultText)) {
            // Use name
            defaultText = lineData.getName(idx);
        }
        line.useStyle(zrUtil.extend(
            {
                strokeNoScale: true,
                fill: 'none',
                stroke: lineData.getItemVisual(idx, 'color')
            },
            itemModel.getModel('lineStyle.normal').getLineStyle()
        ));
        line.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
        var defaultColor = lineData.getItemVisual(idx, 'color') || '#000';
        var label = this.childOfName('label');
        // label.afterUpdate = lineAfterUpdate;
        label.setStyle({
            text: labelModel.get('show')
                ? zrUtil.retrieve(
                    seriesModel.getFormattedLabel(idx, 'normal', lineData),
                    defaultText
                )
                : '',
            textFont: textStyleModel.getFont(),
            fill: textStyleModel.getTextColor() || defaultColor
        });
        label.hoverStyle = {
            text: labelHoverModel.get('show')
                ? zrUtil.retrieve(
                    seriesModel.getFormattedLabel(idx, 'emphasis', lineData),
                    defaultText
                )
                : '',
            textFont: textStyleHoverModel.getFont(),
            fill: textStyleHoverModel.getTextColor() || defaultColor
        };
        label.__textAlign = textStyleModel.get('align');
        label.__verticalAlign = textStyleModel.get('baseline');
        label.__position = labelModel.get('position');

        label.ignore = !label.style.text && !label.hoverStyle.text;

        graphic.setHoverStyle(this);
    };
Example #22
0
        _fillOption: function (option) {
            // Shallow clone
            option = zrUtil.extend({}, option);

            var map = echarts.getMap(option.map);
            var geoJson = map && map.geoJson;
            geoJson && (option.data = fillData((option.data || []), geoJson));

            return option;
        },
Example #23
0
            controller.off('pan').on('pan', function (dx, dy) {
                this._mouseDownFlag = false;

                roamHelper.updateViewOnPan(controllerHost, dx, dy);

                api.dispatchAction(zrUtil.extend(makeActionBase(), {
                    dx: dx,
                    dy: dy
                }));
            }, this);
Example #24
0
 function getAnimatableProps(el) {
     var obj = {
         position: vector.clone(el.position),
         rotation: el.rotation
     };
     if (el.shape) {
         obj.shape = zrUtil.extend({}, el.shape);
     }
     return obj;
 }
Example #25
0
 // Remove unnecessary props to avoid potential problems.
 function getCleanedElOption(elOption) {
     elOption = zrUtil.extend({}, elOption);
     zrUtil.each(
         ['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
         function (name) {
             delete elOption[name];
         }
     );
     return elOption;
 }
Example #26
0
 graphic.setText = function (textStyle, labelModel, color) {
     var labelPosition = labelModel.getShallow('position') || 'inside';
     var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
     var textStyleModel = labelModel.getModel('textStyle');
     zrUtil.extend(textStyle, {
         textDistance: labelModel.getShallow('distance') || 5,
         textFont: textStyleModel.getFont(),
         textPosition: labelPosition,
         textFill: textStyleModel.getTextColor() || labelColor
     });
 };
Example #27
0
        function (option, parentModel, ecModel, extraOpt) {
            // Set dependentModels, componentIndex, name, id, mainType, subType.
            zrUtil.extend(this, extraOpt);

            this.uid = componentUtil.getUID('componentModel');

            this.setReadOnly([
                'type', 'id', 'uid', 'name', 'mainType', 'subType',
                'dependentModels', 'componentIndex'
            ]);
        }
Example #28
0
    var VisualMapping = function (option) {
        var mappingMethod = option.mappingMethod;
        var visualType = option.type;

        /**
         * @readOnly
         * @type {Object}
         */
        var thisOption = this.option = zrUtil.clone(option);

        /**
         * @readOnly
         * @type {string}
         */
        this.type = visualType;

        /**
         * @readOnly
         * @type {string}
         */
        this.mappingMethod = mappingMethod;

        /**
         * @private
         * @type {Function}
         */
        this._normalizeData = normalizers[mappingMethod];

        /**
         * @private
         * @type {Function}
         */
        this._getSpecifiedVisual = zrUtil.bind(
            specifiedVisualGetters[mappingMethod], this, visualType
        );

        zrUtil.extend(this, visualHandlers[visualType]);

        if (mappingMethod === 'piecewise') {
            normalizeVisualRange(thisOption);
            preprocessForPiecewise(thisOption);
        }
        else if (mappingMethod === 'category') {
            thisOption.categories
                ? preprocessForSpecifiedCategory(thisOption)
                // categories is ordinal when thisOption.categories not specified,
                // which need no more preprocess except normalize visual.
                : normalizeVisualRange(thisOption, true);
        }
        else { // mappingMethod === 'linear'
            zrUtil.assert(thisOption.dataExtent);
            normalizeVisualRange(thisOption);
        }
    };
Example #29
0
            graph.eachNode(function (node) {
                var layout = node.getLayout();
                var itemModel = node.getModel();
                var labelModel = itemModel.getModel('label.normal');
                var textStyleModel = labelModel.getModel('textStyle');
                var labelHoverModel = itemModel.getModel('label.emphasis');
                var textStyleHoverModel = labelHoverModel.getModel('textStyle');

                var rect = new graphic.Rect({
                    shape: {
                        x: layout.x,
                        y: layout.y,
                        width: node.getLayout().dx,
                        height: node.getLayout().dy
                    },
                    style: {
                        // Get formatted label in label.normal option
                        //  Use node id if it is not specified
                        text: labelModel.get('show')
                            ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
                            // Use empty string to hide the label
                            : '',
                        textFont: textStyleModel.getFont(),
                        textFill: textStyleModel.getTextColor(),
                        textPosition: labelModel.get('position')
                    }
                });

                rect.setStyle(zrUtil.defaults(
                    {
                        fill: node.getVisual('color')
                    },
                    itemModel.getModel('itemStyle.normal').getItemStyle()
                ));

                graphic.setHoverStyle(rect, zrUtil.extend(
                    node.getModel('itemStyle.emphasis'),
                    {
                        text: labelHoverModel.get('show')
                            ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
                            : '',
                        textFont: textStyleHoverModel.getFont(),
                        textFill: textStyleHoverModel.getTextColor(),
                        textPosition: labelHoverModel.get('position')
                    }
                ));

                group.add(rect);

                nodeData.setItemGraphicEl(node.dataIndex, rect);

                rect.dataType = 'node';
            });
Example #30
0
 function setLabelStyle(style, data, idx, state, labelModel, specifiedStyle) {
     var position = labelModel.get('position');
     var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
     return graphic.setTextStyle(style, labelModel, zrUtil.extend({
         textFill: labelModel.getTextColor()
             || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
         text: zrUtil.retrieve(
             data.hostModel.getFormattedLabel(idx, state),
             data.getName(idx)
         )
     }, specifiedStyle), {mergeMode: true});
 }