提交 1b4e5e30 编写于 作者: P pah100

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

{
// appDir: './',
// baseUrl: '../src',
// optimize: 'none',
name: 'echarts',
packages: [
{
name: 'zrender',
location: '../../zrender-dev3.0/src',
main: 'zrender'
},
{
name: 'echarts',
location: '../src',
main: 'echarts'
}
],
include:[
'echarts/chart/line',
'echarts/chart/bar',
'echarts/chart/scatter',
'echarts/component/legend',
'echarts/component/grid',
'echarts/component/polar',
'echarts/component/dataZoom'
],
out: 'echarts.js'
}
\ No newline at end of file
此差异已折叠。
...@@ -78,7 +78,6 @@ define(function(require) { ...@@ -78,7 +78,6 @@ define(function(require) {
var p2 = []; var p2 = [];
var lineStyleModel = axisModel.getModel('axisLine.lineStyle'); var lineStyleModel = axisModel.getModel('axisLine.lineStyle');
var lineWidth = lineStyleModel.get('width');
var coordExtent = axis.getExtent(); var coordExtent = axis.getExtent();
if (axis.isHorizontal()) { if (axis.isHorizontal()) {
......
...@@ -19,11 +19,11 @@ define(function(require) { ...@@ -19,11 +19,11 @@ define(function(require) {
var list = new List(); var list = new List();
zrUtil.each(option.data, function (dataItem) { zrUtil.each(option.data, function (dataItem) {
if (typeof dataItem === 'string') { if (typeof dataItem === 'string') {
list.append(dataItem, {}); dataItem = {
} name: dataItem
else { };
list.append(dataItem.name, dataItem);
} }
list.add(dataItem, this);
}); });
/** /**
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
*/ */
define(function(require, factory) { define(function(require, factory) {
'use strict';
var zrUtil = require('zrender/core/util'); var zrUtil = require('zrender/core/util');
var Cartesian2D = require('./Cartesian2D'); var Cartesian2D = require('./Cartesian2D');
var Axis2D = require('./Axis2D'); var Axis2D = require('./Axis2D');
...@@ -178,65 +176,20 @@ define(function(require, factory) { ...@@ -178,65 +176,20 @@ define(function(require, factory) {
var leftUsed = false; var leftUsed = false;
var bottomUsed = false; var bottomUsed = false;
var xAxesMap = {}; var axesMap = {
var yAxesMap = {}; x: {},
var xAxesCount = 0; y: {}
var yAxesCount = 0; };
var axesCount = {
ecModel.eachComponent('xAxis', function (xAxisModel, idx) { x: 0,
if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)) { y: 0
return; };
}
// Create x axis
var xAxisPosition = xAxisModel.get('position') || (bottomUsed ? 'top' : 'bottom');
bottomUsed = xAxisPosition === 'bottom';
var axisX = new Axis2D(
'x', createScaleByModel(xAxisModel),
[0, 0],
xAxisModel.get('type'),
xAxisPosition
);
axisX.onBand = xAxisModel.get('boundaryGap') && axisX.type === 'category';
axisX.inverse = xAxisModel.get('inverse');
// Inject axis into axisModel
xAxisModel.axis = axisX;
this._axesList.push(axisX);
this._axesMap['x' + idx] = axisX;
xAxesMap[idx] = axisX;
xAxesCount++;
}, this);
ecModel.eachComponent('yAxis', function (yAxisModel, idx) {
if (!isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)) {
return;
}
// Create y axis
var yAxisPosition = yAxisModel.get('position') || (leftUsed ? 'right' : 'left');
leftUsed = yAxisPosition === 'left';
var axisY = new Axis2D(
'y', createScaleByModel(yAxisModel),
[0, 0],
yAxisModel.get('type'),
yAxisModel.get('position')
);
axisY.onBand = yAxisModel.get('boundaryGap') && axisY.type === 'category';
axisY.inverse = yAxisModel.get('inverse');
yAxisModel.axis = axisY;
this._axesList.push(axisY); ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
this._axesMap['y' + idx] = axisY;
yAxesMap[idx] = axisY; ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
yAxesCount++;
}, this);
if (! xAxesCount || ! yAxesCount) { if (! axesCount.x || ! axesCount.y) {
api.log('Grid must has at least one x axis and one y axis'); api.log('Grid must has at least one x axis and one y axis');
// Roll back // Roll back
this._axesMap = {}; this._axesMap = {};
...@@ -244,8 +197,8 @@ define(function(require, factory) { ...@@ -244,8 +197,8 @@ define(function(require, factory) {
return; return;
} }
zrUtil.each(xAxesMap, function (xAxis, xAxisIndex) { zrUtil.each(axesMap.x, function (xAxis, xAxisIndex) {
zrUtil.each(yAxesMap, function (yAxis, yAxisIndex) { zrUtil.each(axesMap.y, function (yAxis, yAxisIndex) {
var key = 'x' + xAxisIndex + 'y' + yAxisIndex; var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
var cartesian = new Cartesian2D(key); var cartesian = new Cartesian2D(key);
this._coordsMap[key] = cartesian; this._coordsMap[key] = cartesian;
...@@ -257,6 +210,38 @@ define(function(require, factory) { ...@@ -257,6 +210,38 @@ define(function(require, factory) {
}, this); }, this);
this._updateCartesianFromSeries(ecModel, gridModel); this._updateCartesianFromSeries(ecModel, gridModel);
function createAxisCreator(axisType) {
return function (axisModel, idx) {
if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
return;
}
var axisPosition = axisType === 'x'
? axisModel.get('position') || (bottomUsed ? 'top' : 'bottom')
: axisModel.get('position') || (leftUsed ? 'right' : 'left');
var axis = new Axis2D(
axisType, createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisPosition
);
axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
axis.inverse = axisModel.get('inverse');
// Inject axis into axisModel
axisModel.axis = axis;
this._axesList.push(axis);
this._axesMap[axisType + idx] = axis;
axesMap[axisType][idx] = axis;
axesCount[axisType]++;
}
}
}, },
/** /**
...@@ -320,23 +305,32 @@ define(function(require, factory) { ...@@ -320,23 +305,32 @@ define(function(require, factory) {
var xAxis = cartesian.getAxis('x'); var xAxis = cartesian.getAxis('x');
var yAxis = cartesian.getAxis('y'); var yAxis = cartesian.getAxis('y');
if (axisData.x.length) { if (axisData.x.length) {
if (axisData.xModel.get('scale')) { var xModel = axisData.xModel;
if (xModel.get('scale')) {
axisData.x.push(0); axisData.x.push(0);
} }
xAxis.scale.setExtentFromData(axisData.x); xAxis.scale.setExtentFromData(axisData.x);
niceScaleExent(xAxis, xModel);
} }
if (axisData.y.length) { if (axisData.y.length) {
if (axisData.yModel.get('scale')) { var yModel = axisData.yModel;
if (yModel.get('scale')) {
axisData.y.push(0); axisData.y.push(0);
} }
yAxis.scale.setExtentFromData(axisData.y); yAxis.scale.setExtentFromData(axisData.y);
niceScaleExent(yAxis, yModel);
} }
}); });
// Set axis from option function niceScaleExent(axis, model) {
zrUtil.each(this._axesList, function (axis) { var min = model.get('min');
axis.scale.niceExtent(); var max = model.get('max');
}); axis.scale.setExtent(min, max);
axis.scale.niceExtent(model.get('splitNumber'), !!min, !!max);
}
} }
}; };
......
...@@ -238,12 +238,12 @@ define(function(require) { ...@@ -238,12 +238,12 @@ define(function(require) {
/** /**
* Create and add a new entry * Create and add a new entry
* @param {Object} option * @param {Object} option
* @param {module:echarts/model/Series} seriesModel * @param {module:echarts/model/Model} parentModel
* @return {module:echarts/data/List~Entry} * @return {module:echarts/data/List~Entry}
*/ */
add: function (option, seriesModel) { add: function (option, parentModel) {
var elements = this.elements; var elements = this.elements;
var entry = new Entry(option, seriesModel, elements.length, this.dimensions, this.value); var entry = new Entry(option, parentModel, elements.length, this.dimensions, this.value);
elements.push(entry); elements.push(entry);
return entry; return entry;
}, },
...@@ -300,18 +300,6 @@ define(function(require) { ...@@ -300,18 +300,6 @@ define(function(require) {
} }
}, },
/**
* @param {string} name
* @param {*} option
*/
append: function (name, option) {
var elements = this.elements;
var el = new Entry(option, null, elements.length);
el.name = name;
elements.push(el);
return el;
},
/** /**
* Get the diff result with the old list data * Get the diff result with the old list data
* @param {module:echarts/data/List} oldList * @param {module:echarts/data/List} oldList
......
...@@ -71,11 +71,8 @@ define(function (require) { ...@@ -71,11 +71,8 @@ define(function (require) {
var max = union ? extent[1] : -Infinity; var max = union ? extent[1] : -Infinity;
var min = union ? extent[0] : Infinity; var min = union ? extent[0] : Infinity;
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (data[i] == null || data[i] === '-') { data[i] > max && (max = data[i]);
continue; data[i] < min && (min = data[i]);
}
max = Math.max(data[i], max);
min = Math.min(data[i], min);
} }
this.setExtent(min, max); this.setExtent(min, max);
...@@ -96,8 +93,12 @@ define(function (require) { ...@@ -96,8 +93,12 @@ define(function (require) {
*/ */
setExtent: function (start, end) { setExtent: function (start, end) {
var thisExtent = this._extent; var thisExtent = this._extent;
thisExtent[0] = isNaN(start) ? 0 : start; if (! isNaN(start)) {
thisExtent[1] = isNaN(end) ? 0 : end; thisExtent[0] = start;
}
if (! isNaN(end)) {
thisExtent[1] = end;
}
}, },
/** /**
...@@ -197,16 +198,22 @@ define(function (require) { ...@@ -197,16 +198,22 @@ define(function (require) {
/** /**
* Nice extent. * Nice extent.
* @param {number} [approxTickNum = 10] Given approx tick number * @param {number} [approxTickNum = 10] Given approx tick number
* @param {boolean} [fixMin=false]
* @param {boolean} [fixMax=false]
*/ */
niceExtent: function (approxTickNum) { niceExtent: function (approxTickNum, fixMin, fixMax) {
this.niceTicks(approxTickNum); this.niceTicks(approxTickNum);
var extent = this._extent; var extent = this._extent;
var interval = this._interval; var interval = this._interval;
extent[0] = mathFloor(extent[0] / interval) * interval; if (! fixMin) {
extent[1] = mathCeil(extent[1] / interval) * interval; extent[0] = mathFloor(extent[0] / interval) * interval;
}
if (! fixMax) {
extent[1] = mathCeil(extent[1] / interval) * interval;
}
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册