提交 366dc77b 编写于 作者: L lang

Daily update

上级 099cc569
......@@ -26,6 +26,10 @@ define(function(require) {
if (list) {
return list[idx];
}
},
resize: function () {
}
}
......
......@@ -4,13 +4,16 @@ define(function(require) {
var zrUtil = require('zrender/core/util');
var extensionAPIList = ['addProcessor', 'update', 'getCoordinateSystem'];
var echartsAPIList = ['getZr', 'addProcessor', 'update', 'getCoordinateSystem'];
function ExtensionAPI(echarts) {
zrUtil.each(extensionAPIList, function (name) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(echarts[name], echarts);
}, this);
};
// Mix graphic api
zrUtil.merge(ExtensionAPI.prototype, require('./graphic'));
return ExtensionAPI;
});
\ No newline at end of file
define(function(require) {
'use strict';
var Group = require('zrender/container/Group');
var Circle = require('zrender/graphic/Circle');
var ZImage = require('zrender/graphic/Image');
var Text = require('zrender/graphic/Text');
var Polygon = require('zrender/graphic/Polygon');
var Polyline = require('zrender/graphic/Polyline');
var pathTool = require('zrender/tool/path');
var transformPath = require('zrender/tool/transformPath');
var matrix = require('zrender/core/matrix');
return {
/**
* Create a group element
*/
createGroup: function (opts) {
return new Group(opts);
},
/**
* Create a path element from path data string
*/
createPath: function (pathData, opts, rect) {
var path = pathTool.createFromString(pathData, opts);
if (rect) {
this.resizePath(path, rect);
}
return path;
},
/**
* Resize a path to fit the rect
*/
resizePath: function (path, rect) {
var pathRect = path.getBoundingRect();
var dx = rect.x - pathRect.x;
var dy = rect.y - pathRect.y;
var sx = rect.width / pathRect.width;
var sy = rect.height / pathRect.height;
var m = matrix.create();
matrix.translate(m, m, [dx, dy]);
matrix.scale(m, m, [sx, sy]);
// TODOTODOTODOTODO
transformPath(path, m);
},
/**
* Create a circle element
*/
createCircle: function () {
},
createImage: function () {
},
createText: function () {
},
createSector: function () {
},
createPolygon: function () {
},
createPolyline: function () {
}
}
});
\ No newline at end of file
define(function (require) {
var Chart = require('../Chart');
var zrUtil = require('zrender/core/util');
require('./BarSeries');
......@@ -10,8 +11,26 @@ define(function (require) {
init: function () {},
render: function (option, api) {
render: function (series, option, api) {
var coordinateSystemType = series.get('coordinateSystem');
if (coordinateSystemType === 'cartesian') {
this._renderCartesianBar(series, option, api);
}
},
_renderCartesianBar: function (series, option, api) {
// Currently only one grid is supported
var grid = api.getCoordinateSystem('grid', 0);
var data = series.getData();
var coords = grid.dataToCoords(
data, series.get('xAxisIndex'), series.get('yAxisIndex')
);
data.each(function (dataItem, idx) {
var coord = coords[idx];
});
}
});
......
......@@ -13,12 +13,10 @@ define(function (require) {
this._dataItemFilter = dataItemFilter;
api.addProcessor(dataItemFilter, true);
},
render: function () {
render: function (series, option, api) {
},
dispose: function () {}
......
......@@ -5,13 +5,11 @@ define(function (require) {
type: 'dataZoom',
init: function (echarts) {
},
render: function (option) {
},
}
});
});
\ No newline at end of file
......@@ -6,8 +6,8 @@ define(function (require) {
type: 'legend',
render: function (option, globalState) {
var selectedStateGroup = globalState.get('legend.selected');
render: function (option, state, api) {
var selectedStateGroup = state.get('legend.selected');
if (selectedStateGroup) {
zrUtil.each(selectedStateGroup, function (selectedState) {
......
......@@ -10,6 +10,7 @@ define(function(require, factory) {
var Axis2D = require('./CartesianAxis2D');
var OrdinalScale = require('../scale/Ordinal');
var IntervalScale = require('../scale/Interval');
var numberUtil = require('../core/number');
function Grid() {
......@@ -34,14 +35,42 @@ define(function(require, factory) {
this._initCartesian(option);
},
getRect: function () {
return {
x: this._x,
y: this._y,
width: this._width,
height: this._height
};
},
/**
* Resize the grid
*/
resize: function (option, api) {
var gridX = this._x;
var gridY = this._y;
var gridWidth = this._width;
var gridHeight = this._height;
resize: function (optionModel, api) {
var viewportWidth = api.getWidth();
var viewportHeight = api.getHeight();
var grid = optionModel.get('grid');
var parsePercent = numberUtil.parsePercent;
var gridX = parsePercent(grid.x, viewportWidth);
var gridY = parsePercent(grid.y, viewportHeight);
var gridX2 = parsePercent(grid.x2, viewportWidth);
var gridY2 = parsePercent(grid.y2, viewportHeight);
var gridWidth = parsePercent(grid.width, viewportWidth);
var gridHeight = parsePercent(grid.height, viewportHeight);
if (isNaN(gridWidth)) {
gridWidth = gridX2 - gridX;
}
if (isNaN(gridHeight)) {
gridHeight = gridY2 - gridY;
}
this._x = gridX;
this._y = gridY;
this._width = gridWidth;
this._height = gridHeight;
zrUtil.each(this._axesList, function (axis) {
var extent;
......@@ -107,6 +136,10 @@ define(function(require, factory) {
yAxisIndex = yAxisIndex || 0;
var cartesian = this.getCartesian(xAxisIndex, yAxisIndex);
if (! cartesian) {
// Error
return;
}
var xAxis = cartesian.getAxis('x');
var yAxis = cartesian.getAxis('y');
......@@ -158,7 +191,7 @@ define(function(require, factory) {
var xAxisType = xAxisOpt.type;
// Create x axis
var axisX = new Axis2D(
'x', getScaleByOption(xAxisOpt, xAxisOpt),
'x', getScaleByOption(xAxisType, xAxisOpt),
[0, 0],
xAxisOpt.type,
xAxisOpt.position
......@@ -262,7 +295,7 @@ define(function(require, factory) {
}
});
}
}
};
Grid.create = function (option, api) {
if (option.grid) {
......
......@@ -5,6 +5,10 @@
define(function (require) {
function _trim(str) {
return str.replace(/^\s+/, '').replace(/\s+$/, '');
}
/**
* Linear mapping a value from domain to range
* @memberOf module:echarts/core/number
......@@ -27,8 +31,30 @@ define(function (require) {
return t * (range[1] - range[0]) + range[0];
};
/**
* Convert a percent string to absolute number.
* Returns NaN if percent is not a valid string or number
* @memberOf module:echarts/core/number
* @param {string|number} percent
* @param {number} all
* @return {number}
*/
function parsePercent(percent, all) {
if (typeof percent === 'string') {
if (_trim(percent).match(/%$/)) {
return parseFloat(percent) / 100 * all;
}
return parseFloat(percent);
}
return +percent;
}
return {
linearMap: linearMap
linearMap: linearMap,
parsePercent: parsePercent
}
});
\ No newline at end of file
......@@ -3,7 +3,7 @@
*
* Note: it will change the elements placement in array.
*
* @module echarts/data/quickSelect
* @module echarts/core/quickSelect
* @author Yi Shen(https://github.com/pissang)
*/
define(function (require) {
......@@ -49,14 +49,14 @@ define(function (require) {
}
/**
* @alias module:echarts/data/quickSelect
* @alias module:echarts/core/quickSelect
* @param {Array} list
* @param {number} [left]
* @param {number} [right]
* @param {number} nth
* @param {Function} [compareFunc]
* @example
* var quickSelect = require('echarts/data/quickSelect');
* var quickSelect = require('echarts/core/quickSelect');
* var list = [5, 2, 1, 4, 3]
* quickSelect(list, 3);
* quickSelect(list, 0, 3, 1, function (a, b) {return a - b});
......@@ -77,6 +77,6 @@ define(function (require) {
}
return select(list, left, right, nth, compareFunc);
}
return quickSelect;
});
\ No newline at end of file
......@@ -66,6 +66,9 @@ define(function (require) {
});
this._originalOption = option;
// Processed option is same with originalOption before processing
// PENDING
this._processedOption = option;
this._prepareComponents(option);
......@@ -103,18 +106,17 @@ define(function (require) {
},
updateImmediately: function () {
// TODO Performance
var option = this._originalOption.clone();
var processedOption = this._processOption(this._originalOption);
this._coordinateSystem.update(option);
this._processedOption = processedOption;
this._processOption(option, this._state);
this._coordinateSystem.update(processedOption);
this._doRender(option);
this._doRender(processedOption);
},
resize: function () {
this._coordinateSystem.resize(this._processedOption, this._extensionAPI);
},
_prepareCharts: function (option) {
......@@ -128,7 +130,7 @@ define(function (require) {
chart = Chart.create(series);
if (chart) {
chart.init(this._extensionAPI);
this._chartsMap[series.type] = chart;
this._chartsMap[id] = chart;
this._chartsList.push(chart);
}
else {
......@@ -179,22 +181,30 @@ define(function (require) {
}, this);
},
_processOption: function (option, globalState) {
_processOption: function (option) {
// TODO Performance
option = option.clone();
zrUtil.each(this._processors, function (processor) {
processor.syncState(globalState);
processor.syncState(this._state);
processor.process(option);
});
}, this);
return option;
},
_doRender: function (option) {
_doRender: function (optionModel, stateModel) {
var api = this._extensionAPI;
// Render all components
zrUtil.each(this._components, function (component) {
component.render(option, api);
});
component.render(optionModel, stateModel, api);
}, this);
// Render all charts
optionModel.eachSeries(function (series, idx) {
var id = series.type + '_' + (series.name || idx);
});
zrUtil.each(this._charts, function (chart) {
var group = chart.render(option, api);
var group = chart.render(optionModel, api);
this.zr.addElement(group);
}, this);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册