MarkLineModel.js 4.6 KB
Newer Older
L
lang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
define(function (require) {

    // Default enable markLine
    var globalDefault = require('../../model/globalDefault');
    globalDefault.markLine = {};

    var MarkLineModel = require('../../echarts').extendComponentModel({

        type: 'markLine',

        dependencies: ['series', 'grid', 'polar'],
        /**
         * @overrite
         */
        init: function (option, parentModel, ecModel, dependentModels, idx, createdBySelf) {
            this.mergeDefaultAndTheme(option, ecModel);
            this.mergeOption(option, createdBySelf);
        },

        mergeOption: function (newOpt, createdBySelf) {
            if (!createdBySelf) {
                var ecModel = this.ecModel;
                ecModel.eachSeries(function (seriesModel) {
                    var markLineOpt = seriesModel.get('markLine');
                    if (markLineOpt && markLineOpt.data) {
                        var mlModel = seriesModel.markLineModel;
                        if (!mlModel) {
                            mlModel = new MarkLineModel(
                                markLineOpt, this, ecModel, [], 0, true
                            );
                        }
                        else {
                            mlModel.mergeOption(markLineOpt, true);
                        }
                        // Use the same series index
                        mlModel.seriesIndex = seriesModel.seriesIndex;
                        seriesModel.markLineModel = mlModel;
                    }
                    else {
                        seriesModel.markLineModel = null;
                    }
                }, this);
            }
        },

        defaultOption: {
            zlevel: 0,
            z: 5,
            clickable: true,
            // 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string
            symbol: ['circle', 'arrow'],
            // 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
            symbolSize: [2, 4],
            // 标线起始和结束的symbol旋转控制
            //symbolRotate: null,
            //smooth: false,
            smoothness: 0.2,    // 平滑度
            precision: 2,
            effect: {
                show: false,
                loop: true,
                period: 15,                     // 运动周期,无单位,值越大越慢
                scaleSize: 2                    // 放大倍数,以markLine线lineWidth为基准
                // color: 'gold',
                // shadowColor: 'rgba(255,215,0,0.8)',
                // shadowBlur: lineWidth * 2    // 炫光模糊,默认等于scaleSize计算所得
            },
            // 边捆绑
            bundling: {
                enable: false,
                // [0, 90]
                maxTurningAngle: 45
            },
            itemStyle: {
                normal: {
                    // color: 各异,               // 标线主色,线色,symbol主色
                    // borderColor: 随color,     // 标线symbol边框颜色,优先于color
                    borderWidth: 1.5,           // 标线symbol边框线宽,单位px,默认为2
                    label: {
                        show: true,
                        // 标签文本格式器,同Tooltip.formatter,不支持回调
                        // formatter: null,
                        // 可选为 'start'|'end'|'left'|'right'|'top'|'bottom'
                        position: 'end'
                        // textStyle: null      // 默认使用全局文本样式,详见TEXTSTYLE
                    },
                    lineStyle: {
                        // color: 随borderColor, // 主色,线色,优先级高于borderColor和color
                        // width: 随borderWidth, // 优先于borderWidth
                        type: 'dashed'
                        // shadowColor: 'rgba(0,0,0,0)', //默认透明
                        // shadowBlur: 0,
                        // shadowOffsetX: 0,
                        // shadowOffsetY: 0
                    }
                },
                emphasis: {
                    // color: 各异
                    label: {
                        show: false
                        // 标签文本格式器,同Tooltip.formatter,不支持回调
                        // formatter: null,
                        // position: 'inside' // 'left'|'right'|'top'|'bottom'
                        // textStyle: null    // 默认使用全局文本样式,详见TEXTSTYLE
                    },
                    lineStyle: {}
                }
            }
        }
    });

    return MarkLineModel;
});