createAxis3DModel.js
2.1 KB
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
import * as echarts from 'echarts/lib/echarts';
import axisDefault from './axis3DDefault';
import OrdinalMeta from 'echarts/lib/data/OrdinalMeta';
var AXIS_TYPES = ['value', 'category', 'time', 'log'];
/**
* Generate sub axis model class
* @param {} registers
* @param {string} dim 'x' 'y' 'radius' 'angle' 'parallel'
* @param {module:echarts/model/Component} BaseAxisModelClass
* @param {Function} axisTypeDefaulter
* @param {Object} [extraDefaultOption]
*/
export default function (registers, dim, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
AXIS_TYPES.forEach(function (axisType) {
var AxisModel = BaseAxisModelClass.extend({
type: dim + 'Axis3D.' + axisType,
/**
* @type readOnly
*/
__ordinalMeta: null,
mergeDefaultAndTheme: function (option, ecModel) {
var themeModel = ecModel.getTheme();
echarts.util.merge(option, themeModel.get(axisType + 'Axis3D'));
echarts.util.merge(option, this.getDefaultOption());
option.type = axisTypeDefaulter(dim, option);
},
/**
* @override
*/
optionUpdated: function () {
var thisOption = this.option;
if (thisOption.type === 'category') {
this.__ordinalMeta = OrdinalMeta.createByAxisModel(this);
}
},
getCategories: function () {
if (this.option.type === 'category') {
return this.__ordinalMeta.categories;
}
},
getOrdinalMeta: function () {
return this.__ordinalMeta;
},
defaultOption: echarts.util.merge(
echarts.util.clone(axisDefault[axisType + 'Axis3D']),
extraDefaultOption || {},
true
)
});
registers.registerComponentModel(AxisModel);
});
// TODO
registers.registerSubTypeDefaulter(
dim + 'Axis3D',
echarts.util.curry(axisTypeDefaulter, dim)
);
};