提交 2e9fc90b 编写于 作者: P pah100

Merge branch 'master' of https://github.com/pissang/echarts-next

......@@ -12,5 +12,5 @@ define(function (require) {
require('./pie/pieLayout'), 'pie'
));
echarts.registerProcessor(require('./pie/dataItemFilter'));
echarts.registerProcessor('filter', require('./pie/dataItemFilter'));
});
\ No newline at end of file
......@@ -7,7 +7,7 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
var linearMap = require('../../util/number').linearMap;
echarts.registerProcessor(function (ecModel) {
echarts.registerProcessor('filter', function (ecModel) {
ecModel.eachComponent('dataZoom', function (dataZoomModel) {
dataZoomModel.eachTargetAxis(processSingleAxis);
});
......
......@@ -9,5 +9,5 @@ define(function (require) {
var echarts = require('../echarts');
// Series Filter
echarts.registerProcessor(require('./legend/legendFilter'));
echarts.registerProcessor('filter', require('./legend/legendFilter'));
});
\ No newline at end of file
......@@ -59,6 +59,16 @@ define(function(require, factory) {
&& axis.type !== CATEGORY_AXIS_TYPE
}
function niceScaleExent(axis, model) {
if (axis.scale.type === 'ordinal') {
return;
}
var min = model.get('min');
var max = model.get('max');
axis.scale.setExtent(min, max);
axis.scale.niceExtent(model.get('splitNumber'), !!min, !!max);
}
function Grid(gridModel, ecModel, api) {
/**
......@@ -233,7 +243,6 @@ define(function(require, factory) {
this._updateCartesianFromSeries(ecModel, gridModel);
// Fix configuration
zrUtil.each(axesMap.x, function (xAxis) {
zrUtil.each(axesMap.y, function (yAxis) {
......@@ -253,9 +262,13 @@ define(function(require, factory) {
if (ifAxisNeedsCrossZero(yAxis, xAxis)) {
yAxis.scale.unionExtent([0, 0]);
niceScaleExent(yAxis, yAxis.model);
}
if (ifAxisNeedsCrossZero(xAxis, yAxis)) {
xAxis.scale.unionExtent([0, 0]);
niceScaleExent(xAxis, xAxis.model);
}
}, this);
......@@ -337,16 +350,6 @@ define(function(require, factory) {
}
}
}, this);
function niceScaleExent(axis, model) {
if (axis.scale.type === 'ordinal') {
return;
}
var min = model.get('min');
var max = model.get('max');
axis.scale.setExtent(min, max);
axis.scale.niceExtent(model.get('splitNumber'), !!min, !!max);
}
}
};
......
......@@ -12,8 +12,7 @@ define(function(require) {
var labelModel = axisModel.getModel('axisLabel');
var labelInterval = labelModel.get('interval');
if (
!(axis.isHorizontal()
&& axis.type === 'category'
!(axis.type === 'category'
&& labelInterval === 'auto'
&& !labelModel.get('rotate'))
) {
......@@ -29,13 +28,15 @@ define(function(require) {
var autoLabelInterval = 0;
var accumulatedLabelInterval = 0;
var isAxisHorizontal = axis.isHorizontal();
for (var i = 0; i < ticks.length; i++) {
var tick = ticks[i];
var tickCoord = axis.dataToCoord(tick);
var rect = textContain.getBoundingRect(
labels[i], font, 'center', 'top'
);
rect.x += tickCoord;
rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
if (!textSpaceTakenRect) {
textSpaceTakenRect = rect.clone();
}
......
/**
* TODO visualCoding 的优先级
* setTheme
* TODO setTheme
* axis position 统一处理
* 规范 Symbol 配置和绘制, customPath
*
......@@ -23,6 +22,8 @@ define(function (require) {
var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component'];
var PROCESSOR_STAGES = ['transform', 'filter', 'statistic'];
/**
* @module echarts~ECharts
*/
......@@ -253,7 +254,7 @@ define(function (require) {
for (var i = 0; i < chartsList.length;) {
var chart = chartsList[i];
if (! chart.__keepAlive) {
if (!chart.__keepAlive) {
zr.remove(chart.group);
chart.dispose(this._extensionAPI);
chartsList.splice(i, 1);
......@@ -323,8 +324,10 @@ define(function (require) {
* @private
*/
_processData: function (ecModel) {
zrUtil.each(dataProcessorFuncs, function (processor) {
processor(ecModel);
zrUtil.each(PROCESSOR_STAGES, function (stage) {
zrUtil.each(dataProcessorFuncs[stage] || [], function (process) {
process(ecModel);
});
});
},
......@@ -436,14 +439,36 @@ define(function (require) {
};
var dataProcessorFuncs = [];
/**
* @type {Array.<Function>}
* @inner
*/
var actions = [];
/**
* @type {Array.<Function>}
* @inner
*/
var layoutClasses = [];
/**
* @type {Array.<Function>}
* @inner
*/
var layoutFuncs = [];
/**
* Data processor functions of each stage
* @type {Array.<Object.<string, Function>>}
* @inner
*/
var dataProcessorFuncs = {};
/**
* Visual coding functions of each stage
* @type {Array.<Object.<string, Function>>}
* @inner
*/
var visualCodingFuncs = {};
/**
......@@ -451,17 +476,25 @@ define(function (require) {
*/
var echarts = {
/**
* @param {HTMLDomElement} dom
* @param {Object} [theme]
* @param {Object} opts
*/
init: function (dom, theme, opts) {
return new ECharts(dom, theme, opts);
},
/**
* @param {Function}
* @param {string} stage
* @param {Function} processorFunc
*/
registerProcessor: function (processorFunc) {
if (zrUtil.indexOf(dataProcessorFuncs, processorFunc) < 0) {
dataProcessorFuncs.push(processorFunc);
registerProcessor: function (stage, processorFunc) {
if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) {
throw new Error('stage should be one of ' + PROCESSOR_STAGES);
}
var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []);
funcs.push(processorFunc);
},
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册