未验证 提交 90243fca 编写于 作者: Y Yi Shen 提交者: GitHub

Merge pull request #13092 from apache/release-dev

Release 4.9.0
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -11289,7 +11289,7 @@ var painterCtors = {
/**
* @type {string}
*/
var version$1 = '4.3.1';
var version$1 = '4.3.2';
/**
* Initializing a zrender instance
......@@ -25578,7 +25578,7 @@ var proto = Scheduler.prototype;
* @param {Object} payload
*/
proto.restoreData = function (ecModel, payload) {
// TODO: Only restroe needed series and components, but not all components.
// TODO: Only restore needed series and components, but not all components.
// Currently `restoreData` of all of the series and component will be called.
// But some independent components like `title`, `legend`, `graphic`, `toolbox`,
// `tooltip`, `axisPointer`, etc, do not need series refresh when `setOption`,
......@@ -27155,10 +27155,10 @@ var isFunction = isFunction$1;
var isObject = isObject$1;
var parseClassType = ComponentModel.parseClassType;
var version = '4.8.0';
var version = '4.9.0';
var dependencies = {
zrender: '4.3.1'
zrender: '4.3.2'
};
var TEST_FRAME_REMAIN_TIME = 1;
......@@ -30401,7 +30401,7 @@ listProto.mapDimension = function (coordDim, idx) {
* Initialize from data
* @param {Array.<Object|number|Array>} data source or data or data provider.
* @param {Array.<string>} [nameLIst] The name of a datum is used on data diff and
* defualt label/tooltip.
* default label/tooltip.
* A name can be specified in encode.itemName,
* or dataItem.name (only for series option data),
* or provided in nameList from outside.
......@@ -33594,7 +33594,7 @@ symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
}
else {
symbolPath.setStyle({
opacity: null,
opacity: 1,
shadowBlur: null,
shadowOffsetX: null,
shadowOffsetY: null,
......@@ -35779,7 +35779,7 @@ var dataSample = function (seriesType) {
var valueAxis = coordSys.getOtherAxis(baseAxis);
var extent = baseAxis.getExtent();
// Coordinste system has been resized
var size = extent[1] - extent[0];
var size = Math.abs(extent[1] - extent[0]);
var rate = Math.round(data.count() / size);
if (rate > 1) {
var sampler;
......@@ -37945,8 +37945,8 @@ function rotateTextRect(textRect, rotate) {
var boundingBox = textRect.plain();
var beforeWidth = boundingBox.width;
var beforeHeight = boundingBox.height;
var afterWidth = beforeWidth * Math.cos(rotateRadians) + beforeHeight * Math.sin(rotateRadians);
var afterHeight = beforeWidth * Math.sin(rotateRadians) + beforeHeight * Math.cos(rotateRadians);
var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians)) + Math.abs(beforeHeight * Math.sin(rotateRadians));
var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians)) + Math.abs(beforeHeight * Math.cos(rotateRadians));
var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight);
return rotatedRect;
......@@ -39141,7 +39141,7 @@ var defaultOption = {
name: '',
// 'start' | 'middle' | 'end'
nameLocation: 'end',
// By degree. By defualt auto rotate by nameLocation.
// By degree. By default auto rotate by nameLocation.
nameRotate: null,
nameTruncate: {
maxWidth: null,
......@@ -42231,20 +42231,25 @@ extendChartView({
var bgEls = [];
var oldBgEls = this._backgroundEls || [];
var createBackground = function (dataIndex) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
return bgEl;
};
data.diff(oldData)
.add(function (dataIndex) {
var itemModel = data.getItemModel(dataIndex);
var layout = getLayout[coord.type](data, dataIndex, itemModel);
if (drawBackground) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
createBackground(dataIndex);
}
// If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
......@@ -42278,13 +42283,19 @@ extendChartView({
var layout = getLayout[coord.type](data, newIndex, itemModel);
if (drawBackground) {
var bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
var bgEl;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
}
else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[newIndex] = bgEl;
}
bgEls[newIndex] = bgEl;
var bgLayout = getLayout[coord.type](data, newIndex);
var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
......@@ -42444,8 +42455,31 @@ var clip = {
return clipped;
},
polar: function (coordSysClipArea) {
return false;
polar: function (coordSysClipArea, layout) {
var signR = layout.r0 <= layout.r ? 1 : -1;
// Make sure r is larger than r0
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
var r = mathMin$4(layout.r, coordSysClipArea.r);
var r0 = mathMax$4(layout.r0, coordSysClipArea.r0);
layout.r = r;
layout.r0 = r0;
var clipped = r - r0 < 0;
// Reverse back
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
return clipped;
}
};
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -11289,7 +11289,7 @@ var painterCtors = {
/**
* @type {string}
*/
var version$1 = '4.3.1';
var version$1 = '4.3.2';
/**
* Initializing a zrender instance
......@@ -25578,7 +25578,7 @@ var proto = Scheduler.prototype;
* @param {Object} payload
*/
proto.restoreData = function (ecModel, payload) {
// TODO: Only restroe needed series and components, but not all components.
// TODO: Only restore needed series and components, but not all components.
// Currently `restoreData` of all of the series and component will be called.
// But some independent components like `title`, `legend`, `graphic`, `toolbox`,
// `tooltip`, `axisPointer`, etc, do not need series refresh when `setOption`,
......@@ -27155,10 +27155,10 @@ var isFunction = isFunction$1;
var isObject = isObject$1;
var parseClassType = ComponentModel.parseClassType;
var version = '4.8.0';
var version = '4.9.0';
var dependencies = {
zrender: '4.3.1'
zrender: '4.3.2'
};
var TEST_FRAME_REMAIN_TIME = 1;
......@@ -30401,7 +30401,7 @@ listProto.mapDimension = function (coordDim, idx) {
* Initialize from data
* @param {Array.<Object|number|Array>} data source or data or data provider.
* @param {Array.<string>} [nameLIst] The name of a datum is used on data diff and
* defualt label/tooltip.
* default label/tooltip.
* A name can be specified in encode.itemName,
* or dataItem.name (only for series option data),
* or provided in nameList from outside.
......@@ -33594,7 +33594,7 @@ symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
}
else {
symbolPath.setStyle({
opacity: null,
opacity: 1,
shadowBlur: null,
shadowOffsetX: null,
shadowOffsetY: null,
......@@ -35779,7 +35779,7 @@ var dataSample = function (seriesType) {
var valueAxis = coordSys.getOtherAxis(baseAxis);
var extent = baseAxis.getExtent();
// Coordinste system has been resized
var size = extent[1] - extent[0];
var size = Math.abs(extent[1] - extent[0]);
var rate = Math.round(data.count() / size);
if (rate > 1) {
var sampler;
......@@ -37945,8 +37945,8 @@ function rotateTextRect(textRect, rotate) {
var boundingBox = textRect.plain();
var beforeWidth = boundingBox.width;
var beforeHeight = boundingBox.height;
var afterWidth = beforeWidth * Math.cos(rotateRadians) + beforeHeight * Math.sin(rotateRadians);
var afterHeight = beforeWidth * Math.sin(rotateRadians) + beforeHeight * Math.cos(rotateRadians);
var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians)) + Math.abs(beforeHeight * Math.sin(rotateRadians));
var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians)) + Math.abs(beforeHeight * Math.cos(rotateRadians));
var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight);
return rotatedRect;
......@@ -39141,7 +39141,7 @@ var defaultOption = {
name: '',
// 'start' | 'middle' | 'end'
nameLocation: 'end',
// By degree. By defualt auto rotate by nameLocation.
// By degree. By default auto rotate by nameLocation.
nameRotate: null,
nameTruncate: {
maxWidth: null,
......@@ -42231,20 +42231,25 @@ extendChartView({
var bgEls = [];
var oldBgEls = this._backgroundEls || [];
var createBackground = function (dataIndex) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
return bgEl;
};
data.diff(oldData)
.add(function (dataIndex) {
var itemModel = data.getItemModel(dataIndex);
var layout = getLayout[coord.type](data, dataIndex, itemModel);
if (drawBackground) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
createBackground(dataIndex);
}
// If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
......@@ -42278,13 +42283,19 @@ extendChartView({
var layout = getLayout[coord.type](data, newIndex, itemModel);
if (drawBackground) {
var bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
var bgEl;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
}
else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[newIndex] = bgEl;
}
bgEls[newIndex] = bgEl;
var bgLayout = getLayout[coord.type](data, newIndex);
var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
......@@ -42444,8 +42455,31 @@ var clip = {
return clipped;
},
polar: function (coordSysClipArea) {
return false;
polar: function (coordSysClipArea, layout) {
var signR = layout.r0 <= layout.r ? 1 : -1;
// Make sure r is larger than r0
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
var r = mathMin$4(layout.r, coordSysClipArea.r);
var r0 = mathMax$4(layout.r0, coordSysClipArea.r0);
layout.r = r;
layout.r0 = r0;
var clipped = r - r0 < 0;
// Reverse back
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
return clipped;
}
};
此差异已折叠。
......@@ -179,7 +179,12 @@ BMapCoordSys.create = function (ecModel, api) {
// Not support IE8
bmapRoot.classList.add('ec-extension-bmap');
root.appendChild(bmapRoot);
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot);
// initialize bmap
var mapOptions = bmapModel.get('mapOptions') || {};
// Not support `mapType`, use `bmap.setMapType(MapType)` instead.
delete mapOptions.mapType;
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
var overlay = new Overlay(viewportRoot);
bmap.addOverlay(overlay);
......@@ -196,8 +201,13 @@ BMapCoordSys.create = function (ecModel, api) {
var center = bmapModel.get('center');
var zoom = bmapModel.get('zoom');
if (center && zoom) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
var bmapCenter = bmap.getCenter();
var bmapZoom = bmap.getZoom();
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
if (centerOrZoomChanged) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
}
}
bmapCoordSys = new BMapCoordSys(bmap, api);
......@@ -262,348 +272,19 @@ echarts.extendComponentModel({
zoom: 5,
// 2.0 http://lbsyun.baidu.com/custom/index.htm
mapStyle: {},
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
mapStyleV2: {},
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
mapOptions: {},
roam: false
}
});
/**
* @module zrender/core/util
*/
// 用于处理merge时无法遍历Date等对象的问题
var BUILTIN_OBJECT = {
'[object Function]': 1,
'[object RegExp]': 1,
'[object Date]': 1,
'[object Error]': 1,
'[object CanvasGradient]': 1,
'[object CanvasPattern]': 1,
// For node-canvas
'[object Image]': 1,
'[object Canvas]': 1
};
var TYPED_ARRAY = {
'[object Int8Array]': 1,
'[object Uint8Array]': 1,
'[object Uint8ClampedArray]': 1,
'[object Int16Array]': 1,
'[object Uint16Array]': 1,
'[object Int32Array]': 1,
'[object Uint32Array]': 1,
'[object Float32Array]': 1,
'[object Float64Array]': 1
};
var objToString = Object.prototype.toString;
/**
* Those data types can be cloned:
* Plain object, Array, TypedArray, number, string, null, undefined.
* Those data types will be assgined using the orginal data:
* BUILTIN_OBJECT
* Instance of user defined class will be cloned to a plain object, without
* properties in prototype.
* Other data types is not supported (not sure what will happen).
*
* Caution: do not support clone Date, for performance consideration.
* (There might be a large number of date in `series.data`).
* So date should not be modified in and out of echarts.
*
* @param {*} source
* @return {*} new
*/
function clone(source) {
if (source == null || typeof source !== 'object') {
return source;
}
var result = source;
var typeStr = objToString.call(source);
if (typeStr === '[object Array]') {
if (!isPrimitive(source)) {
result = [];
for (var i = 0, len = source.length; i < len; i++) {
result[i] = clone(source[i]);
}
}
}
else if (TYPED_ARRAY[typeStr]) {
if (!isPrimitive(source)) {
var Ctor = source.constructor;
if (source.constructor.from) {
result = Ctor.from(source);
}
else {
result = new Ctor(source.length);
for (var i = 0, len = source.length; i < len; i++) {
result[i] = clone(source[i]);
}
}
}
}
else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
result = {};
for (var key in source) {
if (source.hasOwnProperty(key)) {
result[key] = clone(source[key]);
}
}
}
return result;
}
/**
* @memberOf module:zrender/core/util
* @param {*} target
* @param {*} source
* @param {boolean} [overwrite=false]
*/
/**
* @param {Array} targetAndSources The first item is target, and the rests are source.
* @param {boolean} [overwrite=false]
* @return {*} target
*/
/**
* @param {*} target
* @param {*} source
* @memberOf module:zrender/core/util
*/
/**
* @param {*} target
* @param {*} source
* @param {boolean} [overlay=false]
* @memberOf module:zrender/core/util
*/
/**
* 查询数组中元素的index
* @memberOf module:zrender/core/util
*/
/**
* 构造类继承关系
*
* @memberOf module:zrender/core/util
* @param {Function} clazz 源类
* @param {Function} baseClazz 基类
*/
/**
* @memberOf module:zrender/core/util
* @param {Object|Function} target
* @param {Object|Function} sorce
* @param {boolean} overlay
*/
/**
* Consider typed array.
* @param {Array|TypedArray} data
*/
/**
* 数组或对象遍历
* @memberOf module:zrender/core/util
* @param {Object|Array} obj
* @param {Function} cb
* @param {*} [context]
*/
/**
* 数组映射
* @memberOf module:zrender/core/util
* @param {Array} obj
* @param {Function} cb
* @param {*} [context]
* @return {Array}
*/
/**
* @memberOf module:zrender/core/util
* @param {Array} obj
* @param {Function} cb
* @param {Object} [memo]
* @param {*} [context]
* @return {Array}
*/
/**
* 数组过滤
* @memberOf module:zrender/core/util
* @param {Array} obj
* @param {Function} cb
* @param {*} [context]
* @return {Array}
*/
/**
* 数组项查找
* @memberOf module:zrender/core/util
* @param {Array} obj
* @param {Function} cb
* @param {*} [context]
* @return {*}
*/
/**
* @memberOf module:zrender/core/util
* @param {Function} func
* @param {*} context
* @return {Function}
*/
/**
* @memberOf module:zrender/core/util
* @param {Function} func
* @return {Function}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
/**
* @memberOf module:zrender/core/util
* @param {*} value
* @return {boolean}
*/
function isDom(value) {
return typeof value === 'object'
&& typeof value.nodeType === 'number'
&& typeof value.ownerDocument === 'object';
}
/**
* Whether is exactly NaN. Notice isNaN('a') returns true.
* @param {*} value
* @return {boolean}
*/
/**
* If value1 is not null, then return value1, otherwise judget rest of values.
* Low performance.
* @memberOf module:zrender/core/util
* @return {*} Final value
*/
/**
* @memberOf module:zrender/core/util
* @param {Array} arr
* @param {number} startIndex
* @param {number} endIndex
* @return {Array}
*/
/**
* Normalize css liked array configuration
* e.g.
* 3 => [3, 3, 3, 3]
* [4, 2] => [4, 2, 4, 2]
* [4, 3, 2] => [4, 3, 2, 3]
* @param {number|Array.<number>} val
* @return {Array.<number>}
*/
/**
* @memberOf module:zrender/core/util
* @param {boolean} condition
* @param {string} message
*/
/**
* @memberOf module:zrender/core/util
* @param {string} str string to be trimed
* @return {string} trimed string
*/
var primitiveKey = '__ec_primitive__';
/**
* Set an object as primitive to be ignored traversing children in clone or merge
*/
function isPrimitive(obj) {
return obj[primitiveKey];
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
......@@ -623,6 +304,15 @@ function isPrimitive(obj) {
* under the License.
*/
function isEmptyObject(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return false;
}
}
return true;
}
echarts.extendComponentView({
type: 'bmap',
......@@ -662,12 +352,10 @@ echarts.extendComponentView({
}
bmap.removeEventListener('moving', this._oldMoveHandler);
// FIXME
// Moveend may be triggered by centerAndZoom method when creating coordSys next time
// bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
bmap.addEventListener('moving', moveHandler);
// bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('zoomend', zoomEndHandler);
this._oldMoveHandler = moveHandler;
......@@ -699,8 +387,8 @@ echarts.extendComponentView({
var mapStyleStr = JSON.stringify(newMapStyle);
if (JSON.stringify(originalStyle) !== mapStyleStr) {
// FIXME May have blank tile when dragging if setMapStyle
if (Object.keys(newMapStyle).length) {
bmap.setMapStyle(clone(newMapStyle));
if (!isEmptyObject(newMapStyle2)) {
bmap.setMapStyle(echarts.util.clone(newMapStyle));
}
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
}
......@@ -713,8 +401,8 @@ echarts.extendComponentView({
var mapStyleStr2 = JSON.stringify(newMapStyle2);
if (JSON.stringify(originalStyle2) !== mapStyleStr2) {
// FIXME May have blank tile when dragging if setMapStyle
if (Object.keys(newMapStyle2).length) {
bmap.setMapStyleV2(clone(newMapStyle2));
if (!isEmptyObject(newMapStyle2)) {
bmap.setMapStyleV2(echarts.util.clone(newMapStyle2));
}
bMapModel.__mapStyle2 = JSON.parse(mapStyleStr2);
}
......
此差异已折叠。
......@@ -19,4 +19,4 @@
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],e):e(t.bmap={},t.echarts)}(this,function(t,o){"use strict";function l(t,e){this._bmap=t,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=e,this._projection=new BMap.MercatorProjection}function n(i,a){return a=a||[0,0],o.util.map([0,1],function(t){var e=a[t],o=i[t]/2,n=[],r=[];return n[t]=e-o,r[t]=e+o,n[1-t]=r[1-t]=a[1-t],Math.abs(this.dataToPoint(n)[t]-this.dataToPoint(r)[t])},this)}var d;l.prototype.dimensions=["lng","lat"],l.prototype.setZoom=function(t){this._zoom=t},l.prototype.setCenter=function(t){this._center=this._projection.lngLatToPoint(new BMap.Point(t[0],t[1]))},l.prototype.setMapOffset=function(t){this._mapOffset=t},l.prototype.getBMap=function(){return this._bmap},l.prototype.dataToPoint=function(t){var e=new BMap.Point(t[0],t[1]),o=this._bmap.pointToOverlayPixel(e),n=this._mapOffset;return[o.x-n[0],o.y-n[1]]},l.prototype.pointToData=function(t){var e=this._mapOffset;return[(t=this._bmap.overlayPixelToPoint({x:t[0]+e[0],y:t[1]+e[1]})).lng,t.lat]},l.prototype.getViewRect=function(){var t=this._api;return new o.graphic.BoundingRect(0,0,t.getWidth(),t.getHeight())},l.prototype.getRoamTransform=function(){return o.matrix.create()},l.prototype.prepareCustoms=function(t){var e=this.getViewRect();return{coordSys:{type:"bmap",x:e.x,y:e.y,width:e.width,height:e.height},api:{coord:o.util.bind(this.dataToPoint,this),size:o.util.bind(n,this)}}},l.dimensions=l.prototype.dimensions,l.create=function(t,c){var m,f=c.getDom();t.eachComponent("bmap",function(t){var e=c.getZr().painter,o=e.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");if(d=d||function(){function t(t){this._root=t}return(t.prototype=new BMap.Overlay).initialize=function(t){return t.getPanes().labelPane.appendChild(this._root),this._root},t.prototype.draw=function(){},t}(),m)throw new Error("Only one bmap component can exist");if(!t.__bmap){var n=f.querySelector(".ec-extension-bmap");n&&(o.style.left="0px",o.style.top="0px",f.removeChild(n)),(n=document.createElement("div")).style.cssText="width:100%;height:100%",n.classList.add("ec-extension-bmap"),f.appendChild(n);var r=t.__bmap=new BMap.Map(n),i=new d(o);r.addOverlay(i),e.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}r=t.__bmap;var a=t.get("center"),p=t.get("zoom");if(a&&p){var s=new BMap.Point(a[0],a[1]);r.centerAndZoom(s,p)}(m=new l(r,c)).setMapOffset(t.__mapOffset||[0,0]),m.setZoom(p),m.setCenter(a),t.coordinateSystem=m}),t.eachSeries(function(t){"bmap"===t.get("coordinateSystem")&&(t.coordinateSystem=m)})},o.extendComponentModel({type:"bmap",getBMap:function(){return this.__bmap},setCenterAndZoom:function(t,e){this.option.center=t,this.option.zoom=e},centerOrZoomChanged:function(t,e){var o=this.option;return!(function(t,e){return t&&e&&t[0]===e[0]&&t[1]===e[1]}(t,o.center)&&e===o.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},mapStyleV2:{},roam:!1}});var p={"[object Function]":1,"[object RegExp]":1,"[object Date]":1,"[object Error]":1,"[object CanvasGradient]":1,"[object CanvasPattern]":1,"[object Image]":1,"[object Canvas]":1},s={"[object Int8Array]":1,"[object Uint8Array]":1,"[object Uint8ClampedArray]":1,"[object Int16Array]":1,"[object Uint16Array]":1,"[object Int32Array]":1,"[object Uint32Array]":1,"[object Float32Array]":1,"[object Float64Array]":1},c=Object.prototype.toString;function h(t){if(null==t||"object"!=typeof t)return t;var e=t,o=c.call(t);if("[object Array]"===o){if(!m(t)){e=[];for(var n=0,r=t.length;n<r;n++)e[n]=h(t[n])}}else if(s[o]){if(!m(t)){var i=t.constructor;if(t.constructor.from)e=i.from(t);else{e=new i(t.length);for(n=0,r=t.length;n<r;n++)e[n]=h(t[n])}}}else if(!p[o]&&!m(t)&&!function(t){return"object"==typeof t&&"number"==typeof t.nodeType&&"object"==typeof t.ownerDocument}(t))for(var a in e={},t)t.hasOwnProperty(a)&&(e[a]=h(t[a]));return e}var e="__ec_primitive__";function m(t){return t[e]}o.extendComponentView({type:"bmap",render:function(r,t,i){function e(t,e){if(!a){var o=p.parentNode.parentNode.parentNode,n=[-parseInt(o.style.left,10)||0,-parseInt(o.style.top,10)||0];p.style.left=n[0]+"px",p.style.top=n[1]+"px",s.setMapOffset(n),r.__mapOffset=n,i.dispatchAction({type:"bmapRoam"})}}var a=!0,o=r.getBMap(),p=i.getZr().painter.getViewportRoot(),s=r.coordinateSystem;function n(){a||i.dispatchAction({type:"bmapRoam"})}o.removeEventListener("moving",this._oldMoveHandler),o.removeEventListener("zoomend",this._oldZoomEndHandler),o.addEventListener("moving",e),o.addEventListener("zoomend",n),this._oldMoveHandler=e,this._oldZoomEndHandler=n;var c=r.get("roam");c&&"scale"!==c?o.enableDragging():o.disableDragging(),c&&"move"!==c?(o.enableScrollWheelZoom(),o.enableDoubleClickZoom(),o.enablePinchToZoom()):(o.disableScrollWheelZoom(),o.disableDoubleClickZoom(),o.disablePinchToZoom());var m=r.__mapStyle,f=r.get("mapStyle")||{},l=JSON.stringify(f);JSON.stringify(m)!==l&&(Object.keys(f).length&&o.setMapStyle(h(f)),r.__mapStyle=JSON.parse(l));var d=r.__mapStyle2,y=r.get("mapStyleV2")||{},u=JSON.stringify(y);JSON.stringify(d)!==u&&(Object.keys(y).length&&o.setMapStyleV2(h(y)),r.__mapStyle2=JSON.parse(u)),a=!1}}),o.registerCoordinateSystem("bmap",l),o.registerAction({type:"bmapRoam",event:"bmapRoam",update:"updateLayout"},function(t,e){e.eachComponent("bmap",function(t){var e=t.getBMap(),o=e.getCenter();t.setCenterAndZoom([o.lng,o.lat],e.getZoom())})});t.version="1.0.0"});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t(e.bmap={},e.echarts)}(this,function(e,y){"use strict";function h(e,t){this._bmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t,this._projection=new BMap.MercatorProjection}function o(a,r){return r=r||[0,0],y.util.map([0,1],function(e){var t=r[e],o=a[e]/2,n=[],i=[];return n[e]=t-o,i[e]=t+o,n[1-e]=i[1-e]=r[1-e],Math.abs(this.dataToPoint(n)[e]-this.dataToPoint(i)[e])},this)}var g;function v(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}h.prototype.dimensions=["lng","lat"],h.prototype.setZoom=function(e){this._zoom=e},h.prototype.setCenter=function(e){this._center=this._projection.lngLatToPoint(new BMap.Point(e[0],e[1]))},h.prototype.setMapOffset=function(e){this._mapOffset=e},h.prototype.getBMap=function(){return this._bmap},h.prototype.dataToPoint=function(e){var t=new BMap.Point(e[0],e[1]),o=this._bmap.pointToOverlayPixel(t),n=this._mapOffset;return[o.x-n[0],o.y-n[1]]},h.prototype.pointToData=function(e){var t=this._mapOffset;return[(e=this._bmap.overlayPixelToPoint({x:e[0]+t[0],y:e[1]+t[1]})).lng,e.lat]},h.prototype.getViewRect=function(){var e=this._api;return new y.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},h.prototype.getRoamTransform=function(){return y.matrix.create()},h.prototype.prepareCustoms=function(e){var t=this.getViewRect();return{coordSys:{type:"bmap",x:t.x,y:t.y,width:t.width,height:t.height},api:{coord:y.util.bind(this.dataToPoint,this),size:y.util.bind(o,this)}}},h.dimensions=h.prototype.dimensions,h.create=function(e,l){var f,u=l.getDom();e.eachComponent("bmap",function(e){var t=l.getZr().painter,o=t.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");if(g=g||function(){function e(e){this._root=e}return(e.prototype=new BMap.Overlay).initialize=function(e){return e.getPanes().labelPane.appendChild(this._root),this._root},e.prototype.draw=function(){},e}(),f)throw new Error("Only one bmap component can exist");if(!e.__bmap){var n=u.querySelector(".ec-extension-bmap");n&&(o.style.left="0px",o.style.top="0px",u.removeChild(n)),(n=document.createElement("div")).style.cssText="width:100%;height:100%",n.classList.add("ec-extension-bmap"),u.appendChild(n);var i=e.get("mapOptions")||{};delete i.mapType;var a=e.__bmap=new BMap.Map(n,i),r=new g(o);a.addOverlay(r),t.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}a=e.__bmap;var p=e.get("center"),s=e.get("zoom");if(p&&s){var m=a.getCenter(),d=a.getZoom();if(e.centerOrZoomChanged([m.lng,m.lat],d)){var c=new BMap.Point(p[0],p[1]);a.centerAndZoom(c,s)}}(f=new h(a,l)).setMapOffset(e.__mapOffset||[0,0]),f.setZoom(s),f.setCenter(p),e.coordinateSystem=f}),e.eachSeries(function(e){"bmap"===e.get("coordinateSystem")&&(e.coordinateSystem=f)})},y.extendComponentModel({type:"bmap",getBMap:function(){return this.__bmap},setCenterAndZoom:function(e,t){this.option.center=e,this.option.zoom=t},centerOrZoomChanged:function(e,t){var o=this.option;return!(function(e,t){return e&&t&&e[0]===t[0]&&e[1]===t[1]}(e,o.center)&&t===o.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},mapStyleV2:{},mapOptions:{},roam:!1}}),y.extendComponentView({type:"bmap",render:function(i,e,a){function t(e,t){if(!r){var o=p.parentNode.parentNode.parentNode,n=[-parseInt(o.style.left,10)||0,-parseInt(o.style.top,10)||0];p.style.left=n[0]+"px",p.style.top=n[1]+"px",s.setMapOffset(n),i.__mapOffset=n,a.dispatchAction({type:"bmapRoam"})}}var r=!0,o=i.getBMap(),p=a.getZr().painter.getViewportRoot(),s=i.coordinateSystem;function n(){r||a.dispatchAction({type:"bmapRoam"})}o.removeEventListener("moving",this._oldMoveHandler),o.removeEventListener("moveend",this._oldMoveHandler),o.removeEventListener("zoomend",this._oldZoomEndHandler),o.addEventListener("moving",t),o.addEventListener("moveend",t),o.addEventListener("zoomend",n),this._oldMoveHandler=t,this._oldZoomEndHandler=n;var m=i.get("roam");m&&"scale"!==m?o.enableDragging():o.disableDragging(),m&&"move"!==m?(o.enableScrollWheelZoom(),o.enableDoubleClickZoom(),o.enablePinchToZoom()):(o.disableScrollWheelZoom(),o.disableDoubleClickZoom(),o.disablePinchToZoom());var d=i.__mapStyle,c=i.get("mapStyle")||{},l=JSON.stringify(c);JSON.stringify(d)!==l&&(v(u)||o.setMapStyle(y.util.clone(c)),i.__mapStyle=JSON.parse(l));var f=i.__mapStyle2,u=i.get("mapStyleV2")||{},h=JSON.stringify(u);JSON.stringify(f)!==h&&(v(u)||o.setMapStyleV2(y.util.clone(u)),i.__mapStyle2=JSON.parse(h)),r=!1}}),y.registerCoordinateSystem("bmap",h),y.registerAction({type:"bmapRoam",event:"bmapRoam",update:"updateLayout"},function(e,t){t.eachComponent("bmap",function(e){var t=e.getBMap(),o=t.getCenter();e.setCenterAndZoom([o.lng,o.lat],t.getZoom())})});e.version="1.0.0"});
此差异已折叠。
......@@ -204,8 +204,12 @@ BMapCoordSys.create = function (ecModel, api) {
bmapRoot.style.cssText = 'width:100%;height:100%'; // Not support IE8
bmapRoot.classList.add('ec-extension-bmap');
root.appendChild(bmapRoot);
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot);
root.appendChild(bmapRoot); // initialize bmap
var mapOptions = bmapModel.get('mapOptions') || {}; // Not support `mapType`, use `bmap.setMapType(MapType)` instead.
delete mapOptions.mapType;
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
var overlay = new Overlay(viewportRoot);
bmap.addOverlay(overlay); // Override
......@@ -224,8 +228,14 @@ BMapCoordSys.create = function (ecModel, api) {
var zoom = bmapModel.get('zoom');
if (center && zoom) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
var bmapCenter = bmap.getCenter();
var bmapZoom = bmap.getZoom();
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
if (centerOrZoomChanged) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
}
}
bmapCoordSys = new BMapCoordSys(bmap, api);
......
......@@ -59,8 +59,12 @@ var _default = echarts.extendComponentModel({
defaultOption: {
center: [104.114129, 37.550339],
zoom: 5,
// 2.0 http://lbsyun.baidu.com/custom/index.htm
mapStyle: {},
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
mapStyleV2: {},
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
mapOptions: {},
roam: false
}
});
......
......@@ -20,10 +20,6 @@
var echarts = require("echarts");
var _util = require("zrender/lib/core/util");
var clone = _util.clone;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
......@@ -42,6 +38,16 @@ var clone = _util.clone;
* specific language governing permissions and limitations
* under the License.
*/
function isEmptyObject(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return false;
}
}
return true;
}
var _default = echarts.extendComponentView({
type: 'bmap',
render: function (bMapModel, ecModel, api) {
......@@ -76,13 +82,11 @@ var _default = echarts.extendComponentView({
});
}
bmap.removeEventListener('moving', this._oldMoveHandler); // FIXME
// Moveend may be triggered by centerAndZoom method when creating coordSys next time
// bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('moving', this._oldMoveHandler);
bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
bmap.addEventListener('moving', moveHandler); // bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('moving', moveHandler);
bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('zoomend', zoomEndHandler);
this._oldMoveHandler = moveHandler;
this._oldZoomEndHandler = zoomEndHandler;
......@@ -113,8 +117,8 @@ var _default = echarts.extendComponentView({
if (JSON.stringify(originalStyle) !== mapStyleStr) {
// FIXME May have blank tile when dragging if setMapStyle
if (Object.keys(newMapStyle).length) {
bmap.setMapStyle(clone(newMapStyle));
if (!isEmptyObject(newMapStyle2)) {
bmap.setMapStyle(echarts.util.clone(newMapStyle));
}
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
......@@ -129,8 +133,8 @@ var _default = echarts.extendComponentView({
if (JSON.stringify(originalStyle2) !== mapStyleStr2) {
// FIXME May have blank tile when dragging if setMapStyle
if (Object.keys(newMapStyle2).length) {
bmap.setMapStyleV2(clone(newMapStyle2));
if (!isEmptyObject(newMapStyle2)) {
bmap.setMapStyleV2(echarts.util.clone(newMapStyle2));
}
bMapModel.__mapStyle2 = JSON.parse(mapStyleStr2);
......
{
"name": "echarts",
"version": "4.8.0",
"version": "4.9.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -7507,9 +7507,9 @@
"dev": true
},
"zrender": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-4.3.1.tgz",
"integrity": "sha512-CeH2TpJeCdG0TAGYoPSAcFX2ogdug1K7LIn9UO/q9HWqQ54gWhrMAlDP9AwWYMUDhrPe4VeazQ4DW3msD96nUQ=="
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-4.3.2.tgz",
"integrity": "sha512-bIusJLS8c4DkIcdiK+s13HiQ/zjQQVgpNohtd8d94Y2DnJqgM1yjh/jpDb8DoL6hd7r8Awagw8e3qK/oLaWr3g=="
}
}
}
{
"name": "echarts",
"version": "4.8.0",
"version": "4.9.0",
"description": "A powerful charting and visualization library for browser",
"license": "Apache-2.0",
"keywords": [
......@@ -27,7 +27,7 @@
"lint:dist": "echo 'It might take a while. Please wait ...' && ./node_modules/.bin/jshint --config .jshintrc-dist dist/echarts.js"
},
"dependencies": {
"zrender": "4.3.1"
"zrender": "4.3.2"
},
"devDependencies": {
"@babel/core": "7.3.4",
......
......@@ -387,8 +387,10 @@ function rotateTextRect(textRect, rotate) {
var boundingBox = textRect.plain();
var beforeWidth = boundingBox.width;
var beforeHeight = boundingBox.height;
var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians)) + Math.abs(beforeHeight * Math.sin(rotateRadians));
var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians)) + Math.abs(beforeHeight * Math.cos(rotateRadians));
var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians))
+ Math.abs(beforeHeight * Math.sin(rotateRadians));
var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians))
+ Math.abs(beforeHeight * Math.cos(rotateRadians));
var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight);
return rotatedRect;
......
......@@ -51,10 +51,10 @@ var isFunction = zrUtil.isFunction;
var isObject = zrUtil.isObject;
var parseClassType = ComponentModel.parseClassType;
export var version = '4.8.0';
export var version = '4.9.0';
export var dependencies = {
zrender: '4.3.1'
zrender: '4.3.2'
};
var TEST_FRAME_REMAIN_TIME = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册