提交 d323a360 编写于 作者: L lang

Roam type

上级 b7491ff8
......@@ -65,8 +65,7 @@ define(function (require) {
var controller = this._controller;
controller.rect = coordSys.getViewRect();
controller.disable();
seriesModel.get('roam') && controller.enable();
controller.enable(seriesModel.get('roam'));
controller
.off('pan')
......
......@@ -224,6 +224,8 @@ define(function (require) {
_updateController: function (mapOrGeoModel, ecModel, api) {
var geo = mapOrGeoModel.coordinateSystem;
var controller = this._controller;
// roamType is will be set default true if it is null
controller.enable(mapOrGeoModel.get('roam') || false);
// FIXME mainType, subType 作为 component 的属性?
var mainType = mapOrGeoModel.type.split('.')[0];
controller.off('pan')
......
......@@ -118,21 +118,32 @@ define(function (require) {
Eventful.call(this);
this.enable = function () {
zr.on('mousedown', mousedownHandler);
zr.on('mousemove', mousemoveHandler);
zr.on('mouseup', mouseupHandler);
zr.on('mousewheel', mousewheelHandler);
/**
* @param {boolean} [controlType=true] Specify the control type, which can be only 'pan' or 'zoom'
*/
this.enable = function (controlType) {
// Disable previous first
this.disable();
if (controlType == null) {
controlType = true;
}
if (controlType && controlType !== 'zoom') {
zr.on('mousedown', mousedownHandler);
zr.on('mousemove', mousemoveHandler);
zr.on('mouseup', mouseupHandler);
}
if (controlType && controlType !== 'pan') {
zr.on('mousewheel', mousewheelHandler);
}
};
this.disable = this.dispose = function () {
this.disable = function () {
zr.off('mousedown', mousedownHandler);
zr.off('mousemove', mousemoveHandler);
zr.off('mouseup', mouseupHandler);
zr.off('mousewheel', mousewheelHandler);
};
this.enable();
this.dispose = this.disable;
this.isDragging = function () {
return this._dragging;
......
define(function (require) {
var vector = require('zrender/core/vector');
var parseGeoJson = require('./parseGeoJson');
var zrUtil = require('zrender/core/util');
......@@ -10,7 +8,6 @@ define(function (require) {
var View = require('../View');
var v2Copy = vector.copy;
// Geo fix functions
var geoFixFuncs = [
......@@ -60,6 +57,8 @@ define(function (require) {
var regionsMap = {};
for (var i = 0; i < regions.length; i++) {
regionsMap[regions[i].name] = regions[i];
// Add geoJson
this.addGeoCoord(regions[i].name, regions[i].center);
}
this._regionsMap = regionsMap;
......@@ -153,6 +152,21 @@ define(function (require) {
item[1] = lat;
return this.dataToPoint(item);
}, this);
},
// Overwrite
/**
* @param {string|Array.<number>} data
* @return {Array.<number>}
*/
dataToPoint: function (data) {
if (typeof data === 'string') {
// Map area name to geoCoord
data = this.getGeoCoord(data);
}
if (data) {
return View.prototype.dataToPoint.call(this, data);
}
}
};
......
......@@ -43,7 +43,7 @@ define(function (require) {
* @type {Array.<number>}
*/
this.center = cp;
};
}
Region.prototype = {
......@@ -74,9 +74,9 @@ define(function (require) {
min[0] = min[1] = max[0] = max[1] = 0;
}
return this._rect = new BoundingRect(
return (this._rect = new BoundingRect(
min[0], min[1], max[0] - min[0], max[1] - min[1]
);
));
},
/**
......
......@@ -4,7 +4,6 @@ define(function (require) {
var Geo = require('./Geo');
var numberUtil = require('../../util/number');
var layout = require('../../util/layout');
var zrUtil = require('zrender/core/util');
......@@ -15,7 +14,7 @@ define(function (require) {
* @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
* @param {module:echarts/ExtensionAPI} api
*/
var resizeGeo = function (geoModel, api) {
function resizeGeo (geoModel, api) {
var locModel = geoModel;
if (geoModel.type === 'series.map') {
locModel = geoModel.getModel('mapLocation');
......@@ -52,7 +51,18 @@ define(function (require) {
this.setPan(panX, panY);
this.setZoom(zoom);
};
}
/**
* @param {module:echarts/coord/Geo} geo
* @param {module:echarts/model/Model} model
* @inner
*/
function setGeoCoords(geo, model) {
zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
geo.addGeoCoord(name, geoCoord);
});
}
var geoCreator = {
......@@ -69,7 +79,10 @@ define(function (require) {
var geo = new Geo(name + idx, name, geoJson);
geoList.push(geo);
setGeoCoords(geo, geoModel);
geoModel.coordinateSystem = geo;
geo.model = geoModel;
// Inject resize method
geo.resize = resizeGeo;
......@@ -112,6 +125,8 @@ define(function (require) {
zrUtil.each(mapSeries, function (singleMapSeries) {
singleMapSeries.coordinateSystem = geo;
setGeoCoords(geo, singleMapSeries);
});
});
......
/**
* TODO setTheme
* axis position 统一处理
* 规范 Symbol 配置和绘制, customPath
*
* 每次 update 只刷新 model 变化的那些 component(需要做依赖收集)
* @module echarts
*/
define(function (require) {
......@@ -34,7 +30,7 @@ define(function (require) {
/**
* @module echarts~ECharts
*/
var ECharts = function (dom, theme, opts) {
function ECharts (dom, theme, opts) {
opts = opts || {};
/**
......@@ -100,9 +96,10 @@ define(function (require) {
this._layouts = zrUtil.map(layoutClasses, function (Layout) {
return new Layout();
});
};
}
var echartsProto = ECharts.prototype;
echartsProto.getDom = function () {
return this._dom;
};
......@@ -423,7 +420,7 @@ define(function (require) {
};
/**
* Layout before each chart render there series after visual coding and data processing
* Layout before each chart render there series, after visual coding and data processing
*
* @param {module:echarts/model/Global} ecModel
* @private
......@@ -480,7 +477,7 @@ define(function (require) {
updateZ(seriesModel, chart);
}, this);
// Remove groups of charts
// Remove groups of unrendered charts
each(this._chartsList, function (chart) {
if (!chart.__keepAlive) {
chart.remove(ecModel, api);
......@@ -560,7 +557,7 @@ define(function (require) {
var visualCodingFuncs = {};
/**
* @module echarts
* @alias
*/
var echarts = {};
......@@ -659,7 +656,7 @@ define(function (require) {
};
/**
* @param
* @param {echarts/scale/*} scale
*/
echarts.registerScale = function (scale) {
scaleClasses.register(scale);
......
......@@ -19,5 +19,5 @@ define(function (require) {
data.setItemLayout(idx, point);
}, true);
});
}
};
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册