提交 052cf6f5 编写于 作者: D deqingli

Merge branch 'master' of https://github.com/ecomfe/echarts into hierarchy

......@@ -9,6 +9,8 @@ npm run prepublish
./node_modules/.bin/webpack
./node_modules/.bin/webpack -p
./node_modules/.bin/webpack --lang-en
./node_modules/.bin/webpack -p --lang-en
./node_modules/.bin/webpack --config extension/webpack.config.js
./node_modules/.bin/webpack --config extension/webpack.config.js -p
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -52,7 +52,7 @@ return /******/ (function(modules) { // webpackBootstrap
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/**
* BMap component extension
......@@ -83,15 +83,15 @@ return /******/ (function(modules) { // webpackBootstrap
};
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 1 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
/***/ },
/***/ }),
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
......@@ -228,7 +228,8 @@ return /******/ (function(modules) { // webpackBootstrap
// TODO Dispose
ecModel.eachComponent('bmap', function (bmapModel) {
var viewportRoot = api.getZr().painter.getViewportRoot();
var painter = api.getZr().painter;
var viewportRoot = painter.getViewportRoot();
if (typeof BMap === 'undefined') {
throw new Error('BMap api is not loaded');
}
......@@ -255,6 +256,11 @@ return /******/ (function(modules) { // webpackBootstrap
var overlay = new Overlay(viewportRoot);
bmap.addOverlay(overlay);
// Override
painter.getViewportRootOffset = function () {
return {offsetLeft: 0, offsetTop: 0};
};
}
var bmap = bmapModel.__bmap;
......@@ -285,9 +291,9 @@ return /******/ (function(modules) { // webpackBootstrap
return BMapCoordSys;
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
......@@ -326,9 +332,9 @@ return /******/ (function(modules) { // webpackBootstrap
});
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 4 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
......@@ -418,7 +424,7 @@ return /******/ (function(modules) { // webpackBootstrap
});
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ }
/***/ })
/******/ ])
});
;
\ No newline at end of file
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports.bmap=e(require("echarts")):(t.echarts=t.echarts||{},t.echarts.bmap=e(t.echarts))}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){var n;n=function(t){return o(1).registerCoordinateSystem("bmap",o(2)),o(3),o(4),o(1).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())})}),{version:"1.0.0"}}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(e,o){e.exports=t},function(t,e,o){var n;n=function(t){function e(t,e){this._bmap=t,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=e,this._projection=new BMap.MercatorProjection}function n(t,e){return e=e||[0,0],a.map([0,1],function(o){var n=e[o],r=t[o]/2,i=[],a=[];return i[o]=n-r,a[o]=n+r,i[1-o]=a[1-o]=e[1-o],Math.abs(this.dataToPoint(i)[o]-this.dataToPoint(a)[o])},this)}function r(){function t(t){this._root=t}return t.prototype=new BMap.Overlay,t.prototype.initialize=function(t){return t.getPanes().labelPane.appendChild(this._root),this._root},t.prototype.draw=function(){},t}var i=o(1),a=i.util;e.prototype.dimensions=["lng","lat"],e.prototype.setZoom=function(t){this._zoom=t},e.prototype.setCenter=function(t){this._center=this._projection.lngLatToPoint(new BMap.Point(t[0],t[1]))},e.prototype.setMapOffset=function(t){this._mapOffset=t},e.prototype.getBMap=function(){return this._bmap},e.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]]},e.prototype.pointToData=function(t){var e=this._mapOffset,t=this._bmap.overlayPixelToPoint({x:t[0]+e[0],y:t[1]+e[1]});return[t.lng,t.lat]},e.prototype.getViewRect=function(){var t=this._api;return new i.graphic.BoundingRect(0,0,t.getWidth(),t.getHeight())},e.prototype.getRoamTransform=function(){return i.matrix.create()},e.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:a.bind(this.dataToPoint,this),size:a.bind(n,this)}}};var p;return e.dimensions=e.prototype.dimensions,e.create=function(t,o){var n,i=o.getDom();t.eachComponent("bmap",function(t){var a=o.getZr().painter.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");if(p=p||r(),n)throw new Error("Only one bmap component can exist");if(!t.__bmap){var s=i.querySelector(".ec-extension-bmap");s&&(a.style.left="0px",a.style.top="0px",i.removeChild(s)),s=document.createElement("div"),s.style.cssText="width:100%;height:100%",s.classList.add("ec-extension-bmap"),i.appendChild(s);var c=t.__bmap=new BMap.Map(s),m=new p(a);c.addOverlay(m)}var c=t.__bmap,d=t.get("center"),l=t.get("zoom");if(d&&l){var f=new BMap.Point(d[0],d[1]);c.centerAndZoom(f,l)}n=new e(c,o),n.setMapOffset(t.__mapOffset||[0,0]),n.setZoom(l),n.setCenter(d),t.coordinateSystem=n}),t.eachSeries(function(t){"bmap"===t.get("coordinateSystem")&&(t.coordinateSystem=n)})},e}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(t,e,o){var n;n=function(t){function e(t,e){return t&&e&&t[0]===e[0]&&t[1]===e[1]}return o(1).extendComponentModel({type:"bmap",getBMap:function(){return this.__bmap},setCenterAndZoom:function(t,e){this.option.center=t,this.option.zoom=e},centerOrZoomChanged:function(t,o){var n=this.option;return!(e(t,n.center)&&o===n.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},roam:!1}})}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(t,e,o){var n;n=function(t){return o(1).extendComponentView({type:"bmap",render:function(t,e,o){function n(){r||o.dispatchAction({type:"bmapRoam"})}var r=!0,i=t.getBMap(),a=o.getZr().painter.getViewportRoot(),p=t.coordinateSystem,s=function(e,n){if(!r){var i=a.parentNode.parentNode.parentNode,s=[-parseInt(i.style.left,10)||0,-parseInt(i.style.top,10)||0];a.style.left=s[0]+"px",a.style.top=s[1]+"px",p.setMapOffset(s),t.__mapOffset=s,o.dispatchAction({type:"bmapRoam"})}};i.removeEventListener("moving",this._oldMoveHandler),i.removeEventListener("zoomend",this._oldZoomEndHandler),i.addEventListener("moving",s),i.addEventListener("zoomend",n),this._oldMoveHandler=s,this._oldZoomEndHandler=n;var c=t.get("roam");c&&"scale"!==c?i.enableDragging():i.disableDragging(),c&&"move"!==c?(i.enableScrollWheelZoom(),i.enableDoubleClickZoom(),i.enablePinchToZoom()):(i.disableScrollWheelZoom(),i.disableDoubleClickZoom(),i.disablePinchToZoom());var m=t.__mapStyle,d=t.get("mapStyle")||{},l=JSON.stringify(d);JSON.stringify(m)!==l&&(Object.keys(d).length&&i.setMapStyle(d),t.__mapStyle=JSON.parse(l)),r=!1}})}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))}])});
\ No newline at end of file
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports.bmap=e(require("echarts")):(t.echarts=t.echarts||{},t.echarts.bmap=e(t.echarts))}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){var n;n=function(t){return o(1).registerCoordinateSystem("bmap",o(2)),o(3),o(4),o(1).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())})}),{version:"1.0.0"}}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(e,o){e.exports=t},function(t,e,o){var n;n=function(t){function e(t,e){this._bmap=t,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=e,this._projection=new BMap.MercatorProjection}function n(t,e){return e=e||[0,0],a.map([0,1],function(o){var n=e[o],r=t[o]/2,i=[],a=[];return i[o]=n-r,a[o]=n+r,i[1-o]=a[1-o]=e[1-o],Math.abs(this.dataToPoint(i)[o]-this.dataToPoint(a)[o])},this)}function r(){function t(t){this._root=t}return t.prototype=new BMap.Overlay,t.prototype.initialize=function(t){return t.getPanes().labelPane.appendChild(this._root),this._root},t.prototype.draw=function(){},t}var i=o(1),a=i.util;e.prototype.dimensions=["lng","lat"],e.prototype.setZoom=function(t){this._zoom=t},e.prototype.setCenter=function(t){this._center=this._projection.lngLatToPoint(new BMap.Point(t[0],t[1]))},e.prototype.setMapOffset=function(t){this._mapOffset=t},e.prototype.getBMap=function(){return this._bmap},e.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]]},e.prototype.pointToData=function(t){var e=this._mapOffset,t=this._bmap.overlayPixelToPoint({x:t[0]+e[0],y:t[1]+e[1]});return[t.lng,t.lat]},e.prototype.getViewRect=function(){var t=this._api;return new i.graphic.BoundingRect(0,0,t.getWidth(),t.getHeight())},e.prototype.getRoamTransform=function(){return i.matrix.create()},e.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:a.bind(this.dataToPoint,this),size:a.bind(n,this)}}};var p;return e.dimensions=e.prototype.dimensions,e.create=function(t,o){var n,i=o.getDom();t.eachComponent("bmap",function(t){var a=o.getZr().painter,s=a.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");if(p=p||r(),n)throw new Error("Only one bmap component can exist");if(!t.__bmap){var c=i.querySelector(".ec-extension-bmap");c&&(s.style.left="0px",s.style.top="0px",i.removeChild(c)),c=document.createElement("div"),c.style.cssText="width:100%;height:100%",c.classList.add("ec-extension-bmap"),i.appendChild(c);var m=t.__bmap=new BMap.Map(c),f=new p(s);m.addOverlay(f),a.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}var m=t.__bmap,d=t.get("center"),l=t.get("zoom");if(d&&l){var u=new BMap.Point(d[0],d[1]);m.centerAndZoom(u,l)}n=new e(m,o),n.setMapOffset(t.__mapOffset||[0,0]),n.setZoom(l),n.setCenter(d),t.coordinateSystem=n}),t.eachSeries(function(t){"bmap"===t.get("coordinateSystem")&&(t.coordinateSystem=n)})},e}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(t,e,o){var n;n=function(t){function e(t,e){return t&&e&&t[0]===e[0]&&t[1]===e[1]}return o(1).extendComponentModel({type:"bmap",getBMap:function(){return this.__bmap},setCenterAndZoom:function(t,e){this.option.center=t,this.option.zoom=e},centerOrZoomChanged:function(t,o){var n=this.option;return!(e(t,n.center)&&o===n.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},roam:!1}})}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))},function(t,e,o){var n;n=function(t){return o(1).extendComponentView({type:"bmap",render:function(t,e,o){function n(){r||o.dispatchAction({type:"bmapRoam"})}var r=!0,i=t.getBMap(),a=o.getZr().painter.getViewportRoot(),p=t.coordinateSystem,s=function(e,n){if(!r){var i=a.parentNode.parentNode.parentNode,s=[-parseInt(i.style.left,10)||0,-parseInt(i.style.top,10)||0];a.style.left=s[0]+"px",a.style.top=s[1]+"px",p.setMapOffset(s),t.__mapOffset=s,o.dispatchAction({type:"bmapRoam"})}};i.removeEventListener("moving",this._oldMoveHandler),i.removeEventListener("zoomend",this._oldZoomEndHandler),i.addEventListener("moving",s),i.addEventListener("zoomend",n),this._oldMoveHandler=s,this._oldZoomEndHandler=n;var c=t.get("roam");c&&"scale"!==c?i.enableDragging():i.disableDragging(),c&&"move"!==c?(i.enableScrollWheelZoom(),i.enableDoubleClickZoom(),i.enablePinchToZoom()):(i.disableScrollWheelZoom(),i.disableDoubleClickZoom(),i.disablePinchToZoom());var m=t.__mapStyle,f=t.get("mapStyle")||{},d=JSON.stringify(f);JSON.stringify(m)!==d&&(Object.keys(f).length&&i.setMapStyle(f),t.__mapStyle=JSON.parse(d)),r=!1}})}.call(e,o,e,t),!(void 0!==n&&(t.exports=n))}])});
\ No newline at end of file
......@@ -52,7 +52,7 @@ return /******/ (function(modules) { // webpackBootstrap
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
var echarts = __webpack_require__(1);
......@@ -64,18 +64,18 @@ return /******/ (function(modules) { // webpackBootstrap
return echarts.dataTool;
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 1 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
/***/ },
/***/ }),
/* 2 */,
/* 3 */,
/* 4 */,
/* 5 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;// GEXF File Parser
// http://gexf.net/1.2draft/gexf-12draft-primer.pdf
......@@ -282,9 +282,9 @@ return /******/ (function(modules) { // webpackBootstrap
};
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 6 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
......@@ -350,9 +350,9 @@ return /******/ (function(modules) { // webpackBootstrap
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ },
/***/ }),
/* 7 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/**
* Copyright (c) 2010-2015, Michael Bostock
......@@ -399,7 +399,7 @@ return /******/ (function(modules) { // webpackBootstrap
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ }
/***/ })
/******/ ])
});
;
\ No newline at end of file
......@@ -4,7 +4,12 @@ define(function (require) {
var numberUtil = require('echarts').number;
/**
* See:
* <https://en.wikipedia.org/wiki/Box_plot#cite_note-frigge_hoaglin_iglewicz-2>
* <http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html>
*
* Helper method for preparing data.
*
* @param {Array.<number>} rawData like
* [
* [12,232,443], (raw data set for the first box)
......@@ -14,10 +19,15 @@ define(function (require) {
* @param {Object} [opt]
*
* @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier.
* default 1.5, means Q1 - 1.5 * (Q3 - Q1).
* If pass 'none', min bound will not be used.
* default 1.5, means Q1 - 1.5 * (Q3 - Q1).
* If 'none'/0 passed, min bound will not be used.
* @param {(number|string)} [opt.layout='horizontal']
* Box plot layout, can be 'horizontal' or 'vertical'
* Box plot layout, can be 'horizontal' or 'vertical'
* @return {Object} {
* boxData: Array.<Array.<number>>
* outliers: Array.<Array.<number>>
* axisData: Array.<string>
* }
*/
return function (rawData, opt) {
opt = opt || [];
......@@ -25,6 +35,7 @@ define(function (require) {
var outliers = [];
var axisData = [];
var boundIQR = opt.boundIQR;
var useExtreme = boundIQR === 'none' || boundIQR === 0;
for (var i = 0; i < rawData.length; i++) {
axisData.push(i + '');
......@@ -33,14 +44,17 @@ define(function (require) {
var Q1 = quantile(ascList, 0.25);
var Q2 = quantile(ascList, 0.5);
var Q3 = quantile(ascList, 0.75);
var IQR = Q3 - Q1;
var low = boundIQR === 'none'
? ascList[0]
: Q1 - (boundIQR == null ? 1.5 : boundIQR) * IQR;
var high = boundIQR === 'none'
? ascList[ascList.length - 1]
: Q3 + (boundIQR == null ? 1.5 : boundIQR) * IQR;
var min = ascList[0];
var max = ascList[ascList.length - 1];
var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1);
var low = useExtreme
? min
: Math.max(min, Q1 - bound);
var high = useExtreme
? max
: Math.min(max, Q3 + bound);
boxData.push([low, Q1, Q2, Q3, high]);
......
/**
* Export echarts as CommonJS module
*/
module.exports = require('./lib/echarts');
\ No newline at end of file
{
"name": "echarts",
"version": "3.6.2",
"version": "3.7.2",
"description": "A powerful charting and visualization library for browser",
"keywords": [
"visualization",
......@@ -32,10 +32,10 @@
"url": "https://github.com/ecomfe/echarts.git"
},
"scripts": {
"prepublish": "node build/amd2common.js"
"prepublish": "rm -r lib; node build/amd2common.js"
},
"dependencies": {
"zrender": "^3.5.2"
"zrender": "^3.6.2"
},
"devDependencies": {
"coordtransform": "^2.0.2",
......@@ -45,6 +45,6 @@
"fs-extra": "^0.26.5",
"glob": "^7.0.0",
"webpack": "^1.12.13",
"zrender": "^3.5.2"
"zrender": "^3.6.2"
}
}
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
function plugins(production) {
let plugins = [
resolve(),
commonjs()
];
if (production) {
plugins.push(uglify({
compress: {
global_defs: {
__DEV__: true
}
}
}));
}
return plugins;
}
function createBuild(type, production) {
if (type) {
type = '.' + type;
}
var postfix = '';
if (production) {
postfix = '.min';
}
return {
entry: `./index${type}.js`,
format: 'umd',
moduleName: 'echarts',
plugins: plugins(production),
dest: `dist/echarts${type}${postfix}.js`
};
}
export default [
createBuild('blank', false),
createBuild('simple', false),
createBuild('common', false),
createBuild('', false),
createBuild('blank', true),
createBuild('simple', true),
createBuild('common', true),
createBuild('', true)
];
\ No newline at end of file
......@@ -58,10 +58,10 @@ define(function(require) {
// }
// },
itemStyle: {
normal: {
// normal: {
// color: '各异'
},
emphasis: {}
// },
// emphasis: {}
}
}
});
......
......@@ -18,7 +18,7 @@ define(function (require) {
);
return {
getBarItemStyle: function (excludes) {
var style = getBarItemStyle.call(this, excludes);
var style = getBarItemStyle(this, excludes);
if (this.getBorderLineDash) {
var lineDash = this.getBorderLineDash();
lineDash && (style.lineDash = lineDash);
......
define(function (require) {
var zrUtil = require('zrender/core/util');
var graphic = require('../../util/graphic');
var helper = {};
......@@ -11,35 +10,22 @@ define(function (require) {
var labelModel = itemModel.getModel('label.normal');
var hoverLabelModel = itemModel.getModel('label.emphasis');
if (labelModel.get('show')) {
setLabel(
normalStyle, labelModel, color,
zrUtil.retrieve2(
seriesModel.getFormattedLabel(dataIndex, 'normal'),
seriesModel.getRawValue(dataIndex)
),
labelPositionOutside
);
}
else {
normalStyle.text = null;
}
graphic.setLabelStyle(
normalStyle, hoverStyle, labelModel, hoverLabelModel,
{
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: seriesModel.getRawValue(dataIndex),
isRectText: true,
autoColor: color
}
);
if (hoverLabelModel.get('show')) {
setLabel(
hoverStyle, hoverLabelModel, false,
seriesModel.getFormattedLabel(dataIndex, 'emphasis'),
labelPositionOutside
);
}
else {
hoverStyle.text = null;
}
fixPosition(normalStyle);
fixPosition(hoverStyle);
};
function setLabel(style, model, defaultColor, labelText, labelPositionOutside) {
graphic.setText(style, model, defaultColor);
style.text = labelText;
function fixPosition(style, labelPositionOutside) {
if (style.textPosition === 'outside') {
style.textPosition = labelPositionOutside;
}
......
......@@ -3,6 +3,7 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
var retrieve = require('zrender/core/util').retrieve;
var parsePercent = require('../../util/number').parsePercent;
var graphic = require('../../util/graphic');
return function (ecModel) {
......@@ -33,6 +34,8 @@ define(function (require) {
return;
}
var dataIndex = 0;
data.each([cDim].concat(vDims), function () {
var args = arguments;
var axisDimVal = args[0];
......@@ -52,17 +55,44 @@ define(function (require) {
var highestPoint = getPoint(highestVal);
var whiskerEnds = [
[highestPoint, ocHighPoint],
[lowestPoint, ocLowPoint]
[
subPixelOptimizePoint(highestPoint),
subPixelOptimizePoint(ocHighPoint)
],
[
subPixelOptimizePoint(lowestPoint),
subPixelOptimizePoint(ocLowPoint)
]
];
var bodyEnds = [];
addBodyEnd(ocHighPoint, 0);
addBodyEnd(ocLowPoint, 1);
var sign;
if (openVal > closeVal) {
sign = -1;
}
else if (openVal < closeVal) {
sign = 1;
}
else {
// If close === open, compare with close of last record
if (dataIndex > 0) {
sign = data.getItemModel(dataIndex - 1).get()[2]
<= closeVal
? 1
: -1;
}
else {
// No record of previous, set to be positive
sign = 1;
}
}
data.setItemLayout(idx, {
chartLayout: chartLayout,
sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0,
sign: sign,
initBaseline: openVal > closeVal
? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
bodyEnds: bodyEnds,
......@@ -70,6 +100,8 @@ define(function (require) {
brushRect: makeBrushRect()
});
++dataIndex;
function getPoint(val) {
var p = [];
p[variableDim] = axisDimVal;
......@@ -82,8 +114,14 @@ define(function (require) {
function addBodyEnd(point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[variableDim] += candleWidth / 2;
point2[variableDim] -= candleWidth / 2;
point1[variableDim] = graphic.subPixelOptimize(
point1[variableDim] + candleWidth / 2, 1, false
);
point2[variableDim] = graphic.subPixelOptimize(
point2[variableDim] - candleWidth / 2, 1, true
);
start
? bodyEnds.push(point1, point2)
: bodyEnds.push(point2, point1);
......@@ -104,6 +142,11 @@ define(function (require) {
};
}
function subPixelOptimizePoint(point) {
point[variableDim] = graphic.subPixelOptimize(point[variableDim], 1);
return point;
}
}, true);
});
};
......@@ -132,6 +175,6 @@ define(function (require) {
? parsePercent(barWidth, bandWidth)
// Put max outer to ensure bar visible in spite of overlap.
: Math.max(Math.min(bandWidth / 2, barMaxWidth), barMinWidth);
}
}
});
\ No newline at end of file
......@@ -341,7 +341,11 @@ define(function (require) {
opacity != null && (itemStyle.opacity = opacity);
if (currLabelValueDim != null) {
graphicUtil.setText(itemStyle, currLabelNormalModel, currVisualColor);
graphicUtil.setTextStyle(itemStyle, currLabelNormalModel, null, {
autoColor: currVisualColor,
isRectText: true
});
itemStyle.text = currLabelNormalModel.getShallow('show')
? zrUtil.retrieve2(
customSeries.getFormattedLabel(dataIndexInside, 'normal'),
......@@ -366,9 +370,16 @@ define(function (require) {
var itemStyle = currItemModel.getModel(ITEM_STYLE_EMPHASIS_PATH).getItemStyle();
if (currLabelValueDim != null) {
graphicUtil.setText(itemStyle, currLabelEmphasisModel, false);
graphicUtil.setTextStyle(itemStyle, currLabelEmphasisModel, null, {
isRectText: true
}, true);
itemStyle.text = currLabelEmphasisModel.getShallow('show')
? customSeries.getFormattedLabel(dataIndexInside, 'emphasis')
? zrUtil.retrieve3(
customSeries.getFormattedLabel(dataIndexInside, 'emphasis'),
customSeries.getFormattedLabel(dataIndexInside, 'normal'),
data.get(currLabelValueDim, dataIndexInside)
)
: null;
}
......
......@@ -127,17 +127,22 @@ define(function (require) {
var labelHoverModel = itemModel.getModel('label.emphasis');
var labelLineModel = itemModel.getModel('labelLine.normal');
var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
var visualColor = data.getItemVisual(idx, 'color');
graphic.setTextStyle(labelText.style, labelModel, {
textAlign: labelLayout.textAlign,
textVerticalAlign: labelLayout.verticalAlign,
text: zrUtil.retrieve(data.hostModel.getFormattedLabel(idx, 'normal'), data.getName(idx))
}, {
defaultTextColor: data.getItemVisual(idx, 'color'),
getDefaultTextColor: function (model, opt) {
return labelLayout.inside ? '#fff' : opt.defaultTextColor;
graphic.setLabelStyle(
labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel,
{
labelFetcher: data.hostModel,
labelDataIndex: idx,
defaultText: data.getName(idx),
autoColor: visualColor,
useInsideStyle: !!labelLayout.inside
},
{
textAlign: labelLayout.textAlign,
textVerticalAlign: labelLayout.verticalAlign
}
});
);
labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
labelText.hoverIgnore = !labelHoverModel.get('show');
......@@ -151,10 +156,6 @@ define(function (require) {
});
labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
labelText.hoverStyle = graphic.setTextStyle({}, labelHoverModel, {
text: data.hostModel.getFormattedLabel(idx, 'emphasis')
}, {forMerge: true});
labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
};
......
......@@ -18,6 +18,35 @@ define(function (require) {
return item.getVisual('opacity') || item.getModel().get(opacityPath);
}
function fadeOutItem(item, opacityPath, opacityRatio) {
var el = item.getGraphicEl();
var opacity = getItemOpacity(item, opacityPath);
if (opacityRatio != null) {
opacity == null && (opacity = 1);
opacity *= opacityRatio;
}
el.downplay && el.downplay();
el.traverse(function (child) {
if (child.type !== 'group') {
child.setStyle('opacity', opacity);
}
});
}
function fadeInItem(item, opacityPath) {
var opacity = getItemOpacity(item, opacityPath);
var el = item.getGraphicEl();
el.highlight && el.highlight();
el.traverse(function (child) {
if (child.type !== 'group') {
child.setStyle('opacity', opacity);
}
});
}
require('../../echarts').extendChartView({
type: 'graph',
......@@ -81,6 +110,7 @@ define(function (require) {
if (forceLayout) {
this._startForceLayoutIteration(forceLayout, layoutAnimation);
}
data.eachItemGraphicEl(function (el, idx) {
var itemModel = data.getItemModel(idx);
// Update draggable
......@@ -121,10 +151,34 @@ define(function (require) {
seriesId: seriesModel.id
});
});
}
}, this);
data.graph.eachEdge(function (edge) {
var el = edge.getGraphicEl();
el.off('mouseover', el.__focusNodeAdjacency);
el.off('mouseout', el.__unfocusNodeAdjacency);
if (edge.getModel().get('focusNodeAdjacency')) {
el.on('mouseover', el.__focusNodeAdjacency = function () {
api.dispatchAction({
type: 'focusNodeAdjacency',
seriesId: seriesModel.id,
edgeDataIndex: edge.dataIndex
});
});
el.on('mouseout', el.__unfocusNodeAdjacency = function () {
api.dispatchAction({
type: 'unfocusNodeAdjacency',
seriesId: seriesModel.id
});
});
}
});
var circularRotateLabel = seriesModel.get('layout') === 'circular'
&& seriesModel.get('circular.rotateLabel');
var cx = data.getLayout('cx');
......@@ -166,82 +220,50 @@ define(function (require) {
focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
var data = this._model.getData();
var dataIndex = payload.dataIndex;
var el = data.getItemGraphicEl(dataIndex);
if (!el) {
return;
}
var graph = data.graph;
var dataType = el.dataType;
var dataIndex = payload.dataIndex;
var edgeDataIndex = payload.edgeDataIndex;
function fadeOutItem(item, opacityPath) {
var opacity = getItemOpacity(item, opacityPath);
var el = item.getGraphicEl();
if (opacity == null) {
opacity = 1;
}
var node = graph.getNodeByIndex(dataIndex);
var edge = graph.getEdgeByIndex(edgeDataIndex);
el.traverse(function (child) {
child.trigger('normal');
if (child.type !== 'group') {
child.setStyle('opacity', opacity * 0.1);
}
});
if (!node && !edge) {
return;
}
function fadeInItem(item, opacityPath) {
var opacity = getItemOpacity(item, opacityPath);
var el = item.getGraphicEl();
el.traverse(function (child) {
child.trigger('emphasis');
if (child.type !== 'group') {
child.setStyle('opacity', opacity);
}
});
}
if (dataIndex !== null && dataType !== 'edge') {
graph.eachNode(function (node) {
fadeOutItem(node, nodeOpacityPath);
});
graph.eachEdge(function (edge) {
fadeOutItem(edge, lineOpacityPath);
});
graph.eachNode(function (node) {
fadeOutItem(node, nodeOpacityPath, 0.1);
});
graph.eachEdge(function (edge) {
fadeOutItem(edge, lineOpacityPath, 0.1);
});
var node = graph.getNodeByIndex(dataIndex);
if (node) {
fadeInItem(node, nodeOpacityPath);
zrUtil.each(node.edges, function (edge) {
if (edge.dataIndex < 0) {
zrUtil.each(node.edges, function (adjacentEdge) {
if (adjacentEdge.dataIndex < 0) {
return;
}
fadeInItem(edge, lineOpacityPath);
fadeInItem(edge.node1, nodeOpacityPath);
fadeInItem(edge.node2, nodeOpacityPath);
fadeInItem(adjacentEdge, lineOpacityPath);
fadeInItem(adjacentEdge.node1, nodeOpacityPath);
fadeInItem(adjacentEdge.node2, nodeOpacityPath);
});
}
if (edge) {
fadeInItem(edge, lineOpacityPath);
fadeInItem(edge.node1, nodeOpacityPath);
fadeInItem(edge.node2, nodeOpacityPath);
}
},
unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
var graph = this._model.getData().graph;
graph.eachNode(function (node) {
var opacity = getItemOpacity(node, nodeOpacityPath);
node.getGraphicEl().traverse(function (child) {
child.trigger('normal');
if (child.type !== 'group') {
child.setStyle('opacity', opacity);
}
});
fadeOutItem(node, nodeOpacityPath);
});
graph.eachEdge(function (edge) {
var opacity = getItemOpacity(edge, lineOpacityPath);
edge.getGraphicEl().traverse(function (child) {
child.trigger('normal');
if (child.type !== 'group') {
child.setStyle('opacity', opacity);
}
});
fadeOutItem(edge, lineOpacityPath);
});
},
......
......@@ -83,6 +83,11 @@ define(function (require) {
vec2.sub(v12, n2.p, n1.p);
var d = vec2.len(v12) - e.d;
var w = n2.w / (n1.w + n2.w);
if (isNaN(w)) {
w = 0;
}
vec2.normalize(v12, v12);
!n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
......
......@@ -49,7 +49,6 @@ define(function (require) {
var nodes = nodeData.mapArray('value', function (value, idx) {
var point = nodeData.getItemLayout(idx);
// var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
var rep = numberUtil.linearMap(value, nodeDataExtent, repulsion);
if (isNaN(rep)) {
rep = (repulsion[0] + repulsion[1]) / 2;
......
......@@ -192,18 +192,17 @@ define(function (require) {
defaultText = rawValue[2];
}
graphic.setText(style, labelModel);
style.text = labelModel.getShallow('show')
? seriesModel.getFormattedLabel(idx, 'normal') || defaultText
: null;
graphic.setText(hoverStl, hoverLabelModel, false);
hoverStl.text = hoverLabelModel.getShallow('show')
? seriesModel.getFormattedLabel(idx, 'emphasis')
: null;
graphic.setLabelStyle(
style, hoverStl, labelModel, hoverLabelModel,
{
labelFetcher: seriesModel,
labelDataIndex: idx,
defaultText: defaultText,
isRectText: true
}
);
rect.setStyle(style);
graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
group.add(rect);
......
......@@ -198,13 +198,13 @@ define(function (require) {
this.stopEffectAnimation();
var symbol = this.childAt(0);
var onEmphasis = function () {
symbol.trigger('emphasis');
symbol.highlight();
if (effectCfg.showEffectOn !== 'render') {
this.startEffectAnimation(effectCfg);
}
};
var onNormal = function () {
symbol.trigger('normal');
symbol.downplay();
if (effectCfg.showEffectOn !== 'render') {
this.stopEffectAnimation();
}
......
......@@ -298,6 +298,8 @@ define(function (require) {
var label = this.childOfName('label');
var defaultLabelColor;
var defaultText;
var normalText;
var emphasisText;
if (showLabel || hoverShowLabel) {
var rawVal = seriesModel.getRawValue(idx);
......@@ -307,31 +309,38 @@ define(function (require) {
? numberUtil.round(rawVal)
: rawVal;
defaultLabelColor = visualColor || '#000';
normalText = zrUtil.retrieve2(
seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
defaultText
);
emphasisText = zrUtil.retrieve2(
seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
normalText
);
}
// label.afterUpdate = lineAfterUpdate;
if (showLabel) {
var labelStyle = graphic.setTextStyle(label.style, labelModel, {
text: zrUtil.retrieve2(
seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
defaultText
)
}, {defaultTextColor: defaultLabelColor});
text: normalText
}, {
autoColor: defaultLabelColor
});
label.__textAlign = labelStyle.textAlign;
label.__verticalAlign = labelStyle.textVerticalAlign;
label.__position = labelStyle.position;
// 'start', 'middle', 'end'
label.__position = labelModel.get('position') || 'middle';
}
else {
label.setStyle('text', null);
}
if (hoverShowLabel) {
// Only these properties supported in this emphasis style here.
label.hoverStyle = {
text: zrUtil.retrieve2(
seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
defaultText
),
text: emphasisText,
textFill: hoverLabelModel.getTextColor(true),
// For merging hover style to normal style, do not use
// `hoverLabelModel.getFont()` here.
......@@ -352,6 +361,14 @@ define(function (require) {
graphic.setHoverStyle(this);
};
lineProto.highlight = function () {
this.trigger('emphasis');
};
lineProto.downplay = function () {
this.trigger('normal');
};
lineProto.updateLayout = function (lineData, idx) {
this.setLinePoints(lineData.getItemLayout(idx));
};
......
......@@ -255,26 +255,17 @@ define(function (require) {
var useNameLabel = seriesScope && seriesScope.useNameLabel;
var valueDim = !useNameLabel && labelHelper.findLabelValueDim(data);
// labelHelper.setTextToStyle(
// data, idx, valueDim, elStyle, seriesModel, labelModel, color
// );
// labelHelper.setTextToStyle(
// data, idx, valueDim, hoverItemStyle, seriesModel, hoverLabelModel, color
// );
if (useNameLabel || valueDim != null) {
graphic.setText(elStyle, labelModel, color);
elStyle.text = labelModel.getShallow('show')
? zrUtil.retrieve2(
seriesModel.getFormattedLabel(idx, 'normal'),
useNameLabel ? data.getName(idx) : data.get(valueDim, idx)
)
: null;
graphic.setText(hoverItemStyle, hoverLabelModel, false);
hoverItemStyle.text = hoverLabelModel.getShallow('show')
? seriesModel.getFormattedLabel(idx, 'emphasis')
: null;
graphic.setLabelStyle(
elStyle, hoverItemStyle, labelModel, hoverLabelModel,
{
labelFetcher: seriesModel,
labelDataIndex: idx,
defaultText: useNameLabel ? data.getName(idx) : data.get(valueDim, idx),
isRectText: true,
autoColor: color
}
);
}
symbolPath.off('mouseover')
......@@ -284,6 +275,8 @@ define(function (require) {
symbolPath.hoverStyle = hoverItemStyle;
// FIXME
// Do not use symbol.trigger('emphasis'), but use symbol.highlight() instead.
graphic.setHoverStyle(symbolPath);
var scale = getScale(symbolSize);
......
......@@ -3,9 +3,7 @@
*/
define(function (require) {
var graphic = require('../../util/graphic');
var modelUtil = require('../../util/model');
var zrUtil = require('zrender/core/util');
var helper = {};
......@@ -30,22 +28,5 @@ define(function (require) {
return valueDim;
};
helper.setTextToStyle = function (
data, dataIndex, valueDim, elStyle, seriesModel, labelModel, color
) {
if (valueDim != null && labelModel.getShallow('show')) {
graphic.setText(elStyle, labelModel, color);
elStyle.text = zrUtil.retrieve(
seriesModel.getFormattedLabel(dataIndex, 'normal'),
valueDim === 'ecDataItemName'
? data.getName(dataIndex)
: data.get(valueDim, dataIndex)
);
}
else {
elStyle.text = '';
}
};
return helper;
});
\ No newline at end of file
......@@ -55,7 +55,11 @@ define(function(require) {
var data = option.data;
addOrdinal && zrUtil.each(data, function (item, index) {
zrUtil.isArray(item) && item.unshift(index);
if (item.value && zrUtil.isArray(item.value)) {
item.value.unshift(index);
} else {
zrUtil.isArray(item) && item.unshift(index);
}
});
var defaultValueDimensions = this.defaultValueDimensions;
......@@ -121,4 +125,4 @@ define(function(require) {
seriesModelMixin: seriesModelMixin,
viewMixin: viewMixin
};
});
\ No newline at end of file
});
......@@ -54,8 +54,20 @@ define(function(require) {
function getStackedOnPoints(coordSys, data) {
var baseAxis = coordSys.getBaseAxis();
var valueAxis = coordSys.getOtherAxis(baseAxis);
var valueStart = baseAxis.onZero
? 0 : valueAxis.scale.getExtent()[0];
var valueStart = 0;
if (!baseAxis.onZero) {
var extent = valueAxis.scale.getExtent();
if (extent[0] > 0) {
// Both positive
valueStart = extent[0];
}
else if (extent[1] < 0) {
// Both negative
valueStart = extent[1];
}
// If is one positive, and one negative, onZero shall be true
}
var valueDim = valueAxis.dim;
......
......@@ -48,9 +48,13 @@ define(function (require) {
var zr = api.getZr();
// Avoid the drag cause ghost shadow
// FIXME Better way ?
zr.painter.getLayer(zlevel).clear(true);
// SVG doesn't support
var isSvg = zr.painter.getType() === 'svg';
if (!isSvg) {
zr.painter.getLayer(zlevel).clear(true);
}
// Config layer with motion blur
if (this._lastZlevel != null) {
if (this._lastZlevel != null && !isSvg) {
zr.configLayer(this._lastZlevel, {
motionBlur: false
});
......@@ -66,10 +70,12 @@ define(function (require) {
notInIndividual && console.warn('Lines with trail effect should have an individual zlevel');
}
zr.configLayer(zlevel, {
motionBlur: true,
lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
});
if (!isSvg) {
zr.configLayer(zlevel, {
motionBlur: true,
lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
});
}
}
this.group.add(lineDraw.group);
......@@ -83,11 +89,20 @@ define(function (require) {
this._lineDraw.updateLayout(seriesModel);
// Not use motion when dragging or zooming
var zr = api.getZr();
zr.painter.getLayer(this._lastZlevel).clear(true);
var isSvg = zr.painter.getType() === 'svg';
if (!isSvg) {
zr.painter.getLayer(this._lastZlevel).clear(true);
}
},
remove: function (ecModel, api) {
this._lineDraw && this._lineDraw.remove(api, true);
// Clear motion when lineDraw is removed
var zr = api.getZr();
var isSvg = zr.painter.getType() === 'svg';
if (!isSvg) {
zr.painter.getLayer(this._lastZlevel).clear(true);
}
},
dispose: function () {}
......
......@@ -116,12 +116,19 @@ define(function (require) {
var polygonGroups = fullData.getItemGraphicEl(fullIndex);
var normalText = zrUtil.retrieve2(
mapModel.getFormattedLabel(idx, 'normal'),
name
);
var emphasisText = zrUtil.retrieve2(
mapModel.getFormattedLabel(idx, 'emphasis'),
normalText
);
var onEmphasis = function () {
var hoverStyle = graphic.setTextStyle({}, hoverLabelModel, {
text: hoverLabelModel.get('show')
? mapModel.getFormattedLabel(idx, 'emphasis')
: null
}, {isRectText: true, forMerge: true});
text: hoverLabelModel.get('show') ? emphasisText : null
}, {isRectText: true, useInsideStyle: false}, true);
circle.style.extendFrom(hoverStyle);
// Make label upper than others if overlaps.
circle.__mapOriginalZ2 = circle.z2;
......@@ -130,14 +137,9 @@ define(function (require) {
var onNormal = function () {
graphic.setTextStyle(circle.style, labelModel, {
text: labelModel.get('show')
? zrUtil.retrieve2(
mapModel.getFormattedLabel(idx, 'normal'),
name
)
: null,
text: labelModel.get('show') ? normalText : null,
textPosition: labelModel.getShallow('position') || 'bottom'
}, {isRectText: true});
}, {isRectText: true, useInsideStyle: false});
if (circle.__mapOriginalZ2 != null) {
circle.z2 = circle.__mapOriginalZ2;
......
......@@ -90,8 +90,10 @@ define(function(require) {
startAngle: 90,
// 最小角度改为0
minAngle: 0,
// 选中扇区偏移量
// 选中扇区偏移量
selectedOffset: 10,
// 高亮扇区偏移量
hoverOffset: 10,
// If use strategy to avoid label overlapping
avoidLabelOverlap: true,
......
......@@ -168,7 +168,7 @@ define(function (require) {
sector.stopAnimation(true);
sector.animateTo({
shape: {
r: layout.r + 10
r: layout.r + seriesModel.get('hoverOffset')
}
}, 300, 'elasticOut');
}
......@@ -229,18 +229,23 @@ define(function (require) {
var labelHoverModel = itemModel.getModel('label.emphasis');
var labelLineModel = itemModel.getModel('labelLine.normal');
var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
var visualColor = data.getItemVisual(idx, 'color');
graphic.setTextStyle(labelText.style, labelModel, {
textVerticalAlign: labelLayout.verticalAlign,
textAlign: labelLayout.textAlign,
opacity: data.getItemVisual(idx, 'opacity'),
text: zrUtil.retrieve(data.hostModel.getFormattedLabel(idx, 'normal'), data.getName(idx))
}, {
defaultTextColor: data.getItemVisual(idx, 'color'),
getDefaultTextColor: function (model, opt) {
return labelLayout.inside ? '#fff' : opt.defaultTextColor;
graphic.setLabelStyle(
labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel,
{
labelFetcher: data.hostModel,
labelDataIndex: idx,
defaultText: data.getName(idx),
autoColor: visualColor,
useInsideStyle: !!labelLayout.inside
},
{
textAlign: labelLayout.textAlign,
textVerticalAlign: labelLayout.verticalAlign,
opacity: data.getItemVisual(idx, 'opacity')
}
});
);
labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
labelText.hoverIgnore = !labelHoverModel.get('show');
......@@ -255,10 +260,6 @@ define(function (require) {
});
labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
labelText.hoverStyle = graphic.setTextStyle({}, labelHoverModel, {
text: data.hostModel.getFormattedLabel(idx, 'emphasis')
}, {forMerge: true});
labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
var smooth = labelLineModel.get('smooth');
......
......@@ -174,25 +174,17 @@ define(function (require) {
symbolPath.setStyle(itemStyle);
symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
graphic.setText(symbolPath.style, labelModel, color);
symbolPath.setStyle({
text: labelModel.get('show')
? zrUtil.retrieve(
seriesModel.getFormattedLabel(
idx, 'normal', null, symbolPath.__dimIdx
),
defaultText
)
: null
});
graphic.setText(symbolPath.hoverStyle, labelHoverModel, true);
symbolPath.hoverStyle.text = labelHoverModel.get('show')
? seriesModel.getFormattedLabel(
idx, 'emphasis', null, symbolPath.__dimIdx
)
: null;
graphic.setLabelStyle(
symbolPath.style, symbolPath.hoverStyle, labelModel, labelHoverModel,
{
labelFetcher: data.hostModel,
labelDataIndex: idx,
labelDimIndex: symbolPath.__dimIdx,
defaultText: data.get(data.dimensions[symbolPath.__dimIdx], idx),
autoColor: color,
isRectText: true
}
);
});
function onEmphasis() {
......
......@@ -5,7 +5,6 @@
define(function (require) {
var graphic = require('../../util/graphic');
var zrUtil = require('zrender/core/util');
var SankeyShape = graphic.extendShape({
shape: {
......@@ -129,25 +128,21 @@ define(function (require) {
style: itemModel.getModel('itemStyle.normal').getItemStyle()
});
graphic.setTextStyle(rect.style, labelModel, {
// Get formatted label in label.normal option
// Use node id if it is not specified
text: labelModel.get('show')
? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
// Use empty string to hide the label
: null
}, {isRectText: true});
var hoverStyle = node.getModel('itemStyle.emphasis').getItemStyle();
graphic.setLabelStyle(
rect.style, hoverStyle, labelModel, labelHoverModel,
{
labelFetcher: seriesModel,
labelDataIndex: node.dataIndex,
defaultText: node.id,
isRectText: true
}
);
rect.setStyle('fill', node.getVisual('color'));
var hoverStyle = node.getModel('itemStyle.emphasis').getItemStyle();
graphic.setHoverStyle(rect, zrUtil.extend(
graphic.setTextStyle(hoverStyle, labelHoverModel, {
text: labelHoverModel.get('show')
? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis')
: null
}, {isRectText: true, forMerge: true})
));
graphic.setHoverStyle(rect, hoverStyle);
group.add(rect);
......
......@@ -119,7 +119,6 @@ define(function (require) {
label: {
normal: {
show: true,
fontSize: 9,
color: '#555'
}
},
......
......@@ -9,6 +9,8 @@
var BoundingRect = require('zrender/core/BoundingRect');
var matrix = require('zrender/core/matrix');
var animationUtil = require('../../util/animation');
var makeStyleMapper = require('../../model/mixin/makeStyleMapper');
var bind = zrUtil.bind;
var Group = graphic.Group;
var Rect = graphic.Rect;
......@@ -23,6 +25,25 @@
var Z_BG = 1;
var Z_CONTENT = 2;
var getItemStyleEmphasis = makeStyleMapper([
['fill', 'color'],
// `borderColor` and `borderWidth` has been occupied,
// so use `stroke` to indicate the stroke of the rect.
['stroke', 'strokeColor'],
['lineWidth', 'strokeWidth'],
['shadowBlur'],
['shadowOffsetX'],
['shadowOffsetY'],
['shadowColor']
]);
var getItemStyleNormal = function (model) {
// Normal style props should include emphasis style props.
var itemStyle = getItemStyleEmphasis(model);
// Clear styles set by emphasis.
itemStyle.stroke = itemStyle.fill = itemStyle.lineWidth = null;
return itemStyle;
};
return require('../../echarts').extendChartView({
type: 'treemap',
......@@ -67,12 +88,6 @@
* @private
*/
this._state = 'ready';
/**
* @private
* @type {boolean}
*/
this._mayClick;
},
/**
......@@ -397,8 +412,6 @@
* @private
*/
_onPan: function (dx, dy) {
this._mayClick = false;
if (this._state !== 'animating'
&& (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
) {
......@@ -431,8 +444,6 @@
* @private
*/
_onZoom: function (scale, mouseX, mouseY) {
this._mayClick = false;
if (this._state !== 'animating') {
// These param must not be cached.
var root = this.seriesModel.getData().tree.root;
......@@ -480,25 +491,11 @@
* @private
*/
_initEvents: function (containerGroup) {
// FIXME
// 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
// 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
// 还是会触发click,期望是不触发。
// Mousedown occurs when drag start, and mouseup occurs when drag end,
// click event should not be triggered in that case.
containerGroup.on('mousedown', function (e) {
this._state === 'ready' && (this._mayClick = true);
}, this);
containerGroup.on('mouseup', function (e) {
if (this._mayClick) {
this._mayClick = false;
this._state === 'ready' && onClick.call(this, e);
containerGroup.on('click', function (e) {
if (this._state !== 'ready') {
return;
}
}, this);
function onClick(e) {
var nodeClick = this.seriesModel.get('nodeClick', true);
if (!nodeClick) {
......@@ -526,7 +523,8 @@
link && window.open(link, linkTarget);
}
}
}
}, this);
},
/**
......@@ -680,6 +678,7 @@
var thisViewChildren = thisNode.viewChildren;
var upperHeight = thisLayout.upperHeight;
var isParent = thisViewChildren && thisViewChildren.length;
var itemStyleNormalModel = thisNode.getModel('itemStyle.normal');
var itemStyleEmphasisModel = thisNode.getModel('itemStyle.emphasis');
// End of closure ariables available in "Procedures in renderNode".
......@@ -728,8 +727,10 @@
var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
updateStyle(bg, function () {
var normalStyle = {fill: visualBorderColor};
var emphasisStyle = {fill: emphasisBorderColor};
var normalStyle = getItemStyleNormal(itemStyleNormalModel);
normalStyle.fill = visualBorderColor;
var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
emphasisStyle.fill = emphasisBorderColor;
if (useUpperLabel) {
var upperLabelWidth = thisWidth - 2 * borderWidth;
......@@ -769,8 +770,9 @@
var visualColor = thisNode.getVisual('color', true);
updateStyle(content, function () {
var normalStyle = {fill: visualColor};
var emphasisStyle = itemStyleEmphasisModel.getItemStyle();
var normalStyle = getItemStyleNormal(itemStyleNormalModel);
normalStyle.fill = visualColor;
var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
......@@ -815,28 +817,30 @@
var normalLabelModel = nodeModel.getModel(
upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
);
graphic.setText(normalStyle, normalLabelModel, visualColor);
upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
if (!normalLabelModel.getShallow('show')) {
normalStyle.text = normalStyle.truncate = null;
}
else {
normalStyle.text = text;
normalStyle.truncate = normalLabelModel.get('ellipsis')
? {
outerWidth: width,
outerHeight: height,
minChar: 2
}
: null;
}
var emphasisLabelModel = nodeModel.getModel(
upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS
);
graphic.setText(emphasisStyle, emphasisLabelModel, false);
var isShow = normalLabelModel.getShallow('show');
graphic.setLabelStyle(
normalStyle, emphasisStyle, normalLabelModel, emphasisLabelModel,
{
defaultText: isShow ? text : null,
autoColor: visualColor,
isRectText: true
}
);
upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
normalStyle.truncate = (isShow && normalLabelModel.get('ellipsis'))
? {
outerWidth: width,
outerHeight: height,
minChar: 2
}
: null;
}
function giveGraphic(storageName, Ctor, depth, z) {
......
......@@ -7,9 +7,10 @@ define(function (require) {
var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
function getAxisLineShape(polar, r0, r, angle) {
var start = polar.coordToPoint([r0, angle]);
var end = polar.coordToPoint([r, angle]);
function getAxisLineShape(polar, rExtent, angle) {
rExtent[1] > rExtent[0] && (rExtent = rExtent.slice().reverse());
var start = polar.coordToPoint([rExtent[0], angle]);
var end = polar.coordToPoint([rExtent[1], angle]);
return {
x1: start[0],
......@@ -19,6 +20,11 @@ define(function (require) {
};
}
function getRadiusIdx(polar) {
var radiusAxis = polar.getRadiusAxis();
return radiusAxis.inverse ? 0 : 1;
}
require('./AxisView').extend({
type: 'angleAxis',
......@@ -60,7 +66,7 @@ define(function (require) {
shape: {
cx: polar.cx,
cy: polar.cy,
r: radiusExtent[1]
r: radiusExtent[getRadiusIdx(polar)]
},
style: lineStyleModel.getLineStyle(),
z2: 1,
......@@ -78,10 +84,11 @@ define(function (require) {
var tickModel = angleAxisModel.getModel('axisTick');
var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
var radius = radiusExtent[getRadiusIdx(polar)];
var lines = zrUtil.map(ticksAngles, function (tickAngle) {
return new graphic.Line({
shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
shape: getAxisLineShape(polar, [radius, radius + tickLen], tickAngle)
});
});
this.group.add(graphic.mergePath(
......@@ -112,7 +119,7 @@ define(function (require) {
// Use length of ticksAngles because it may remove the last tick to avoid overlapping
for (var i = 0; i < ticksAngles.length; i++) {
var r = radiusExtent[1];
var r = radiusExtent[getRadiusIdx(polar)];
var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
var cx = polar.cx;
var cy = polar.cy;
......@@ -156,7 +163,7 @@ define(function (require) {
var colorIndex = (lineCount++) % lineColors.length;
splitLines[colorIndex] = splitLines[colorIndex] || [];
splitLines[colorIndex].push(new graphic.Line({
shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
shape: getAxisLineShape(polar, radiusExtent, ticksAngles[i])
}));
}
......
......@@ -49,7 +49,7 @@ define(function (require) {
* @param {Object} opt Standard axis parameters.
* @param {Array.<number>} opt.position [x, y]
* @param {number} opt.rotation by radian
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'.
* @param {number} [opt.tickDirection=1] 1 or -1
* @param {number} [opt.labelDirection=1] 1 or -1
* @param {number} [opt.labelOffset=0] Usefull when onZero.
......@@ -171,173 +171,14 @@ define(function (require) {
/**
* @private
*/
axisTick: function () {
axisTickLabel: function () {
var axisModel = this.axisModel;
var axis = axisModel.axis;
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
return;
}
var tickModel = axisModel.getModel('axisTick');
var opt = this.opt;
var lineStyleModel = tickModel.getModel('lineStyle');
var tickLen = tickModel.get('length');
var tickInterval = getInterval(tickModel, opt.labelInterval);
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
var ticks = axis.scale.getTicks();
var pt1 = [];
var pt2 = [];
var matrix = this._transform;
for (var i = 0; i < ticksCoords.length; i++) {
// Only ordinal scale support tick interval
if (ifIgnoreOnTick(axis, i, tickInterval)) {
continue;
}
var tickCoord = ticksCoords[i];
pt1[0] = tickCoord;
pt1[1] = 0;
pt2[0] = tickCoord;
pt2[1] = opt.tickDirection * tickLen;
if (matrix) {
v2ApplyTransform(pt1, pt1, matrix);
v2ApplyTransform(pt2, pt2, matrix);
}
// Tick line, Not use group transform to have better line draw
this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
// Id for animation
anid: 'tick_' + ticks[i],
shape: {
x1: pt1[0],
y1: pt1[1],
x2: pt2[0],
y2: pt2[1]
},
style: zrUtil.defaults(
lineStyleModel.getLineStyle(),
{
stroke: axisModel.get('axisLine.lineStyle.color')
}
),
z2: 2,
silent: true
})));
}
},
/**
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
* @param {module:echarts/coord/cartesian/GridModel} gridModel
* @private
*/
axisLabel: function () {
var opt = this.opt;
var axisModel = this.axisModel;
var axis = axisModel.axis;
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
if (!show || axis.scale.isBlank()) {
return;
}
var labelModel = axisModel.getModel('axisLabel');
var labelMargin = labelModel.get('margin');
var ticks = axis.scale.getTicks();
var labels = axisModel.getFormattedLabels();
// Special label rotate.
var labelRotation = (
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
) * PI / 180;
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
var categoryData = axisModel.get('data');
var textEls = [];
var silent = isSilent(axisModel);
var triggerEvent = axisModel.get('triggerEvent');
zrUtil.each(ticks, function (tickVal, index) {
if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
return;
}
var itemLabelModel = labelModel;
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
itemLabelModel = new Model(
categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
);
}
var textColor = itemLabelModel.getTextColor()
|| axisModel.get('axisLine.lineStyle.color');
var tickCoord = axis.dataToCoord(tickVal);
var pos = [
tickCoord,
opt.labelOffset + opt.labelDirection * labelMargin
];
var labelStr = axis.scale.getLabel(tickVal);
var textEl = new graphic.Text({
// Id for animation
anid: 'label_' + tickVal,
position: pos,
rotation: labelLayout.rotation,
silent: silent,
z2: 10
});
graphic.setTextStyle(textEl.style, itemLabelModel, {
text: labels[index],
textAlign: itemLabelModel.getShallow('align', true)
|| labelLayout.textAlign,
textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
|| itemLabelModel.getShallow('baseline', true)
|| labelLayout.textVerticalAlign,
textFill: typeof textColor === 'function'
? textColor(
// (1) In category axis with data zoom, tick is not the original
// index of axis.data. So tick should not be exposed to user
// in category axis.
// (2) Compatible with previous version, which always returns labelStr.
// But in interval scale labelStr is like '223,445', which maked
// user repalce ','. So we modify it to return original val but remain
// it as 'string' to avoid error in replacing.
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
index
)
: textColor
});
// Pack data for mouse event
if (triggerEvent) {
textEl.eventData = makeAxisEventDataBase(axisModel);
textEl.eventData.targetType = 'axisLabel';
textEl.eventData.value = labelStr;
}
// FIXME
this._dumbGroup.add(textEl);
textEl.updateTransform();
textEls.push(textEl);
this.group.add(textEl);
textEl.decomposeTransform();
var tickEls = buildAxisTick(this, axisModel, opt);
var labelEls = buildAxisLabel(this, axisModel, opt);
}, this);
fixMinMaxLabelShow(axisModel, textEls);
fixMinMaxLabelShow(axisModel, labelEls, tickEls);
},
/**
......@@ -366,7 +207,7 @@ define(function (require) {
? extent[1] + gapSignal * gap
: (extent[0] + extent[1]) / 2, // 'middle'
// Reuse labelOffset.
nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0
];
var labelLayout;
......@@ -378,7 +219,7 @@ define(function (require) {
var axisNameAvailableWidth;
if (nameLocation === 'middle') {
if (isNameLocationCenter(nameLocation)) {
labelLayout = innerTextLayout(
opt.rotation,
nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
......@@ -559,32 +400,64 @@ define(function (require) {
);
}
function fixMinMaxLabelShow(axisModel, textEls) {
function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
// If min or max are user set, we need to check
// If the tick on min(max) are overlap on their neighbour tick
// If they are overlapped, we need to hide the min(max) tick label
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
var firstLabel = textEls[0];
var nextLabel = textEls[1];
var lastLabel = textEls[textEls.length - 1];
var prevLabel = textEls[textEls.length - 2];
// FIXME
// Have not consider onBand yet, where tick els is more than label els.
labelEls = labelEls || [];
tickEls = tickEls || [];
var firstLabel = labelEls[0];
var nextLabel = labelEls[1];
var lastLabel = labelEls[labelEls.length - 1];
var prevLabel = labelEls[labelEls.length - 2];
var firstTick = tickEls[0];
var nextTick = tickEls[1];
var lastTick = tickEls[tickEls.length - 1];
var prevTick = tickEls[tickEls.length - 2];
if (showMinLabel === false) {
firstLabel.ignore = true;
ignoreEl(firstLabel);
ignoreEl(firstTick);
}
else if (axisModel.getMin() != null && isTwoLabelOverlapped(firstLabel, nextLabel)) {
showMinLabel ? (nextLabel.ignore = true) : (firstLabel.ignore = true);
else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
if (showMinLabel) {
ignoreEl(nextLabel);
ignoreEl(nextTick);
}
else {
ignoreEl(firstLabel);
ignoreEl(firstTick);
}
}
if (showMaxLabel === false) {
lastLabel.ignore = true;
ignoreEl(lastLabel);
ignoreEl(lastTick);
}
else if (axisModel.getMax() != null && isTwoLabelOverlapped(prevLabel, lastLabel)) {
showMaxLabel ? (prevLabel.ignore = true) : (lastLabel.ignore = true);
else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
if (showMaxLabel) {
ignoreEl(prevLabel);
ignoreEl(prevTick);
}
else {
ignoreEl(lastLabel);
ignoreEl(lastTick);
}
}
}
function ignoreEl(el) {
el && (el.ignore = true);
}
function isTwoLabelOverlapped(current, next, labelLayout) {
// current and next has the same rotation.
var firstRect = current && current.getBoundingRect().clone();
......@@ -605,11 +478,28 @@ define(function (require) {
return firstRect.intersect(nextRect);
}
function isNameLocationCenter(nameLocation) {
return nameLocation === 'middle' || nameLocation === 'center';
}
/**
* @static
*/
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
axis,
i,
interval,
ticksCnt,
showMinLabel,
showMaxLabel
) {
if (i === 0 && showMinLabel || i === ticksCnt - 1 && showMaxLabel) {
return false;
}
// FIXME
// Have not consider label overlap (if label is too long) yet.
var rawTick;
var scale = axis.scale;
return scale.type === 'ordinal'
......@@ -634,6 +524,187 @@ define(function (require) {
return interval;
};
function buildAxisTick(axisBuilder, axisModel, opt) {
var axis = axisModel.axis;
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
return;
}
var tickModel = axisModel.getModel('axisTick');
var lineStyleModel = tickModel.getModel('lineStyle');
var tickLen = tickModel.get('length');
var tickInterval = getInterval(tickModel, opt.labelInterval);
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
// FIXME
// Corresponds to ticksCoords ?
var ticks = axis.scale.getTicks();
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
var pt1 = [];
var pt2 = [];
var matrix = axisBuilder._transform;
var tickEls = [];
var ticksCnt = ticksCoords.length;
for (var i = 0; i < ticksCnt; i++) {
// Only ordinal scale support tick interval
if (ifIgnoreOnTick(
axis, i, tickInterval, ticksCnt,
showMinLabel, showMaxLabel
)) {
continue;
}
var tickCoord = ticksCoords[i];
pt1[0] = tickCoord;
pt1[1] = 0;
pt2[0] = tickCoord;
pt2[1] = opt.tickDirection * tickLen;
if (matrix) {
v2ApplyTransform(pt1, pt1, matrix);
v2ApplyTransform(pt2, pt2, matrix);
}
// Tick line, Not use group transform to have better line draw
var tickEl = new graphic.Line(graphic.subPixelOptimizeLine({
// Id for animation
anid: 'tick_' + ticks[i],
shape: {
x1: pt1[0],
y1: pt1[1],
x2: pt2[0],
y2: pt2[1]
},
style: zrUtil.defaults(
lineStyleModel.getLineStyle(),
{
stroke: axisModel.get('axisLine.lineStyle.color')
}
),
z2: 2,
silent: true
}));
axisBuilder.group.add(tickEl);
tickEls.push(tickEl);
}
return tickEls;
}
function buildAxisLabel(axisBuilder, axisModel, opt) {
var axis = axisModel.axis;
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
if (!show || axis.scale.isBlank()) {
return;
}
var labelModel = axisModel.getModel('axisLabel');
var labelMargin = labelModel.get('margin');
var ticks = axis.scale.getTicks();
var labels = axisModel.getFormattedLabels();
// Special label rotate.
var labelRotation = (
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
) * PI / 180;
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
var categoryData = axisModel.get('data');
var labelEls = [];
var silent = isSilent(axisModel);
var triggerEvent = axisModel.get('triggerEvent');
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
zrUtil.each(ticks, function (tickVal, index) {
if (ifIgnoreOnTick(
axis, index, opt.labelInterval, ticks.length,
showMinLabel, showMaxLabel
)) {
return;
}
var itemLabelModel = labelModel;
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
itemLabelModel = new Model(
categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
);
}
var textColor = itemLabelModel.getTextColor()
|| axisModel.get('axisLine.lineStyle.color');
var tickCoord = axis.dataToCoord(tickVal);
var pos = [
tickCoord,
opt.labelOffset + opt.labelDirection * labelMargin
];
var labelStr = axis.scale.getLabel(tickVal);
var textEl = new graphic.Text({
// Id for animation
anid: 'label_' + tickVal,
position: pos,
rotation: labelLayout.rotation,
silent: silent,
z2: 10
});
graphic.setTextStyle(textEl.style, itemLabelModel, {
text: labels[index],
textAlign: itemLabelModel.getShallow('align', true)
|| labelLayout.textAlign,
textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
|| itemLabelModel.getShallow('baseline', true)
|| labelLayout.textVerticalAlign,
textFill: typeof textColor === 'function'
? textColor(
// (1) In category axis with data zoom, tick is not the original
// index of axis.data. So tick should not be exposed to user
// in category axis.
// (2) Compatible with previous version, which always returns labelStr.
// But in interval scale labelStr is like '223,445', which maked
// user repalce ','. So we modify it to return original val but remain
// it as 'string' to avoid error in replacing.
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
index
)
: textColor
});
// Pack data for mouse event
if (triggerEvent) {
textEl.eventData = makeAxisEventDataBase(axisModel);
textEl.eventData.targetType = 'axisLabel';
textEl.eventData.value = labelStr;
}
// FIXME
axisBuilder._dumbGroup.add(textEl);
textEl.updateTransform();
labelEls.push(textEl);
axisBuilder.group.add(textEl);
textEl.decomposeTransform();
});
return labelEls;
}
return AxisBuilder;
});
\ No newline at end of file
......@@ -9,7 +9,7 @@ define(function (require) {
var getInterval = AxisBuilder.getInterval;
var axisBuilderAttrs = [
'axisLine', 'axisLabel', 'axisTick', 'axisName'
'axisLine', 'axisTickLabel', 'axisName'
];
var selfBuilderAttrs = [
'splitArea', 'splitLine'
......@@ -97,13 +97,19 @@ define(function (require) {
);
var ticks = axis.scale.getTicks();
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
var p1 = [];
var p2 = [];
// Simple optimization
// Batching the lines if color are the same
var lineStyle = lineStyleModel.getLineStyle();
for (var i = 0; i < ticksCoords.length; i++) {
if (ifIgnoreOnTick(axis, i, lineInterval)) {
if (ifIgnoreOnTick(
axis, i, lineInterval, ticksCoords.length,
showMinLabel, showMaxLabel
)) {
continue;
}
......@@ -174,8 +180,14 @@ define(function (require) {
var areaStyle = areaStyleModel.getAreaStyle();
areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
for (var i = 1; i < ticksCoords.length; i++) {
if (ifIgnoreOnTick(axis, i, areaInterval)) {
if (ifIgnoreOnTick(
axis, i, areaInterval, ticksCoords.length,
showMinLabel, showMaxLabel
)) {
continue;
}
......
......@@ -6,7 +6,7 @@ define(function (require) {
var brushHelper = require('../helper/brushHelper');
var graphic = require('../../util/graphic');
var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName'];
var elementList = ['axisLine', 'axisTickLabel', 'axisName'];
var AxisView = require('../../echarts').extendComponentView({
......
......@@ -7,7 +7,7 @@ define(function (require) {
var AxisBuilder = require('./AxisBuilder');
var axisBuilderAttrs = [
'axisLine', 'axisLabel', 'axisTick', 'axisName'
'axisLine', 'axisTickLabel', 'axisName'
];
var selfBuilderAttrs = [
'splitLine', 'splitArea'
......
......@@ -8,7 +8,7 @@ define(function (require) {
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
var axisBuilderAttrs = [
'axisLine', 'axisLabel', 'axisTick', 'axisName'
'axisLine', 'axisTickLabel', 'axisName'
];
var selfBuilderAttr = 'splitLine';
......@@ -66,8 +66,14 @@ define(function (require) {
var p1 = [];
var p2 = [];
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
for (var i = 0; i < ticksCoords.length; ++i) {
if (ifIgnoreOnTick(axis, i, lineInterval)) {
if (ifIgnoreOnTick(
axis, i, lineInterval, ticksCoords.length,
showMinLabel, showMaxLabel
)) {
continue;
}
var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
......
......@@ -392,7 +392,7 @@ define(function(require) {
var isCategoryAxis = axisModel.get('type') === 'category';
var axisDataLen = isCategoryAxis && (axisModel.get('data') || []).length;
if (min != null && min !== 'dataMin') {
if (min != null && min !== 'dataMin' && typeof min !== 'function') {
dataExtent[0] = min;
}
else if (isCategoryAxis) {
......@@ -400,7 +400,7 @@ define(function(require) {
}
var max = axisModel.getMax(true);
if (max != null && max !== 'dataMax') {
if (max != null && max !== 'dataMax' && typeof max !== 'function') {
dataExtent[1] = max;
}
else if (isCategoryAxis) {
......
......@@ -123,8 +123,8 @@ define(function (require) {
var isGeo = mapOrGeoModel.mainType === 'geo';
// map series has data, geo model that controlled by map series
// has no data, otherwise data exists.
// Map series has data. GEO model that controlled by map series
// will be assigned with map data. Other GEO model has no data.
var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
isGeo && ecModel.eachComponent({mainType: 'series', subType: 'map'}, function (mapSeries) {
if (!data && mapSeries.getHostGeoModel() === mapOrGeoModel) {
......@@ -235,14 +235,14 @@ define(function (require) {
(isGeo || isDataNaN && (showLabel || hoverShowLabel))
|| (itemLayout && itemLayout.showLabel)
) {
var query = data ? dataIdx : region.name;
var formattedStr;
var hoverFormattedStr;
var query = !isGeo ? dataIdx : region.name;
var labelFetcher;
// Consider dataIdx not found.
if (!data || dataIdx >= 0) {
formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal');
hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis');
labelFetcher = mapOrGeoModel;
}
var textEl = new graphic.Text({
position: region.center.slice(),
scale: [1 / scale[0], 1 / scale[1]],
......@@ -250,15 +250,19 @@ define(function (require) {
silent: true
});
graphic.setTextStyle(textEl.style, labelModel, {
text: showLabel ? (formattedStr || region.name) : null,
textAlign: 'center',
textVerticalAlign: 'middle'
});
graphic.setTextStyle(textEl.hoverStyle = {}, hoverLabelModel, {
text: hoverShowLabel ? hoverFormattedStr : null
}, {forMerge: true});
graphic.setLabelStyle(
textEl.style, textEl.hoverStyle = {}, labelModel, hoverLabelModel,
{
labelFetcher: labelFetcher,
labelDataIndex: query,
defaultText: region.name,
useInsideStyle: false
},
{
textAlign: 'center',
textVerticalAlign: 'middle'
}
);
regionGroup.add(textEl);
}
......
......@@ -113,7 +113,9 @@ define(function (require) {
function mousedown(e) {
if (e.target && e.target.draggable) {
if (eventTool.notLeftMouse(e)
|| (e.target && e.target.draggable)
) {
return;
}
......@@ -130,15 +132,12 @@ define(function (require) {
}
function mousemove(e) {
if (!checkKeyBinding(this, 'moveOnMouseMove', e) || !this._dragging) {
return;
}
if (e.gestureEvent === 'pinch') {
return;
}
if (interactionMutex.isTaken(this._zr, 'globalPan')) {
if (eventTool.notLeftMouse(e)
|| !checkKeyBinding(this, 'moveOnMouseMove', e)
|| !this._dragging
|| e.gestureEvent === 'pinch'
|| interactionMutex.isTaken(this._zr, 'globalPan')
) {
return;
}
......@@ -160,7 +159,9 @@ define(function (require) {
}
function mouseup(e) {
this._dragging = false;
if (!eventTool.notLeftMouse(e)) {
this._dragging = false;
}
}
function mousewheel(e) {
......
......@@ -211,7 +211,13 @@ define(function (require) {
// Use user given icon first
legendSymbolType = itemIcon || legendSymbolType;
itemGroup.add(symbolCreator.createSymbol(
legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : inactiveColor
legendSymbolType,
0,
0,
itemWidth,
itemHeight,
isSelected ? color : inactiveColor,
true
));
// Compose symbols
......
......@@ -41,6 +41,12 @@ define(function (require) {
* @type {module:zrender/container/Group}
*/
this.group.add(this._controllerGroup = new Group());
/**
*
* @private
*/
this._showController;
},
/**
......@@ -140,7 +146,7 @@ define(function (require) {
var contentRect = contentGroup.getBoundingRect();
var controllerRect = controllerGroup.getBoundingRect();
var showController = contentRect[wh] > maxSize[wh];
var showController = this._showController = contentRect[wh] > maxSize[wh];
var contentPos = [-contentRect.x, -contentRect.y];
// Remain contentPos when scroll animation perfroming.
......@@ -204,7 +210,11 @@ define(function (require) {
// Content translate animation.
var pageInfo = this._getPageInfo(legendModel);
pageInfo.pageIndex != null && graphic.updateProps(
contentGroup, {position: pageInfo.contentPosition}, legendModel
contentGroup,
{position: pageInfo.contentPosition},
// When switch from "show controller" to "not show controller", view should be
// updated immediately without animation, otherwise causes weird efffect.
showController ? legendModel : false
);
this._updatePageInfoView(legendModel, pageInfo);
......@@ -243,7 +253,7 @@ define(function (require) {
var pageFormatter = legendModel.get('pageFormatter');
var pageIndex = pageInfo.pageIndex;
var current = pageIndex != null ? pageIndex + 1 : 0;
var total = pageIndex.pageCount;
var total = pageInfo.pageCount;
pageText && pageFormatter && pageText.setStyle(
'text',
......@@ -281,11 +291,16 @@ define(function (require) {
var pageNextDataIndex;
var targetItemGroup;
contentGroup.eachChild(function (child) {
if (child.__legendDataIndex === currDataIndex) {
targetItemGroup = child;
}
});
if (this._showController) {
contentGroup.eachChild(function (child) {
if (child.__legendDataIndex === currDataIndex) {
targetItemGroup = child;
}
});
}
else {
targetItemGroup = contentGroup.childAt(0);
}
var pageCount = containerRectSize ? Math.ceil(contentRect[wh] / containerRectSize) : 0;
......
......@@ -221,23 +221,18 @@ define(function (require) {
)
);
polygon.hoverStyle = itemModel.getModel('itemStyle.normal').getItemStyle();
var defaultValue = areaData.getName(idx) || '';
var textColor = color || polygon.style.fill;
graphic.setText(polygon.style, labelModel, textColor);
polygon.style.text = labelModel.getShallow('show')
? zrUtil.retrieve(
maModel.getFormattedLabel(idx, 'normal'),
defaultValue
)
: null;
graphic.setText(polygon.hoverStyle, labelHoverModel, false);
polygon.hoverStyle.text = labelHoverModel.getShallow('show')
? maModel.getFormattedLabel(idx, 'emphasis')
: null;
polygon.hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
graphic.setLabelStyle(
polygon.style, polygon.hoverStyle, labelModel, labelHoverModel,
{
labelFetcher: maModel,
labelDataIndex: idx,
defaultText: areaData.getName(idx) || '',
isRectText: true,
autoColor: color
}
);
graphic.setHoverStyle(polygon, {});
......
......@@ -5,7 +5,7 @@ define(function (require) {
var graphic = require('../../util/graphic');
var axisBuilderAttrs = [
'axisLine', 'axisLabel', 'axisTick', 'axisName'
'axisLine', 'axisTickLabel', 'axisName'
];
return require('../../echarts').extendComponentView({
......
......@@ -195,7 +195,8 @@ define(function(require) {
x: groupRect.x - padding[3],
y: groupRect.y - padding[0],
width: groupRect.width + padding[1] + padding[3],
height: groupRect.height + padding[0] + padding[2]
height: groupRect.height + padding[0] + padding[2],
r: titleModel.get('borderRadius')
},
style: style,
silent: true
......
......@@ -30,15 +30,15 @@ define(function (require) {
});
(new DataDiffer(this._featureNames || [], featureNames))
.add(process)
.update(process)
.remove(zrUtil.curry(process, null))
.add(processFeature)
.update(processFeature)
.remove(zrUtil.curry(processFeature, null))
.execute();
// Keep for diff.
this._featureNames = featureNames;
function process(newIndex, oldIndex) {
function processFeature(newIndex, oldIndex) {
var featureName = featureNames[newIndex];
var oldName = featureNames[oldIndex];
var featureOpt = featureOpts[featureName];
......
......@@ -3,6 +3,7 @@ define(function(require) {
var featureManager = require('../featureManager');
var zrUtil = require('zrender/core/util');
var lang = require('../../../lang').toolbox.brush;
function Brush(model, ecModel, api) {
this.model = model;
......@@ -33,14 +34,8 @@ define(function(require) {
keep: 'M4,10.5V1h10.3 M20.7,1h6.1 M33,1h6.1 M55.4,10.5V1H45.2 M4,17.3v6.6 M55.6,17.3v6.6 M4,30.5V40h10.3 M20.7,40 h6.1 M33,40h6.1 M55.4,30.5V40H45.2 M21,18.9h62.9v48.6H21V18.9z', // jshint ignore:line
clear: 'M22,14.7l30.9,31 M52.9,14.7L22,45.7 M4.7,16.8V4.2h13.1 M26,4.2h7.8 M41.6,4.2h7.8 M70.3,16.8V4.2H57.2 M4.7,25.9v8.6 M70.3,25.9v8.6 M4.7,43.2v12.6h13.1 M26,55.8h7.8 M41.6,55.8h7.8 M70.3,43.2v12.6H57.2' // jshint ignore:line
},
title: {
rect: '矩形选择',
polygon: '圈选',
lineX: '横向选择',
lineY: '纵向选择',
keep: '保持选择',
clear: '清除选择'
}
// `rect`, `polygon`, `lineX`, `lineY`, `keep`, `clear`
title: zrUtil.clone(lang.title)
};
var proto = Brush.prototype;
......
......@@ -6,7 +6,7 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
var eventTool = require('zrender/core/event');
var lang = require('../../../lang').toolbox.dataView;
var BLOCK_SPLITER = new Array(60).join('-');
var ITEM_SPLITER = '\t';
......@@ -277,8 +277,8 @@ define(function (require) {
contentToOption: null,
icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28',
title: '数据视图',
lang: ['数据视图', '关闭', '刷新'],
title: zrUtil.clone(lang.title),
lang: zrUtil.clone(lang.lang),
backgroundColor: '#fff',
textColor: '#000',
textareaColor: '#fff',
......
......@@ -6,6 +6,7 @@ define(function(require) {
var BrushTargetManager = require('../../helper/BrushTargetManager');
var history = require('../../dataZoom/history');
var sliderMove = require('../../helper/sliderMove');
var lang = require('../../../lang').toolbox.dataZoom;
var each = zrUtil.each;
......@@ -39,10 +40,8 @@ define(function(require) {
zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
},
title: {
zoom: '区域缩放',
back: '区域缩放还原'
}
// `zoom`, `back`
title: zrUtil.clone(lang.title)
};
var proto = DataZoom.prototype;
......
......@@ -2,6 +2,7 @@ define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var lang = require('../../../lang').toolbox.magicType;
function MagicType(model) {
this.model = model;
......@@ -17,12 +18,8 @@ define(function(require) {
stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line
tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
},
title: {
line: '切换为折线图',
bar: '切换为柱状图',
stack: '切换为堆叠',
tiled: '切换为平铺'
},
// `line`, `bar`, `stack`, `tiled`
title: zrUtil.clone(lang.title),
option: {},
seriesIndex: {}
};
......
......@@ -2,6 +2,7 @@ define(function(require) {
'use strict';
var history = require('../../dataZoom/history');
var lang = require('../../../lang').toolbox.restore;
function Restore(model) {
this.model = model;
......@@ -10,7 +11,7 @@ define(function(require) {
Restore.defaultOption = {
show: true,
icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5',
title: '还原'
title: lang.title
};
var proto = Restore.prototype;
......
define(function (require) {
var env = require('zrender/core/env');
var lang = require('../../../lang').toolbox.saveAsImage;
function SaveAsImage (model) {
this.model = model;
......@@ -9,14 +10,14 @@ define(function (require) {
SaveAsImage.defaultOption = {
show: true,
icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
title: '保存为图片',
title: lang.title,
type: 'png',
// Default use option.backgroundColor
// backgroundColor: '#fff',
name: '',
excludeComponents: ['toolbox'],
pixelRatio: 1,
lang: ['右键另存为图片']
lang: lang.lang.slice()
};
SaveAsImage.prototype.unusable = !env.canvasSupported;
......@@ -49,13 +50,25 @@ define(function (require) {
}
// IE
else {
var lang = model.get('lang');
var html = ''
+ '<body style="margin:0;">'
+ '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />'
+ '</body>';
var tab = window.open();
tab.document.write(html);
if (window.navigator.msSaveOrOpenBlob) {
var bstr = atob(url.split(',')[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while(n--) {
u8arr[n] = bstr.charCodeAt(n);
}
var blob = new Blob([u8arr]);
window.navigator.msSaveOrOpenBlob(blob, title + '.' + type);
}
else {
var lang = model.get('lang');
var html = '' +
'<body style="margin:0;">' +
'<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />' +
'</body>';
var tab = window.open();
tab.document.write(html);
}
}
};
......@@ -64,4 +77,4 @@ define(function (require) {
);
return SaveAsImage;
});
\ No newline at end of file
});
......@@ -741,7 +741,7 @@ define(function (require) {
// Consider browser compatibility.
// IE8 does not support getComputedStyle.
if (document.defaultView.getComputedStyle) {
if (document.defaultView && document.defaultView.getComputedStyle) {
var stl = document.defaultView.getComputedStyle(el);
if (stl) {
width += parseInt(stl.paddingLeft, 10) + parseInt(stl.paddingRight, 10)
......
......@@ -29,7 +29,8 @@ define(function(require) {
itemWidth: null, // The length of the other side.
hoverLink: true, // Enable hover highlight.
hoverLinkDataSize: null,// The size of hovered data.
hoverLinkOnHandle: true // Whether trigger hoverLink when hover handle.
hoverLinkOnHandle: null // Whether trigger hoverLink when hover handle.
// If not specified, follow the value of `realtime`.
},
/**
......@@ -38,7 +39,6 @@ define(function(require) {
optionUpdated: function (newOption, isInit) {
ContinuousModel.superApply(this, 'optionUpdated', arguments);
this.resetTargetSeries();
this.resetExtent();
this.resetVisual(function (mappingOption) {
......
......@@ -606,7 +606,6 @@ define(function(require) {
// For hover link show when hover handle, which might be
// below or upper than sizeExtent.
pos[1] = mathMin(mathMax(0, pos[1]), itemSize[1]);
self._doHoverLinkToSeries(
pos[1],
0 <= pos[0] && pos[0] <= itemSize[0]
......@@ -693,6 +692,7 @@ define(function(require) {
}
var resultBatches = modelUtil.compressBatches(oldBatch, newBatch);
this._dispatchHighDown('downplay', helper.convertDataIndex(resultBatches[0]));
this._dispatchHighDown('highlight', helper.convertDataIndex(resultBatches[1]));
},
......@@ -739,7 +739,6 @@ define(function(require) {
this._hideIndicator();
var indices = this._hoverLinkDataIndices;
this._dispatchHighDown('downplay', helper.convertDataIndex(indices));
indices.length = 0;
......@@ -837,7 +836,8 @@ define(function(require) {
}
function useHoverLinkOnHandle(visualMapModel) {
return !visualMapModel.get('realtime') && visualMapModel.get('hoverLinkOnHandle');
var hoverLinkOnHandle = visualMapModel.get('hoverLinkOnHandle');
return !!(hoverLinkOnHandle == null ? visualMapModel.get('realtime') : hoverLinkOnHandle);
}
function getCursor(orient) {
......
......@@ -81,7 +81,6 @@ define(function(require) {
*/
this._pieceList = [];
this.resetTargetSeries();
this.resetExtent();
/**
......
......@@ -64,7 +64,8 @@ define(function(require) {
zlevel: 0,
z: 4,
seriesIndex: null, // 所控制的series indices,默认所有有value的series.
seriesIndex: 'all', // 'all' or null/undefined: all series.
// A number or an array of number: the specified series.
// set min: 0, max: 200, only for campatible with ec2.
// In fact min max should not have default value.
......@@ -181,26 +182,31 @@ define(function(require) {
);
},
/**
* @protected
* @return {Array.<number>} An array of series indices.
*/
resetTargetSeries: function () {
var thisOption = this.option;
var allSeriesIndex = thisOption.seriesIndex == null;
thisOption.seriesIndex = allSeriesIndex
? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
getTargetSeriesIndices: function () {
var optionSeriesIndex = this.option.seriesIndex;
var seriesIndices = [];
if (optionSeriesIndex == null || optionSeriesIndex === 'all') {
this.ecModel.eachSeries(function (seriesModel, index) {
seriesIndices.push(index);
});
}
else {
seriesIndices = modelUtil.normalizeToArray(optionSeriesIndex);
}
allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
thisOption.seriesIndex.push(index);
});
return seriesIndices;
},
/**
* @public
*/
eachTargetSeries: function (callback, context) {
zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
zrUtil.each(this.getTargetSeriesIndices(), function (seriesIndex) {
callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
}, this);
},
......
......@@ -79,9 +79,22 @@ define(function (require) {
if (min === 'dataMin') {
min = originalExtent[0];
}
else if (typeof min === 'function') {
min = min({
min: originalExtent[0],
max: originalExtent[1]
});
}
if (max === 'dataMax') {
max = originalExtent[1];
}
else if (typeof max === 'function') {
max = max({
min: originalExtent[0],
max: originalExtent[1]
});
}
(min == null || !isFinite(min)) && (min = NaN);
(max == null || !isFinite(max)) && (max = NaN);
......
......@@ -42,7 +42,12 @@ define(function (require) {
var min = (!origin && option.rangeStart != null)
? option.rangeStart : option.min;
if (this.axis && min != null && min !== 'dataMin' && !zrUtil.eqNaN(min)) {
if (this.axis
&& min != null
&& min !== 'dataMin'
&& typeof min !== 'function'
&& !zrUtil.eqNaN(min)
) {
min = this.axis.scale.parse(min);
}
return min;
......@@ -57,7 +62,12 @@ define(function (require) {
var max = (!origin && option.rangeEnd != null)
? option.rangeEnd : option.max;
if (this.axis && max != null && max !== 'dataMax' && !zrUtil.eqNaN(max)) {
if (this.axis
&& max != null
&& max !== 'dataMax'
&& typeof max !== 'function'
&& !zrUtil.eqNaN(max)
) {
max = this.axis.scale.parse(max);
}
return max;
......
......@@ -7,7 +7,7 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
// (24*60*60*1000)
var ONE_DAY = 86400000;
var PROXIMATE_ONE_DAY = 86400000;
/**
* Calendar
......@@ -76,7 +76,16 @@ define(function (require) {
* get date info
*
* @param {string|number} date date
* @return {Object} info
* @return {Object}
* {
* y: string, local full year, eg., '1940',
* m: string, local month, from '01' ot '12',
* d: string, local date, from '01' to '31' (if exists),
* day: It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
* time: timestamp,
* formatedDate: string, yyyy-MM-dd,
* date: original date object.
* }
*/
getDateInfo: function (date) {
......@@ -111,14 +120,15 @@ define(function (require) {
return this.getDateInfo(date);
}
var time = this.getDateInfo(date).time;
date = new Date(this.getDateInfo(date).time);
date.setDate(date.getDate() + n);
return this.getDateInfo(time + ONE_DAY * n);
return this.getDateInfo(date);
},
update: function (ecModel, api) {
this._firstDayOfWeek = this._model.getModel('dayLabel').get('firstDay');
this._firstDayOfWeek = +this._model.getModel('dayLabel').get('firstDay');
this._orient = this._model.get('orient');
this._lineWidth = this._model.getModel('itemStyle.normal').getItemStyle().lineWidth || 0;
......@@ -179,18 +189,18 @@ define(function (require) {
}
var week = dayInfo.day;
var nthWeek = this._getRangeInfo([range.start.time, date]).weeks;
var nthWeek = this._getRangeInfo([range.start.time, date]).nthWeek;
if (this._orient === 'vertical') {
return [
this._rect.x + week * this._sw + this._sw / 2,
this._rect.y + (nthWeek - 1) * this._sh + this._sh / 2
this._rect.y + nthWeek * this._sh + this._sh / 2
];
}
return [
this._rect.x + (nthWeek - 1) * this._sw + this._sw / 2,
this._rect.x + nthWeek * this._sw + this._sw / 2,
this._rect.y + week * this._sh + this._sh / 2
];
......@@ -328,25 +338,60 @@ define(function (require) {
*
* @private
* @param {Array} range range ['2017-01-01', '2017-07-08']
* If range[0] > range[1], they will not be reversed.
* @return {Object} obj
*/
_getRangeInfo: function (range) {
range = [
this.getDateInfo(range[0]),
this.getDateInfo(range[1])
];
var start = this.getDateInfo(range[0]);
var end = this.getDateInfo(range[1]);
var reversed;
if (range[0].time > range[1].time) {
reversed = true;
range.reverse();
}
var allDay = Math.floor(end.time / ONE_DAY) - Math.floor(start.time / ONE_DAY) + 1;
var allDay = Math.floor(range[1].time / PROXIMATE_ONE_DAY)
- Math.floor(range[0].time / PROXIMATE_ONE_DAY) + 1;
// Consider case:
// Firstly set system timezone as "Time Zone: America/Toronto",
// ```
// var first = new Date(1478412000000 - 3600 * 1000 * 2.5);
// var second = new Date(1478412000000);
// var allDays = Math.floor(second / ONE_DAY) - Math.floor(first / ONE_DAY) + 1;
// ```
// will get wrong result because of DST. So we should fix it.
var date = new Date(range[0].time);
var startDateNum = date.getDate();
var endDateNum = range[1].date.getDate();
date.setDate(startDateNum + allDay - 1);
// The bias can not over a month, so just compare date.
if (date.getDate() !== endDateNum) {
var sign = date.getTime() - range[1].time > 0 ? 1 : -1;
while (date.getDate() !== endDateNum && (date.getTime() - range[1].time) * sign > 0) {
allDay -= sign;
date.setDate(startDateNum + allDay - 1);
}
}
var weeks = Math.floor((allDay + range[0].day + 6) / 7);
var nthWeek = reversed ? -weeks + 1: weeks - 1;
var weeks = Math.floor((allDay + start.day + 6) / 7);
reversed && range.reverse();
return {
range: [start.formatedDate, end.formatedDate],
start: start,
end: end,
range: [range[0].formatedDate, range[1].formatedDate],
start: range[0],
end: range[1],
allDay: allDay,
weeks: weeks,
fweek: start.day,
lweek: end.day
// From 0.
nthWeek: nthWeek,
fweek: range[0].day,
lweek: range[1].day
};
},
......@@ -370,11 +415,10 @@ define(function (require) {
}
var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
var date = new Date(rangeInfo.start.time);
date.setDate(rangeInfo.start.d + nthDay);
var time = rangeInfo.start.time + nthDay * ONE_DAY;
return this.getDateInfo(time);
return this.getDateInfo(date);
}
};
......
......@@ -94,15 +94,11 @@ define(function (require) {
label: {
normal: {
show: false,
textStyle: {
color: '#000'
}
color: '#000'
},
emphasis: {
show: true,
textStyle: {
color: 'rgb(100,0,0)'
}
color: 'rgb(100,0,0)'
}
},
......@@ -147,8 +143,7 @@ define(function (require) {
return formatter(params);
}
else if (typeof formatter === 'string') {
var serName = params.seriesName;
return formatter.replace('{a}', serName != null ? serName : '');
return formatter.replace('{a}', name != null ? name : '');
}
},
......
// Fix for 钓鱼岛
define(function (require) {
var Region = require('../Region');
var zrUtil = require('zrender/core/util');
// var Region = require('../Region');
// var zrUtil = require('zrender/core/util');
var geoCoord = [126, 25];
// var geoCoord = [126, 25];
var points = [
[
......
......@@ -33,7 +33,7 @@ define(function(require) {
['width', 'width'],
['opacity', 'opacity']
]
).call(this.getModel('areaSelectStyle'));
)(this.getModel('areaSelectStyle'));
},
/**
......
......@@ -4,8 +4,9 @@ define(function (require) {
var Polar = require('./Polar');
var numberUtil = require('../../util/number');
var zrUtil = require('zrender/core/util');
var axisHelper = require('../../coord/axisHelper');
var parsePercent = numberUtil.parsePercent;
var niceScaleExtent = axisHelper.niceScaleExtent;
// 依赖 PolarModel 做预处理
......@@ -16,20 +17,20 @@ define(function (require) {
* @param {module:echarts/coord/polar/PolarModel} polarModel
* @param {module:echarts/ExtensionAPI} api
*/
function resizePolar(polarModel, api) {
function resizePolar(polar, polarModel, api) {
var center = polarModel.get('center');
var radius = polarModel.get('radius');
var width = api.getWidth();
var height = api.getHeight();
var parsePercent = numberUtil.parsePercent;
this.cx = parsePercent(center[0], width);
this.cy = parsePercent(center[1], height);
polar.cx = parsePercent(center[0], width);
polar.cy = parsePercent(center[1], height);
var radiusAxis = this.getRadiusAxis();
var radiusAxis = polar.getRadiusAxis();
var size = Math.min(width, height) / 2;
// var idx = radiusAxis.inverse ? 1 : 0;
radiusAxis.setExtent(0, parsePercent(radius, size));
var radius = parsePercent(polarModel.get('radius'), size);
radiusAxis.inverse
? radiusAxis.setExtent(radius, 0)
: radiusAxis.setExtent(0, radius);
}
/**
......@@ -73,11 +74,11 @@ define(function (require) {
axis.type = axisModel.get('type');
axis.scale = axisHelper.createScaleByModel(axisModel);
axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
axis.inverse = axisModel.get('inverse');
// FIXME Radius axis not support inverse axis
if (axisModel.mainType === 'angleAxis') {
axis.inverse ^= axisModel.get('clockwise');
var startAngle = axisModel.get('startAngle');
axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
}
......@@ -96,7 +97,6 @@ define(function (require) {
ecModel.eachComponent('polar', function (polarModel, idx) {
var polar = new Polar(idx);
// Inject resize and update method
polar.resize = resizePolar;
polar.update = updatePolarScale;
var radiusAxis = polar.getRadiusAxis();
......@@ -108,7 +108,8 @@ define(function (require) {
setAxis(radiusAxis, radiusAxisModel);
setAxis(angleAxis, angleAxisModel);
polar.resize(polarModel, api);
resizePolar(polar, polarModel, api);
polarList.push(polar);
polarModel.coordinateSystem = polar;
......
......@@ -33,6 +33,7 @@ define(function (require) {
var ExtensionAPI = require('./ExtensionAPI');
var CoordinateSystemManager = require('./CoordinateSystem');
var OptionManager = require('./model/OptionManager');
var backwardCompat = require('./preprocessor/backwardCompat');
var ComponentModel = require('./model/Component');
var SeriesModel = require('./model/Series');
......@@ -43,12 +44,13 @@ define(function (require) {
var modelUtil = require('./util/model');
var throttle = require('./util/throttle');
var zrender = require('zrender');
var zrender = require('zrender/zrender');
var zrUtil = require('zrender/core/util');
var colorTool = require('zrender/tool/color');
var Eventful = require('zrender/mixin/Eventful');
var timsort = require('zrender/core/timsort');
var each = zrUtil.each;
var parseClassType = ComponentModel.parseClassType;
......@@ -74,6 +76,7 @@ define(function (require) {
var OPTION_UPDATED = '__optionUpdated';
var ACTION_REG = /^[a-zA-Z0-9_]+$/;
function createRegisterEventWithLowercaseName(method) {
return function (eventName, handler, context) {
// Event name is all lowercase
......@@ -136,11 +139,13 @@ define(function (require) {
*/
this._throttledZrFlush = throttle.throttle(zrUtil.bind(zr.flush, zr), 17);
var theme = zrUtil.clone(theme);
theme && backwardCompat(theme, true);
/**
* @type {Object}
* @private
*/
this._theme = zrUtil.clone(theme);
this._theme = theme;
/**
* @type {Array.<module:echarts/view/Chart>}
......@@ -1521,9 +1526,9 @@ define(function (require) {
/**
* @type {number}
*/
version: '3.6.2',
version: '3.7.2',
dependencies: {
zrender: '3.5.2'
zrender: '3.6.2'
}
};
......@@ -1940,7 +1945,7 @@ define(function (require) {
};
echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, require('./visual/seriesColor'));
echarts.registerPreprocessor(require('./preprocessor/backwardCompat'));
echarts.registerPreprocessor(backwardCompat);
echarts.registerLoading('default', require('./loading/default'));
// Default action
......@@ -1955,7 +1960,6 @@ define(function (require) {
update: 'downplay'
}, zrUtil.noop);
// --------
// Exports
// --------
......
define(function(require) {
return {
toolbox: {
brush: {
title: {
rect: '矩形选择',
polygon: '圈选',
lineX: '横向选择',
lineY: '纵向选择',
keep: '保持选择',
clear: '清除选择'
}
},
dataView: {
title: '数据视图',
lang: ['数据视图', '关闭', '刷新']
},
dataZoom: {
title: {
zoom: '区域缩放',
back: '区域缩放还原'
}
},
magicType: {
title: {
line: '切换为折线图',
bar: '切换为柱状图',
stack: '切换为堆叠',
tiled: '切换为平铺'
}
},
restore: {
title: '还原'
},
saveAsImage: {
title: '保存为图片',
lang: ['右键另存为图片']
}
}
};
});
\ No newline at end of file
define(function(require) {
return {
toolbox: {
brush: {
title: {
rect: 'Box Select',
polygon: 'Lasso Select',
lineX: 'Horizontally Select',
lineY: 'Vertically Select',
keep: 'Keep Selections',
clear: 'Clear Selections'
}
},
dataView: {
title: 'Data View',
lang: ['Data View', 'Close', 'Refresh']
},
dataZoom: {
title: {
zoom: 'Zoom',
back: 'Zoom Reset'
}
},
magicType: {
title: {
line: 'Switch to Line Chart',
bar: 'Switch to Bar Chart',
stack: 'Stack',
tiled: 'Tile'
}
},
restore: {
title: 'Restore'
},
saveAsImage: {
title: 'Save as Image',
lang: ['Right Click to Save Image']
}
}
};
});
\ No newline at end of file
......@@ -92,6 +92,14 @@ define(function(require) {
var inputPositionParams = layoutMode
? layout.getLayoutParams(option) : {};
// Backward compat: using subType on theme.
// But if name duplicate between series subType
// (for example: parallel) add component mainType,
// add suffix 'Series'.
var themeSubType = this.subType;
if (ComponentModel.hasClass(themeSubType)) {
themeSubType += 'Series';
}
zrUtil.merge(
option,
ecModel.getTheme().get(this.subType)
......
......@@ -25,7 +25,7 @@ define(function () {
// PENDING
fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
// fontFamily: 'Arial, Verdana, sans-serif',
fontSize: 8,
fontSize: 12,
fontStyle: 'normal',
fontWeight: 'normal'
},
......
define(function (require) {
var getAreaStyle = require('./makeStyleMapper')(
[
['fill', 'color'],
['shadowBlur'],
['shadowOffsetX'],
['shadowOffsetY'],
['opacity'],
['shadowColor']
]
);
return {
getAreaStyle: require('./makeStyleMapper')(
[
['fill', 'color'],
['shadowBlur'],
['shadowOffsetX'],
['shadowOffsetY'],
['opacity'],
['shadowColor']
]
)
getAreaStyle: function (excludes, includes) {
return getAreaStyle(this, excludes, includes);
}
};
});
\ No newline at end of file
......@@ -15,7 +15,7 @@ define(function (require) {
);
return {
getItemStyle: function (excludes, includes) {
var style = getItemStyle.call(this, excludes, includes);
var style = getItemStyle(this, excludes, includes);
var lineDash = this.getBorderLineDash();
lineDash && (style.lineDash = lineDash);
return style;
......
......@@ -12,7 +12,7 @@ define(function (require) {
);
return {
getLineStyle: function (excludes) {
var style = getLineStyle.call(this, excludes);
var style = getLineStyle(this, excludes);
var lineDash = this.getLineDash(style.lineWidth);
lineDash && (style.lineDash = lineDash);
return style;
......
......@@ -10,7 +10,7 @@ define(function (require) {
properties[i][1] = properties[i][0];
}
}
return function (excludes, includes) {
return function (model, excludes, includes) {
var style = {};
for (var i = 0; i < properties.length; i++) {
var propName = properties[i][1];
......@@ -19,7 +19,7 @@ define(function (require) {
) {
continue;
}
var val = this.getShallow(propName);
var val = model.getShallow(propName);
if (val != null) {
style[properties[i][0]] = val;
}
......
......@@ -8,13 +8,15 @@ define(function (require) {
return {
/**
* Get color property or get color from option.textStyle.color
* @param {boolean} [noDefault]
* @param {boolean} [isEmphasis]
* @return {string}
*/
getTextColor: function (noDefault) {
getTextColor: function (isEmphasis) {
var ecModel = this.ecModel;
return this.getShallow('color')
|| (!noDefault && ecModel && ecModel.get(PATH_COLOR));
|| (
(!isEmphasis && ecModel) ? ecModel.get(PATH_COLOR) : null
);
},
/**
......
......@@ -56,8 +56,8 @@ define(function (require) {
var each = zrUtil.each;
return function (option) {
compatStyle(option);
return function (option, isTheme) {
compatStyle(option, isTheme);
var series = option.series;
each(zrUtil.isArray(series) ? series : [series], function (seriesOpt) {
......
......@@ -72,6 +72,8 @@ define(function (require) {
compatLabelTextStyle(seriesOpt.label);
// treemap
compatLabelTextStyle(seriesOpt.upperLabel);
// graph
compatLabelTextStyle(seriesOpt.edgeLabel);
var markPoint = seriesOpt.markPoint;
compatItemStyle(markPoint);
......@@ -95,30 +97,31 @@ define(function (require) {
compatItemStyle(data[i]);
compatLabelTextStyle(data[i] && data[i].label);
}
// mark point data
var markPoint = seriesOpt.markPoint;
if (markPoint && markPoint.data) {
var mpData = markPoint.data;
for (var i = 0; i < mpData.length; i++) {
compatItemStyle(mpData[i]);
compatLabelTextStyle(mpData[i] && mpData[i].label);
}
}
// mark point data
var markPoint = seriesOpt.markPoint;
if (markPoint && markPoint.data) {
var mpData = markPoint.data;
for (var i = 0; i < mpData.length; i++) {
compatItemStyle(mpData[i]);
compatLabelTextStyle(mpData[i] && mpData[i].label);
}
// mark line data
var markLine = seriesOpt.markLine;
if (markLine && markLine.data) {
var mlData = markLine.data;
for (var i = 0; i < mlData.length; i++) {
if (zrUtil.isArray(mlData[i])) {
compatItemStyle(mlData[i][0]);
compatLabelTextStyle(mlData[i][0] && mlData[i][0].label);
compatItemStyle(mlData[i][1]);
compatLabelTextStyle(mlData[i][1] && mlData[i][1].label);
}
else {
compatItemStyle(mlData[i]);
compatLabelTextStyle(mlData[i] && mlData[i].label);
}
}
// mark line data
var markLine = seriesOpt.markLine;
if (markLine && markLine.data) {
var mlData = markLine.data;
for (var i = 0; i < mlData.length; i++) {
if (zrUtil.isArray(mlData[i])) {
compatItemStyle(mlData[i][0]);
compatLabelTextStyle(mlData[i][0] && mlData[i][0].label);
compatItemStyle(mlData[i][1]);
compatLabelTextStyle(mlData[i][1] && mlData[i][1].label);
}
else {
compatItemStyle(mlData[i]);
compatLabelTextStyle(mlData[i] && mlData[i].label);
}
}
}
......@@ -132,13 +135,16 @@ define(function (require) {
return (zrUtil.isArray(o) ? o[0] : o) || {};
}
return function (option) {
return function (option, isTheme) {
each(toArr(option.series), function (seriesOpt) {
isObject(seriesOpt) && processSeries(seriesOpt);
});
var axes = ['xAxis', 'yAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'parallelAxis', 'radar'];
isTheme && axes.push('valueAxis', 'categoryAxis', 'logAxis', 'timeAxis');
each(
['xAxis', 'yAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'parallelAxis', 'radar'],
axes,
function (axisName) {
each(toArr(option[axisName]), function (axisOpt) {
if (axisOpt) {
......@@ -167,7 +173,12 @@ define(function (require) {
});
each(toArr(option.geo), function (geoOpt) {
isObject(geoOpt) && compatLabelTextStyle(geoOpt.label);
if (isObject(geoOpt)) {
compatLabelTextStyle(geoOpt.label);
each(toArr(geoOpt.regions), function (regionObj) {
compatLabelTextStyle(regionObj.label);
});
}
});
compatLabelTextStyle(toObj(option.timeline).label);
......
......@@ -35,7 +35,7 @@ define(function (require) {
var bisect = function (a, x, lo, hi) {
while (lo < hi) {
var mid = lo + hi >>> 1;
if (a[mid][2] < x) {
if (a[mid][1] < x) {
lo = mid + 1;
}
else {
......@@ -77,7 +77,7 @@ define(function (require) {
// If there are no data and extent are [Infinity, -Infinity]
if (extent[1] === -Infinity && extent[0] === Infinity) {
var d = new Date();
extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
extent[1] = +new Date(d.getFullYear(), d.getMonth(), d.getDate());
extent[0] = extent[1] - ONE_DAY;
}
......@@ -98,8 +98,6 @@ define(function (require) {
* @override
*/
niceTicks: function (approxTickNum, minInterval, maxInterval) {
var timezoneOffset = this.getSetting('useUTC')
? 0 : numberUtil.getTimezoneOffset() * 60 * 1000;
approxTickNum = approxTickNum || 10;
var extent = this._extent;
......@@ -117,7 +115,7 @@ define(function (require) {
var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
var interval = level[2];
var interval = level[1];
// Same with interval scale if span is much larger than 1 year
if (level[0] === 'year') {
var yearSpan = span / interval;
......@@ -129,9 +127,11 @@ define(function (require) {
interval *= yearStep;
}
var timezoneOffset = this.getSetting('useUTC')
? 0 : (new Date(+extent[0] || +extent[1])).getTimezoneOffset() * 60 * 1000;
var niceExtent = [
Math.round(mathCeil((extent[0] - timezoneOffset) / interval) * interval + timezoneOffset),
Math.round(mathFloor((extent[1] - timezoneOffset)/ interval) * interval + timezoneOffset)
Math.round(mathFloor((extent[1] - timezoneOffset) / interval) * interval + timezoneOffset)
];
scaleHelper.fixExtent(niceExtent, extent);
......@@ -156,27 +156,42 @@ define(function (require) {
// Steps from d3
var scaleLevels = [
// Format step interval
['hh:mm:ss', 1, ONE_SECOND], // 1s
['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
['MM-dd\nyyyy', 1, ONE_DAY], // 1d
['week', 7, ONE_DAY * 7], // 7d
['month', 1, ONE_DAY * 31], // 1M
['quarter', 3, ONE_DAY * 380 / 4], // 3M
['half-year', 6, ONE_DAY * 380 / 2], // 6M
['year', 1, ONE_DAY * 380] // 1Y
// Format interval
['hh:mm:ss', ONE_SECOND], // 1s
['hh:mm:ss', ONE_SECOND * 5], // 5s
['hh:mm:ss', ONE_SECOND * 10], // 10s
['hh:mm:ss', ONE_SECOND * 15], // 15s
['hh:mm:ss', ONE_SECOND * 30], // 30s
['hh:mm\nMM-dd', ONE_MINUTE], // 1m
['hh:mm\nMM-dd', ONE_MINUTE * 5], // 5m
['hh:mm\nMM-dd', ONE_MINUTE * 10], // 10m
['hh:mm\nMM-dd', ONE_MINUTE * 15], // 15m
['hh:mm\nMM-dd', ONE_MINUTE * 30], // 30m
['hh:mm\nMM-dd', ONE_HOUR], // 1h
['hh:mm\nMM-dd', ONE_HOUR * 2], // 2h
['hh:mm\nMM-dd', ONE_HOUR * 6], // 6h
['hh:mm\nMM-dd', ONE_HOUR * 12], // 12h
['MM-dd\nyyyy', ONE_DAY], // 1d
['MM-dd\nyyyy', ONE_DAY * 2], // 2d
['MM-dd\nyyyy', ONE_DAY * 3], // 3d
['MM-dd\nyyyy', ONE_DAY * 4], // 4d
['MM-dd\nyyyy', ONE_DAY * 5], // 5d
['MM-dd\nyyyy', ONE_DAY * 6], // 6d
['week', ONE_DAY * 7], // 7d
['MM-dd\nyyyy', ONE_DAY * 10], // 10d
['week', ONE_DAY * 14], // 2w
['week', ONE_DAY * 21], // 3w
['month', ONE_DAY * 31], // 1M
['week', ONE_DAY * 42], // 6w
['month', ONE_DAY * 62], // 2M
['week', ONE_DAY * 42], // 10w
['quarter', ONE_DAY * 380 / 4], // 3M
['month', ONE_DAY * 31 * 4], // 4M
['month', ONE_DAY * 31 * 5], // 5M
['half-year', ONE_DAY * 380 / 2], // 6M
['month', ONE_DAY * 31 * 8], // 8M
['month', ONE_DAY * 31 * 10], // 10M
['year', ONE_DAY * 380] // 1Y
];
/**
......
此差异已折叠。
......@@ -273,11 +273,14 @@ define(function (require) {
var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
/**
* Consider DST, it is incorrect to provide a method `getTimezoneOffset`
* without time specified. So this method is removed.
*
* @return {number} in minutes
*/
number.getTimezoneOffset = function () {
return (new Date()).getTimezoneOffset();
};
// number.getTimezoneOffset = function () {
// return (new Date()).getTimezoneOffset();
// };
/**
* @param {string|Date|number} value These values can be accepted:
......@@ -311,24 +314,42 @@ define(function (require) {
return new Date(NaN);
}
var timezoneOffset = number.getTimezoneOffset();
var timeOffset = !match[8]
? 0
: match[8].toUpperCase() === 'Z'
? timezoneOffset
: +match[8].slice(0, 3) * 60 + timezoneOffset;
// match[n] can only be string or undefined.
// But take care of '12' + 1 => '121'.
return new Date(
+match[1],
+(match[2] || 1) - 1,
+match[3] || 1,
+match[4] || 0,
+(match[5] || 0) - timeOffset,
+match[6] || 0,
+match[7] || 0
);
// Use local time when no timezone offset specifed.
if (!match[8]) {
// match[n] can only be string or undefined.
// But take care of '12' + 1 => '121'.
return new Date(
+match[1],
+(match[2] || 1) - 1,
+match[3] || 1,
+match[4] || 0,
+(match[5] || 0),
+match[6] || 0,
+match[7] || 0
);
}
// Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
// https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
// For example, system timezone is set as "Time Zone: America/Toronto",
// then these code will get different result:
// `new Date(1478411999999).getTimezoneOffset(); // get 240`
// `new Date(1478412000000).getTimezoneOffset(); // get 300`
// So we should not use `new Date`, but use `Date.UTC`.
else {
var hour = +match[4] || 0;
if (match[8].toUpperCase() !== 'Z') {
hour -= match[8].slice(0, 3);
}
return new Date(Date.UTC(
+match[1],
+(match[2] || 1) - 1,
+match[3] || 1,
hour,
+(match[5] || 0),
+match[6] || 0,
+match[7] || 0
));
}
}
else if (value == null) {
return new Date(NaN);
......
......@@ -86,14 +86,16 @@ define(function(require) {
var tanX = Math.sin(angle);
var tanY = Math.cos(angle);
var cpLen = r * 0.6;
var cpLen2 = r * 0.7;
path.moveTo(x - dx, cy + dy);
path.arc(
x, cy, r,
Math.PI - angle,
Math.PI * 2 + angle
);
var cpLen = r * 0.6;
var cpLen2 = r * 0.7;
path.bezierCurveTo(
x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
x, y - cpLen2,
......@@ -308,8 +310,10 @@ define(function(require) {
* @param {number} w
* @param {number} h
* @param {string} color
* @param {boolean} [keepAspect=false] whether to keep the ratio of w/h,
* for path and image only.
*/
createSymbol: function (symbolType, x, y, w, h, color) {
createSymbol: function (symbolType, x, y, w, h, color, keepAspect) {
// TODO Support image object, DynamicImage.
var isEmpty = symbolType.indexOf('empty') === 0;
......@@ -319,18 +323,19 @@ define(function(require) {
var symbolPath;
if (symbolType.indexOf('image://') === 0) {
symbolPath = new graphic.Image({
style: {
image: symbolType.slice(8),
x: x,
y: y,
width: w,
height: h
}
});
symbolPath = graphic.makeImage(
symbolType.slice(8),
new BoundingRect(x, y, w, h),
keepAspect ? 'center' : 'cover'
);
}
else if (symbolType.indexOf('path://') === 0) {
symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
symbolPath = graphic.makePath(
symbolType.slice(7),
{},
new BoundingRect(x, y, w, h),
keepAspect ? 'center' : 'cover'
);
}
else {
symbolPath = new Symbol({
......
......@@ -142,7 +142,7 @@ define(function (require) {
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastMapToColor(value, thisOption.parsedVisual, out);
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
......@@ -152,7 +152,7 @@ define(function (require) {
_doMap: {
linear: function (normalized) {
return zrColor.stringify(
zrColor.fastMapToColor(normalized, this.option.parsedVisual),
zrColor.fastLerp(normalized, this.option.parsedVisual),
'rgba'
);
},
......@@ -161,7 +161,7 @@ define(function (require) {
var result = getSpecifiedVisual.call(this, value);
if (result == null) {
result = zrColor.stringify(
zrColor.fastMapToColor(normalized, this.option.parsedVisual),
zrColor.fastLerp(normalized, this.option.parsedVisual),
'rgba'
);
}
......
......@@ -38,27 +38,42 @@
<h2>cartesian category axis | xAxis: {min: -10, max: '类目3'}</h2>
<div class="chart" id="main2"></div>
<h2>cartesian category axis | xAxis: {min: function, max: function}</h2>
<div class="chart" id="main2.1"></div>
<h2>cartesian value axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
<div class="chart" id="main3"></div>
<h2>cartesian value axis | xAxis: {min: -10, max: 10}</h2>
<div class="chart" id="main4"></div>
<h2>cartesian value axis | xAxis: {min: function, max: function}</h2>
<div class="chart" id="main4.1"></div>
<h2>cartesian time axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
<div class="chart" id="main5"></div>
<h2>cartesian time axis | xAxis: {min: '2012-08-12', max: '2012-10-01'}</h2>
<div class="chart" id="main6"></div>
<h2>cartesian time axis | xAxis: {min: function, max: function}</h2>
<div class="chart" id="main6.1"></div>
<h2>polar category axis | radiuAxis: {min: 'dataMin', max: 'dataMax'}</h2>
<div class="chart" id="main90.1"></div>
<h2>polar category axis | radiuAxis: {min: function, max: function}</h2>
<div class="chart" id="main90.2"></div>
<h2>parallel category axis | parallelAxis: {min: undefined, max: undefined}</h2>
<div class="chart" id="main91.1"></div>
<h2>single category axis | singleAxis: {min: 'dataMin', max: 'dataMax'}</h2>
<div class="chart" id="main92.1"></div>
<h2>single category axis | singleAxis: {min: function, max: function}</h2>
<div class="chart" id="main92.2"></div>
<script>
......@@ -282,6 +297,57 @@
<script>
makeChart('main2.1', {
legend: {
data: ['no point', 'one point', 'two points'],
selectedMode: 'single'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
grid: {
containLabel: true
},
xAxis: {
data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
min: function (value) {
return value + 20;
},
max: function (value) {
return value + 20;
},
axisTick: {
interval: 0
},
axisLabel: {
interval: 0
}
},
yAxis: {},
series: [{
name: 'no point',
type: 'line',
data: []
}, {
name: 'one point',
type: 'line',
data: [43]
}, {
name: 'two points',
type: 'line',
data: [43, 99]
}]
});
</script>
<script>
makeChart('main3', {
......@@ -354,6 +420,49 @@
<script>
makeChart('main4.1', {
legend: {
data: ['no point', 'one point', 'two points'],
selectedMode: 'single'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
xAxis: {
min: function (value) {
return value + 20;
},
max: function (value) {
return value + 20;
}
},
yAxis: {},
series: [{
name: 'no point',
type: 'line',
data: []
}, {
name: 'one point',
type: 'line',
data: [[2, 43]]
}, {
name: 'two points',
type: 'line',
data: [[2, 43], [4, 99]]
}]
});
</script>
<script>
makeChart('main5', {
legend: {
......@@ -438,6 +547,54 @@
<script>
makeChart('main6.1', {
legend: {
data: ['no point', 'one point', 'two points'],
selectedMode: 'single'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
xAxis: {
type: 'time',
min: function (value) {
return value + 20;
},
max: function (value) {
return value + 20;
}
},
yAxis: {},
series: [{
name: 'one point',
type: 'line',
data: [
[new Date('2012-9-12'), 11]
]
}, {
name: 'two points',
type: 'line',
data: [
['2012-9-12', 11],
['2012-9-18', 14]
]
}, {
name: 'no point',
type: 'line',
data: []
}]
});
</script>
<script>
makeChart('main90.1', {
......@@ -480,6 +637,51 @@
<script>
makeChart('main90.2', {
legend: {
data: ['no point', 'one point', 'two points'],
selectedMode: 'single'
},
tooltip: {
trigger: 'axis'
},
polar: {},
radiusAxis: {
min: function (value) {
return value + 20;
},
max: function (value) {
return value + 20;
},
data: ['类目1', '类目2', '类目3', '类目4', '类目5']
},
angleAxis: {},
series: [{
coordinateSystem: 'polar',
name: 'no point',
type: 'line',
data: []
}, {
coordinateSystem: 'polar',
name: 'one point',
type: 'line',
data: [43]
}, {
coordinateSystem: 'polar',
name: 'two points',
type: 'line',
data: [43, 99]
}]
});
</script>
<script>
makeChart('main91.1', {
......@@ -564,5 +766,54 @@
<script>
makeChart('main92.2', {
legend: {
data: ['no point', 'one point', 'two points'],
selectedMode: 'single'
},
tooltip: {
trigger: 'axis'
},
singleAxis: {
type: 'category',
min: function (value) {
return value + 20;
},
max: function (value) {
return value + 20;
},
data: ['类目1', '类目2', '类目3', '类目4', '类目5']
},
series: [{
coordinateSystem: 'singleAxis',
name: 'no point',
type: 'scatter',
symbolSize: 20,
data: []
}, {
coordinateSystem: 'singleAxis',
name: 'one point',
type: 'scatter',
symbolSize: 20,
data: [[2]]
}, {
coordinateSystem: 'singleAxis',
name: 'two points',
type: 'scatter',
symbolSize: 20,
data: [[2], [4]]
}]
}, true);
</script>
</body>
</html>
\ No newline at end of file
......@@ -3,34 +3,54 @@
<meta charset="utf-8">
<script src="esl.js"></script>
<script src="config.js"></script>
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
margin: 0;
h1 {
line-height: 60px;
height: 60px;
background: #146402;
text-align: center;
font-weight: bold;
color: #eee;
font-size: 14px;
}
#main {
background: #fff;
.chart {
height: 600px;
}
</style>
<div id="main"></div>
<div id="main" class="chart"></div>
<script>
require([
'echarts',
'echarts/chart/bar',
'echarts/chart/line',
'echarts/component/legend',
'echarts/component/graphic',
'echarts/component/grid',
'echarts/component/tooltip',
'echarts/component/toolbox',
'echarts/component/title',
'zrender/vml/vml'
], function (echarts) {
require(
(testHelper.hasURLParam('en')
? [
'echarts',
'echarts/lang/en',
]
: [
'echarts'
]
).concat(
[
'echarts/chart/bar',
'echarts/chart/line',
'echarts/component/legend',
'echarts/component/graphic',
'echarts/component/grid',
'echarts/component/tooltip',
'echarts/component/brush',
'echarts/component/toolbox',
'echarts/component/title',
'zrender/vml/vml'
]
),
function (echarts) {
var chart = echarts.init(document.getElementById('main'));
......@@ -76,6 +96,7 @@
padding: 20
},
legend: {
left: 150,
inactiveColor: '#abc',
borderWidth: 1,
data: [{
......@@ -93,6 +114,9 @@
show: true
}
},
brush: {
xAxisIndex: 0
},
toolbox: {
top: 25,
// right: 20,
......@@ -104,6 +128,11 @@
saveAsImage: {
pixelRatio: 2
},
brush: {
type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear']
},
restore: {},
dataZoom: {},
myTool1: {
show: true,
title: '自定义扩展方法1',
......@@ -217,7 +246,8 @@
});
window.onresize = chart.resize;
});
}
);
</script>
</body>
</html>
\ No newline at end of file
......@@ -15,6 +15,7 @@
height: 100%;
}
</style>
<h2>Test: set system timezone as "Time Zone: America/Toronto", everything should be correct.</h2>
<div id="main"></div>
<script>
......
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="esl.js"></script>
<script src="config.js"></script>
<script src="lib/facePrint.js"></script>
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
}
</style>
<div id="info"></div>
<div id="main"></div>
<script>
/**
* @see <https://en.wikipedia.org/wiki/Michelson%E2%80%93Morley_experiment>
* @see <http://bl.ocks.org/mbostock/4061502>
*/
var chart;
var data;
require([
'echarts',
'data/security-sh-2013.json',
'echarts/chart/candlestick',
'echarts/chart/bar',
'echarts/chart/line',
'echarts/component/title',
'echarts/component/legend',
'echarts/component/grid',
'echarts/component/tooltip'
], function (echarts, rawData) {
chart = echarts.init(document.getElementById('main'), null, {
renderer: 'canvas'
});
option = {
title: {
text: "十字星颜色测试,期望值:红、红、红、绿、红、红、红、绿"
},
"xAxis": [{
"type": "category",
"data": ["2017-08-22", "2017-08-23", "2017-08-24", "2017-08-25", "2017-08-28", "2017-08-29", "2017-08-30", "2017-08-31"],
"scale": true,
"boundaryGap": false,
"axisLine": {
"onZero": false,
"lineStyle": {
"color": "#f1f1f1"
}
},
"axisTick": {
"show": false
},
"axisLabel": {
"show": false
},
"axisPointer": {
"z": 100
}
}],
"yAxis": [{
}],
"series": [{
"name": "stock",
"type": "candlestick",
"data": [
[20, 20, 17, 29],
[22.68, 22.68, 22.68, 22.68],
[24.95, 24.95, 20, 28],
[20, 20, 18, 24],
[35, 35, 35, 40],
[36.54, 36.54, 30, 36.54],
[40, 45, 38, 45],
[32, 28, 27, 33]
],
"itemStyle": {
"normal": {
"color": "#fa6464",
"color0": "#32C896",
"borderColor": "#fa6464",
"borderColor0": "#32C896"
}
},
"markPoint": {
"label": {
"normal": {}
},
"data": []
}
}]
};
chart.setOption(option);
});
</script>
</body>
</html>
\ No newline at end of file
......@@ -119,24 +119,31 @@
// echarts.connect([chart1, chart2]);
bindAction(chart1, chart2, data2);
bindAction(chart2, chart1, data1);
function bindAction(fromChart, toChart, toData) {
fromChart.on('updateAxisPointer', function (params) {
toChart.dispatchAction(
toChart.makeActionFromEvent(params),
true
);
});
bindAction([chart1, chart2]);
function bindAction(chartList) {
echarts.util.each(chartList, function (fromChart) {
echarts.util.each(chartList, function (toChart) {
if (fromChart === toChart) {
return;
}
fromChart.on('updateAxisPointer', function (params) {
toChart.dispatchAction(
toChart.makeActionFromEvent(params),
true
);
});
fromChart.on('dataZoom', function (params) {
toChart.dispatchAction({
type: 'dataZoom',
dataZoomIndex: params.batch[0].dataZoomIndex,
start: params.batch[0].start,
end: params.batch[0].end
}, true);
fromChart.on('dataZoom', function (params) {
toChart.dispatchAction({
type: 'dataZoom',
dataZoomIndex: params.batch[0].dataZoomIndex,
start: params.batch[0].start,
end: params.batch[0].end
}, true);
});
});
});
}
......
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<script src="esl.js"></script>
<script src="config.js"></script>
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="reset.css">
</head>
<body>
<style>
h1 {
line-height: 60px;
height: 60px;
background: #146402;
text-align: center;
font-weight: bold;
color: #eee;
font-size: 14px;
}
.chart {
height: 500px;
}
</style>
<div class="chart" id="main"></div>
<script>
var echarts;
var chart;
var myChart;
var groupCategories = [];
var groupColors = [];
require([
'echarts',
'echarts/chart/line',
'echarts/chart/bar',
'echarts/chart/pie',
'echarts/chart/scatter',
'echarts/chart/custom',
'echarts/chart/parallel',
'echarts/chart/radar',
'echarts/component/grid',
'echarts/component/polar',
'echarts/component/geo',
'echarts/component/singleAxis',
'echarts/component/legend',
'echarts/component/tooltip',
'echarts/component/toolbox',
'echarts/component/visualMap',
'echarts/component/dataZoom'
], function (ec) {
echarts = ec;
chart = myChart = echarts.init(document.getElementById('main'));
var data = [
{name:'广州', value: 50},
{name:'深圳', value: 72},
{name:'珠海', value: 30},
{name:'佛山', value: 38},
{name:'杭州', value: 42},
{name:'舟山', value: 32},
{name:'宁波', value: 52}
];
option = {
tooltip : {
trigger: 'item'
},
legend: {
data:['广州','深圳','珠海','佛山','杭州','舟山','宁波'],
top: 0,
left: 'center'
},
xAxis : [
{
type : 'category',
data : [0],
axisTick: {show: false},
axisLabel: {show: false}
},
],
yAxis : [
{
type : 'value'
}
],
series : echarts.util.map(data, function (item) {
return {
name: item.name,
type: 'bar',
label: {
normal: {
show: true,
position: 'bottom',
formatter: function (param) {
return param.seriesName;
}
}
},
data: [item.value]
}
}).concat([{
type: 'custom',
renderItem: renderProvinceName,
data: [0]
}])
};
function renderProvinceName(param, api) {
var currentSeriesIndices = api.currentSeriesIndices();
currentSeriesIndices.pop(); // remove custom series;
var barLayout = api.barLayout({
barGap: '30%', barCategoryGap: '20%', count: currentSeriesIndices.length
});
var nameTexts = echarts.util.map(currentSeriesIndices, function (serIdx, index) {
var point = api.coord([0, 0]);
point[0] += barLayout[index].offsetCenter;
point[1] = api.getHeight() - 20;
return {
position: point,
name: serIdx,
type: 'circle',
shape: {
cx: 0, cy: 0, r: 10
},
style: {
text: serIdx,
fill: '#333',
stroke: null
}
};
});
return {
type: 'group',
diffChildrenByName: true,
children: nameTexts
};
}
chart.setOption(option);
});
</script>
</body>
</html>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册