Skip to content

Commit

Permalink
resize bug fix~
Browse files Browse the repository at this point in the history
  • Loading branch information
kener committed Jun 5, 2013
1 parent b494730 commit a6c4d0d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 11 deletions.
26 changes: 26 additions & 0 deletions src/chart/island.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ define(function (require) {
var _zlevelBase = self.getZlevelBase();
var _nameConnector;
var _valueConnector;
var _zrHeight = zr.getHeight();
var _zrWidth = zr.getWidth();

/**
* 孤岛合并
Expand Down Expand Up @@ -71,6 +73,29 @@ define(function (require) {
}
}

function resize() {
var newWidth = zr.getWidth();
var newHieght = zr.getHeight();
var xScale = newWidth / (_zrWidth || newWidth);
var yScale = newHieght / (_zrHeight || newHieght);
if (xScale == 1 && yScale == 1) {
return;
}
_zrWidth = newWidth;
_zrHeight = newHieght;
for (var i = 0, l = self.shapeList.length; i < l; i++) {
zr.modShape(
self.shapeList[i].id,
{
style: {
x: Math.round(self.shapeList[i].style.x * xScale),
y: Math.round(self.shapeList[i].style.y * yScale)
}
}
);
}
}

function add(shape) {
var name = ecData.get(shape, 'name');
var value = ecData.get(shape, 'value');
Expand Down Expand Up @@ -201,6 +226,7 @@ define(function (require) {
};

self.render = render;
self.resize = resize;
self.add = add;
self.del = del;
self.ondrop = ondrop;
Expand Down
4 changes: 4 additions & 0 deletions src/component/dataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ define(function (require) {
+ 'height:' + _zrHeight + 'px;'
+ 'background-color:#fff;';
_tDom.style.cssText = _gCssText + _sizeCssText;
_textArea.style.cssText = 'display:block;margin:0 0 8px 0;'
+ 'padding:4px 6px;overflow:auto;'
+ 'width:' + (_zrWidth - 15) + 'px;'
+ 'height:' + (_zrHeight - 100) + 'px;';
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/component/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define(function (require) {
_height = gridOption.height;
}

zr.addShape({
self.shapeList.push({
shape : 'rectangle',
id : zr.newShapeId('grid'),
zlevel : _zlevelBase,
Expand All @@ -78,6 +78,7 @@ define(function (require) {
// type : option.splitArea.areaStyle.type,
}
});
zr.addShape(self.shapeList[0]);
}

function getX() {
Expand Down Expand Up @@ -112,6 +113,12 @@ define(function (require) {
height : _height
};
}

function refresh() {
self.clear();
init(option);
}

self.init = init;
self.getX = getX;
self.getY = getY;
Expand All @@ -120,6 +127,7 @@ define(function (require) {
self.getXend = getXend;
self.getYend = getYend;
self.getArea = getArea;
self.refresh = refresh;

init(option);
}
Expand Down
12 changes: 12 additions & 0 deletions src/component/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,17 @@ define(function (require) {
hideDataView();
}

function resize() {
_resetMark();
self.clear();
if (option.toolbox.show) {
_buildShape();
}
if (_dataView) {
_dataView.resize();
}
}

function hideDataView() {
if (_dataView) {
_dataView.hide();
Expand All @@ -614,6 +625,7 @@ define(function (require) {
self.dispose = dispose;

self.render = render;
self.resize = resize;
self.hideDataView = hideDataView;
self.getMagicOption = getMagicOption;
self.resetMagicType = resetMagicType;
Expand Down
19 changes: 9 additions & 10 deletions src/component/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,6 @@ define(function (require) {
}
}

/**
* zrender事件响应:窗口大小改变
*/
function _onresize() {
_zrHeight = zr.getHeight();
_zrWidth = zr.getWidth();
}

/**
* zrender事件响应:鼠标移动
*/
Expand Down Expand Up @@ -707,13 +699,20 @@ define(function (require) {
self.hasAppend = false;
}

/**
* zrender事件响应:窗口大小改变
*/
function resize() {
_zrHeight = zr.getHeight();
_zrWidth = zr.getWidth();
}

/**
* 释放后实例不可用,重载基类方法
*/
function dispose() {
clearTimeout(_hidingTicket);
clearTimeout(_showingTicket);
zr.un(zrConfig.EVENT.RESIZE, _onresize);
zr.un(zrConfig.EVENT.MOUSEMOVE, _onmousemove);

if (self.hasAppend) {
Expand All @@ -726,13 +725,13 @@ define(function (require) {
self = null;
}

zr.on(zrConfig.EVENT.RESIZE, _onresize);
zr.on(zrConfig.EVENT.MOUSEMOVE, _onmousemove);

// 重载基类方法
self.dispose = dispose;

self.init = init;
self.resize = resize;
self.setComponent = setComponent;
init(option, dom);
}
Expand Down
3 changes: 3 additions & 0 deletions src/echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,11 @@ define(function(require) {
// 先来后到,不能仅刷新自己,也不能在上一个循环中刷新,如坐标系数据改变会影响其他图表的大小
// 所以安顺序刷新各种图表,图表内部refresh优化无需更新则不更新~
for (var i = 0, l = _chartList.length; i < l; i++) {
_chartList[i].resize && _chartList[i].resize();
_chartList[i].refresh && _chartList[i].refresh();
}
_island.resize();
_toolbox.resize();
_zr.refresh();
}

Expand Down

0 comments on commit a6c4d0d

Please sign in to comment.