提交 3438bb1d 编写于 作者: L lang

Export helper methods, some tweaks for better interface

上级 07b819d1
......@@ -8,7 +8,7 @@ define(function (require) {
// FIXME Use data dimensions ?
lineData.each(function (idx) {
var itemModel = lineData.getItemModel(idx);
// TODO Support pure array
var coords = (itemModel.option instanceof Array) ?
itemModel.option : itemModel.get('coords');
......
......@@ -9,7 +9,7 @@ define(function (require) {
type: 'series.scatter',
dependencies: ['grid', 'polar'],
dependencies: ['grid', 'polar', 'geo', 'singleAxis'],
getInitialData: function (option, ecModel) {
var list = createListFromArray(option.data, this, ecModel);
......
......@@ -41,7 +41,7 @@ define(function (require) {
zrUtil.each(elementList, function (name) {
if (angleAxisModel.get(name +'.show')
&& (!angleAxis.isBlank() || name === 'axisLine')
&& (!angleAxis.scale.isBlank() || name === 'axisLine')
) {
this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
}
......
......@@ -173,7 +173,7 @@ define(function (require) {
var axisModel = this.axisModel;
var axis = axisModel.axis;
if (!axisModel.get('axisTick.show') || axis.isBlank()) {
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
return;
}
......@@ -243,7 +243,7 @@ define(function (require) {
var axis = axisModel.axis;
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
if (!show || axis.isBlank()) {
if (!show || axis.scale.isBlank()) {
return;
}
......
......@@ -66,7 +66,7 @@ define(function (require) {
_splitLine: function (axisModel, gridModel, labelInterval) {
var axis = axisModel.axis;
if (axis.isBlank()) {
if (axis.scale.isBlank()) {
return;
}
......@@ -140,7 +140,7 @@ define(function (require) {
_splitArea: function (axisModel, gridModel, labelInterval) {
var axis = axisModel.axis;
if (axis.isBlank()) {
if (axis.scale.isBlank()) {
return;
}
......
......@@ -36,7 +36,7 @@ define(function (require) {
this.group.add(axisBuilder.getGroup());
zrUtil.each(selfBuilderAttrs, function (name) {
if (radiusAxisModel.get(name +'.show') && !radiusAxis.isBlank()) {
if (radiusAxisModel.get(name +'.show') && !radiusAxis.scale.isBlank()) {
this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
}
}, this);
......
......@@ -38,7 +38,7 @@ define(function (require) {
_splitLine: function(axisModel, labelInterval) {
var axis = axisModel.axis;
if (axis.isBlank()) {
if (axis.scale.isBlank()) {
return;
}
......
......@@ -616,7 +616,7 @@ define(function (require) {
axisType = baseAxis.dim;
}
if (baseAxis.isBlank() || zrUtil.eqNaN(point[0]) || zrUtil.eqNaN(point[1])) {
if (baseAxis.scale.isBlank() || zrUtil.eqNaN(point[0]) || zrUtil.eqNaN(point[1])) {
this._hideAxisPointer(coordSys.name);
return;
}
......
......@@ -213,24 +213,7 @@ define(function (require) {
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
},
/**
* When axis extent depends on data and no data exists,
* axis ticks should not be drawn, which is named 'blank'.
*/
isBlank: function () {
return this._isBlank;
},
/**
* When axis extent depends on data and no data exists,
* axis ticks should not be drawn, which is named 'blank'.
*/
setBlank: function (isBlank) {
this._isBlank = isBlank;
}
};
return Axis;
......
......@@ -15,8 +15,7 @@ define(function (require) {
* Get axis scale extent before niced.
* Item of returned array can only be number (including Infinity and NaN).
*/
axisHelper.getScaleExtent = function (axis, model) {
var scale = axis.scale;
axisHelper.getScaleExtent = function (scale, model) {
var scaleType = scale.type;
var min = model.getMin();
......@@ -62,7 +61,7 @@ define(function (require) {
(min == null || !isFinite(min)) && (min = NaN);
(max == null || !isFinite(max)) && (max = NaN);
axis.setBlank(zrUtil.eqNaN(min) || zrUtil.eqNaN(max));
scale.setBlank(zrUtil.eqNaN(min) || zrUtil.eqNaN(max));
// Evaluate if axis needs cross zero
if (model.getNeedCrossZero()) {
......@@ -79,9 +78,8 @@ define(function (require) {
return [min, max];
};
axisHelper.niceScaleExtent = function (axis, model) {
var scale = axis.scale;
var extent = axisHelper.getScaleExtent(axis, model);
axisHelper.niceScaleExtent = function (scale, model) {
var extent = axisHelper.getScaleExtent(scale, model);
var fixMin = model.getMin() != null;
var fixMax = model.getMax() != null;
var splitNumber = model.get('splitNumber');
......
......@@ -111,10 +111,10 @@ define(function(require, factory) {
}
each(axesMap.x, function (xAxis) {
niceScaleExtent(xAxis, xAxis.model);
niceScaleExtent(xAxis.scale, xAxis.model);
});
each(axesMap.y, function (yAxis) {
niceScaleExtent(yAxis, yAxis.model);
niceScaleExtent(yAxis.scale, yAxis.model);
});
// Fix configuration
each(axesMap.x, function (xAxis) {
......
......@@ -117,7 +117,7 @@ define(function(require) {
each(this.dimensions, function (dim) {
var axis = this._axesMap[dim];
axis.scale.unionExtentFromData(data, dim);
axisHelper.niceScaleExtent(axis, axis.model);
axisHelper.niceScaleExtent(axis.scale, axis.model);
}, this);
}, this);
},
......
......@@ -51,8 +51,8 @@ define(function (require) {
}
});
niceScaleExtent(angleAxis, angleAxis.model);
niceScaleExtent(radiusAxis, radiusAxis.model);
niceScaleExtent(angleAxis.scale, angleAxis.model);
niceScaleExtent(radiusAxis.scale, radiusAxis.model);
// Fix extent of category angle axis
if (angleAxis.type === 'category' && !angleAxis.onBand) {
......
......@@ -151,8 +151,8 @@ define(function (require) {
}
// Force all the axis fixing the maxSplitNumber.
zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
var rawExtent = axisHelper.getScaleExtent(indicatorAxis, indicatorAxis.model);
axisHelper.niceScaleExtent(indicatorAxis, indicatorAxis.model);
var rawExtent = axisHelper.getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
axisHelper.niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
var axisModel = indicatorAxis.model;
var scale = indicatorAxis.scale;
......
......@@ -99,7 +99,7 @@ define(function (require) {
this._axis.scale.unionExtentFromData(
data, seriesModel.coordDimToDataDim(dim)
);
axisHelper.niceScaleExtent(this._axis, this._axis.model);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
},
......
......@@ -649,7 +649,7 @@ define(function (require) {
* @private
*/
update: function (payload) {
// console.time && console.time('update');
// console.profile && console.profile('update');
var ecModel = this._model;
var api = this._api;
......@@ -726,7 +726,7 @@ define(function (require) {
func(ecModel, api);
});
// console.time && console.timeEnd('update');
// console.profile && console.profileEnd('update');
},
/**
......@@ -1893,6 +1893,8 @@ define(function (require) {
}
);
echarts.helper = require('./helper');
// PRIORITY
echarts.PRIORITY = {
PROCESSOR: {
......
define(function (require) {
var createListFromArray = require('./chart/helper/createListFromArray');
// var axisHelper = require('./coord/axisHelper');
return {
createList: function (seriesModel) {
var data = seriesModel.get('data');
return createListFromArray(data, seriesModel, seriesModel.ecModel);
}
// createScale: function () {
// }
};
});
\ No newline at end of file
......@@ -64,11 +64,15 @@ define(function(require) {
this.mergeDefaultAndTheme(option, ecModel);
var data = this.getInitialData(option, ecModel);
if (__DEV__) {
zrUtil.assert(data, 'getInitialData returned invalid data.');
}
/**
* @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
* @private
*/
set(this, 'dataBeforeProcessed', this.getInitialData(option, ecModel));
set(this, 'dataBeforeProcessed', data);
// If we reverse the order (make data firstly, and then make
// dataBeforeProcessed by cloneShallow), cloneShallow will
......
......@@ -123,6 +123,23 @@ define(function (require) {
return labels;
};
/**
* When axis extent depends on data and no data exists,
* axis ticks should not be drawn, which is named 'blank'.
*/
scaleProto.isBlank = function () {
return this._isBlank;
},
/**
* When axis extent depends on data and no data exists,
* axis ticks should not be drawn, which is named 'blank'.
*/
scaleProto.setBlank = function (isBlank) {
this._isBlank = isBlank;
};
clazzUtil.enableClassExtend(Scale);
clazzUtil.enableClassManagement(Scale, {
registerWhenExtend: true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册