提交 71b7a9fc 编写于 作者: O Ovilia

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

/**
* Export echarts as CommonJS module
*/
module.exports = require('./lib/echarts');
require('./lib/lang/en');
require('./index/part.common');
/**
* Export echarts as CommonJS module
*/
module.exports = require('./lib/echarts');
require('./lib/lang/en');
require('./index/part');
\ No newline at end of file
/**
* Export echarts as CommonJS module
*/
module.exports = require('./lib/echarts');
require('./lib/lang/en');
require('./index/part.simple');
\ No newline at end of file
/**
* Export echarts as CommonJS module
*/
module.exports = require('./lib/echarts');
\ No newline at end of file
......@@ -3,22 +3,4 @@
*/
module.exports = require('./lib/echarts');
require('./lib/chart/line');
require('./lib/chart/bar');
require('./lib/chart/pie');
require('./lib/chart/scatter');
require('./lib/component/graphic');
require('./lib/component/tooltip');
require('./lib/component/axisPointer');
require('./lib/component/legendScroll');
require('./lib/component/grid');
require('./lib/component/title');
require('./lib/component/markPoint');
require('./lib/component/markLine');
require('./lib/component/markArea');
require('./lib/component/dataZoom');
require('./lib/component/toolbox');
require('zrender/lib/vml/vml');
\ No newline at end of file
require('./index/part.common');
\ No newline at end of file
......@@ -3,51 +3,4 @@
*/
module.exports = require('./lib/echarts');
// Import all charts and components
require('./lib/chart/line');
require('./lib/chart/bar');
require('./lib/chart/pie');
require('./lib/chart/scatter');
require('./lib/chart/radar');
require('./lib/chart/map');
require('./lib/chart/treemap');
require('./lib/chart/graph');
require('./lib/chart/gauge');
require('./lib/chart/funnel');
require('./lib/chart/parallel');
require('./lib/chart/sankey');
require('./lib/chart/boxplot');
require('./lib/chart/candlestick');
require('./lib/chart/effectScatter');
require('./lib/chart/lines');
require('./lib/chart/heatmap');
require('./lib/chart/pictorialBar');
require('./lib/chart/themeRiver');
require('./lib/chart/custom');
require('./lib/component/graphic');
require('./lib/component/grid');
require('./lib/component/legendScroll');
require('./lib/component/tooltip');
require('./lib/component/axisPointer');
require('./lib/component/polar');
require('./lib/component/geo');
require('./lib/component/parallel');
require('./lib/component/singleAxis');
require('./lib/component/brush');
require('./lib/component/calendar');
require('./lib/component/title');
require('./lib/component/dataZoom');
require('./lib/component/visualMap');
require('./lib/component/markPoint');
require('./lib/component/markLine');
require('./lib/component/markArea');
require('./lib/component/timeline');
require('./lib/component/toolbox');
require('zrender/lib/vml/vml');
require('./index/part');
\ No newline at end of file
......@@ -3,7 +3,4 @@
*/
module.exports = require('./lib/echarts');
require('./lib/chart/line');
require('./lib/chart/bar');
require('./lib/chart/pie');
require('./lib/component/gridSimple');
\ No newline at end of file
require('./index/part.simple');
\ No newline at end of file
require('../lib/chart/line');
require('../lib/chart/bar');
require('../lib/chart/pie');
require('../lib/chart/scatter');
require('../lib/component/graphic');
require('../lib/component/tooltip');
require('../lib/component/axisPointer');
require('../lib/component/legendScroll');
require('../lib/component/grid');
require('../lib/component/title');
require('../lib/component/markPoint');
require('../lib/component/markLine');
require('../lib/component/markArea');
require('../lib/component/dataZoom');
require('../lib/component/toolbox');
require('zrender/lib/vml/vml');
\ No newline at end of file
// Import all charts and components
require('../lib/chart/line');
require('../lib/chart/bar');
require('../lib/chart/pie');
require('../lib/chart/scatter');
require('../lib/chart/radar');
require('../lib/chart/map');
require('../lib/chart/treemap');
require('../lib/chart/graph');
require('../lib/chart/gauge');
require('../lib/chart/funnel');
require('../lib/chart/parallel');
require('../lib/chart/sankey');
require('../lib/chart/boxplot');
require('../lib/chart/candlestick');
require('../lib/chart/effectScatter');
require('../lib/chart/lines');
require('../lib/chart/heatmap');
require('../lib/chart/pictorialBar');
require('../lib/chart/themeRiver');
require('../lib/chart/custom');
require('../lib/component/graphic');
require('../lib/component/grid');
require('../lib/component/legendScroll');
require('../lib/component/tooltip');
require('../lib/component/axisPointer');
require('../lib/component/polar');
require('../lib/component/geo');
require('../lib/component/parallel');
require('../lib/component/singleAxis');
require('../lib/component/brush');
require('../lib/component/calendar');
require('../lib/component/title');
require('../lib/component/dataZoom');
require('../lib/component/visualMap');
require('../lib/component/markPoint');
require('../lib/component/markLine');
require('../lib/component/markArea');
require('../lib/component/timeline');
require('../lib/component/toolbox');
require('zrender/lib/vml/vml');
require('../lib/chart/line');
require('../lib/chart/bar');
require('../lib/chart/pie');
require('../lib/component/gridSimple');
\ No newline at end of file
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: {}
}
}
});
......
......@@ -3,6 +3,7 @@ define(function(require) {
var featureManager = require('../featureManager');
var zrUtil = require('zrender/core/util');
var lang = require('../../../echarts').getLang().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('../../../echarts').getLang().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('../../../echarts').getLang().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('../../../echarts').getLang().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('../../../echarts').getLang().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('../../../echarts').getLang().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;
......
......@@ -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`.
},
/**
......
......@@ -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) {
......
......@@ -43,13 +43,15 @@ define(function (require) {
var graphic = require('./util/graphic');
var modelUtil = require('./util/model');
var throttle = require('./util/throttle');
var langDefault = require('./lang/default');
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;
......@@ -75,6 +77,8 @@ define(function (require) {
var OPTION_UPDATED = '__optionUpdated';
var ACTION_REG = /^[a-zA-Z0-9_]+$/;
var langSet = zrUtil.clone(langDefault);
function createRegisterEventWithLowercaseName(method) {
return function (eventName, handler, context) {
// Event name is all lowercase
......@@ -1942,6 +1946,21 @@ define(function (require) {
zrUtil.createCanvas = creator;
};
/**
* @param {Object} langObj
*/
echarts.setLang = function (langObj) {
langSet = langSet || {};
zrUtil.merge(langSet, langObj, true);
};
/**
* @return {Ojbect} Lang set.
*/
echarts.getLang = function () {
return langSet;
};
echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, require('./visual/seriesColor'));
echarts.registerPreprocessor(backwardCompat);
echarts.registerLoading('default', require('./loading/default'));
......@@ -1958,7 +1977,6 @@ define(function (require) {
update: 'downplay'
}, zrUtil.noop);
// --------
// Exports
// --------
......
define(function(require) {
require('../echarts').setLang(require('./default'));
});
\ No newline at end of file
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) {
require('../echarts').setLang({
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
......@@ -551,7 +551,7 @@ define(function(require) {
* for textFill, textStroke, textBackgroundColor, and textBorderColor.
* If autoColor specified, it is used as default textFill.
* useInsideStyle:
* `true`: Use inside style (textFill, textStroke, textLineWidth)
* `true`: Use inside style (textFill, textStroke, textStrokeWidth)
* if `textFill` is not specified.
* `false`: Do not use inside style.
* `null/undefined`: use inside style if `isRectText` is true and
......@@ -664,7 +664,7 @@ define(function(require) {
|| globalTextStyle.color;
textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt)
|| globalTextStyle.textBorderColor;
textStyle.textLineWidth = zrUtil.retrieve2(
textStyle.textStrokeWidth = zrUtil.retrieve2(
textStyleModel.getShallow('textBorderWidth'),
globalTextStyle.textBorderWidth
);
......@@ -748,13 +748,13 @@ define(function(require) {
insideRollback = {
textFill: null,
textStroke: textStyle.textStroke,
textLineWidth: textStyle.textLineWidth
textStrokeWidth: textStyle.textStrokeWidth
};
textStyle.textFill = '#fff';
// Consider text with #fff overflow its container.
if (textStyle.textStroke == null) {
textStyle.textStroke = opt.autoColor;
textStyle.textLineWidth == null && (textStyle.textLineWidth = 2);
textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
}
}
......@@ -766,7 +766,7 @@ define(function(require) {
if (insideRollback) {
style.textFill = insideRollback.textFill;
style.textStroke = insideRollback.textStroke;
style.textLineWidth = insideRollback.textLineWidth;
style.textStrokeWidth = insideRollback.textStrokeWidth;
}
}
......
......@@ -3,34 +3,59 @@
<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>
<h1>
<input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'cn')" value="CN"/>
<input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'en')" value="EN"/>
</h1>
<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 +101,7 @@
padding: 20
},
legend: {
left: 150,
inactiveColor: '#abc',
borderWidth: 1,
data: [{
......@@ -93,6 +119,9 @@
show: true
}
},
brush: {
xAxisIndex: 0
},
toolbox: {
top: 25,
// right: 20,
......@@ -104,6 +133,11 @@
saveAsImage: {
pixelRatio: 2
},
brush: {
type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear']
},
restore: {},
dataZoom: {},
myTool1: {
show: true,
title: '自定义扩展方法1',
......@@ -217,7 +251,8 @@
});
window.onresize = chart.resize;
});
}
);
</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);
});
});
});
}
......
此差异已折叠。
......@@ -38,9 +38,41 @@
} else if (window.addEventListener) {
window.addEventListener('resize', chart.resize, false);
}
},
// Clean params specified by `cleanList` and seed a param specifid by `newVal` in URL.
setURLParam: function (cleanList, newVal) {
var params = getParamListFromURL();
for (var i = params.length - 1; i >= 0; i--) {
for (var j = 0; j < cleanList.length; j++) {
if (params[i] === cleanList[j]) {
params.splice(i, 1);
}
}
}
newVal && params.push(newVal);
params.sort();
location.search = params.join('&');
},
// Whether has param `val` in URL.
hasURLParam: function (val) {
var params = getParamListFromURL();
for (var i = params.length - 1; i >= 0; i--) {
if (params[i] === val) {
return true;
}
}
return false;
}
};
function getParamListFromURL() {
var params = location.search.replace('?', '');
return params ? params.split('&') : [];
}
context.testHelper = testHelper;
})(window);
\ No newline at end of file
<!DOCTYPE>
<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/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<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/map',
'echarts/chart/custom',
'echarts/component/geo',
'echarts/component/legend',
'echarts/component/tooltip',
'echarts/component/toolbox',
'echarts/component/visualMap',
'echarts/component/dataZoom'
], function (ec) {
echarts = ec;
$.get('../map/json/world.json', function (worldJson) {
echarts.registerMap('world', worldJson);
$.getJSON('./data/global-wind.json', function (windData) {
var p = 0;
var maxMag = 0;
var minMag = Infinity;
var data = [];
for (var j = 0; j < windData.ny; j++) {
for (var i = 0; i < windData.nx; i++, p++) {
var vx = windData.data[p][0];
var vy = windData.data[p][1];
var mag = Math.sqrt(vx * vx + vy * vy);
// 数据是一个一维数组
// [ [经度, 维度,向量经度方向的值,向量维度方向的值] ]
data.push([
i / windData.nx * 360 - 180,
j / windData.ny * 180 - 90,
vx,
vy,
mag
]);
maxMag = Math.max(mag, maxMag);
minMag = Math.min(mag, minMag);
}
}
data.reverse();
var option = {
backgroundColor: '#333',
visualMap: {
left: 'center',
min: minMag,
max: maxMag,
dimension: 4,
inRange: {
// color: ['green', 'yellow', 'red']
color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
},
realtime: false,
hoverLink: true,
calculable: true,
textStyle: {
color: '#fff'
},
orient: 'horizontal'
},
geo: {
map: 'world',
left: 0,
right: 0,
top: 0,
zoom: 1,
silent: true,
itemStyle: {
normal: {
areaColor: '#323c48',
borderColor: '#111'
}
}
},
series: {
type: 'custom',
coordinateSystem: 'geo',
data: data,
// silent: true,
encode: {
x: 0,
y: 0
},
renderItem: function (params, api) {
var x = api.value(0), y = api.value(1), dx = api.value(2), dy = api.value(3);
var start = api.coord([Math.max(x - dx / 5, -180), Math.max(y - dy / 5, -90)]);
var end = api.coord([Math.min(x + dx / 5, 180), Math.min(y + dy / 5, 90)]);
return {
type: 'line',
shape: {
x1: start[0], y1: start[1],
x2: end[0], y2: end[1]
},
style: {
lineWidth: 0.5,
stroke: api.visual('color')
}
}
},
progressive: 2000
}
};
testHelper.createChart(echarts, 'main', 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.
先完成此消息的编辑!
想要评论请 注册