AxisModel.js 1.6 KB
Newer Older
S
sushuang 已提交
1
import * as zrUtil from 'zrender/core/util';
S
sushuang 已提交
2 3 4
import ComponentModel from '../../model/Component';
import axisModelCreator from '../axisModelCreator';
import axisModelCommonMixin from '../axisModelCommonMixin';
D
deqingli 已提交
5

S
sushuang 已提交
6
var AxisModel = ComponentModel.extend({
D
deqingli 已提交
7

S
sushuang 已提交
8
    type: 'singleAxis',
D
deqingli 已提交
9

S
sushuang 已提交
10
    layoutMode: 'box',
D
deqingli 已提交
11

S
sushuang 已提交
12 13 14 15
    /**
     * @type {module:echarts/coord/single/SingleAxis}
     */
    axis: null,
D
deqingli 已提交
16

S
sushuang 已提交
17 18 19 20
    /**
     * @type {module:echarts/coord/single/Single}
     */
    coordinateSystem: null,
1
100pah 已提交
21

S
sushuang 已提交
22 23 24 25 26 27
    /**
     * @override
     */
    getCoordSysModel: function () {
        return this;
    }
D
deqingli 已提交
28

S
sushuang 已提交
29 30 31 32 33 34 35 36 37 38
});

var defaultOption = {

    left: '5%',
    top: '5%',
    right: '5%',
    bottom: '5%',

    type: 'value',
D
deqingli 已提交
39

S
sushuang 已提交
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
    position: 'bottom',

    orient: 'horizontal',

    axisLine: {
        show: true,
        lineStyle: {
            width: 2,
            type: 'solid'
        }
    },

    // Single coordinate system and single axis is the,
    // which is used as the parent tooltip model.
    // same model, so we set default tooltip show as true.
    tooltip: {
        show: true
    },

    axisTick: {
        show: true,
        length: 6,
        lineStyle: {
            width: 2
        }
    },

    axisLabel: {
        show: true,
        interval: 'auto'
    },

    splitLine: {
        show: true,
        lineStyle: {
            type: 'dashed',
            opacity: 0.2
        }
D
deqingli 已提交
78
    }
S
sushuang 已提交
79 80 81 82 83
};

function getAxisType(axisName, option) {
    return option.type || (option.data ? 'category' : 'value');
}
D
deqingli 已提交
84

S
sushuang 已提交
85
zrUtil.merge(AxisModel.prototype, axisModelCommonMixin);
D
deqingli 已提交
86

S
sushuang 已提交
87
axisModelCreator('single', AxisModel, getAxisType, defaultOption);
D
deqingli 已提交
88

S
sushuang 已提交
89
export default AxisModel;