PieSeries.js 3.3 KB
Newer Older
L
lang 已提交
1 2 3 4 5
define(function(require) {

    'use strict';

    var List = require('../../data/List');
6
    var SeriesModel = require('../../model/Series');
L
lang 已提交
7
    var zrUtil = require('zrender/core/util');
L
lang 已提交
8

9 10 11
    var dataSelectableMixin = require('../helper/dataSelectableMixin');

    var PieSeries = SeriesModel.extend({
L
lang 已提交
12

L
Add pie  
lang 已提交
13
        type: 'series.pie',
L
lang 已提交
14

L
lang 已提交
15 16
        init: function (option) {
            SeriesModel.prototype.init.apply(this, arguments);
L
lang 已提交
17 18 19 20 21

            // Enable legend selection for each data item
            // Use a function instead of direct access because data reference may changed
            this.legendDataProvider = function () {
                return this._dataBeforeProcessed;
L
lang 已提交
22
            };
23 24 25 26 27 28 29

            this.updateSelectedMap();
        },

        mergeOption: function (newOption) {
            SeriesModel.prototype.mergeOption.call(this, newOption);
            this.updateSelectedMap();
L
lang 已提交
30 31
        },

L
Add pie  
lang 已提交
32 33
        getInitialData: function (option, ecModel) {
            var list = new List([{
L
lang 已提交
34
                name: 'value',
L
Add pie  
lang 已提交
35 36 37 38 39 40 41 42 43 44 45 46
                stackable: true
            }], this);
            list.initData(option.data);
            return list;
        },

        defaultOption: {
            zlevel: 0,
            z: 2,
            legendHoverLink: true,
            // 默认全局居中
            center: ['50%', '50%'],
47
            radius: [0, '40%'],
L
Add pie  
lang 已提交
48 49 50 51 52 53 54
            // 默认顺时针
            clockWise: true,
            startAngle: 90,
            // 最小角度改为0
            minAngle: 0,
            // 选中是扇区偏移量
            selectedOffset: 10,
L
lang 已提交
55
            avoidLabelOverlap: true,
L
Add pie  
lang 已提交
56 57 58 59
            // 选择模式,默认关闭,可选single,multiple
            // selectedMode: false,
            // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
            // roseType: null,
60 61 62

            label: {
                normal: {
L
lang 已提交
63 64
                    // If rotate around circle
                    rotate: false,
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
                    show: true,
                    // 'outer', 'inside', 'center'
                    position: 'outer'
                    // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
                    // textStyle: null      // 默认使用全局文本样式,详见TEXTSTYLE
                    // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
                },
                emphasis: {}
            },
            // Enabled when label.normal.position is 'outer'
            labelLine: {
                show: true,
                // 引导线两段中的第一段长度
                length: 20,
                // 引导线两段中的第二段长度
                length2: 5,
                lineStyle: {
                    // color: 各异,
                    width: 1,
                    type: 'solid'
                }
            },
L
Add pie  
lang 已提交
87 88 89 90
            itemStyle: {
                normal: {
                    // color: 各异,
                    borderColor: 'rgba(0,0,0,0)',
91
                    borderWidth: 1
L
Add pie  
lang 已提交
92 93 94 95
                },
                emphasis: {
                    // color: 各异,
                    borderColor: 'rgba(0,0,0,0)',
96
                    borderWidth: 1
L
Add pie  
lang 已提交
97 98
                }
            }
L
lang 已提交
99 100
        }
    });
101 102 103 104

    zrUtil.mixin(PieSeries, dataSelectableMixin);

    return PieSeries;
L
lang 已提交
105
});