提交 fbc508bd 编写于 作者: S sushuang

to es6 module I.

上级 6251d60b
......@@ -2,7 +2,6 @@
"bitwise": false,
"camelcase": true,
"curly": true,
"es3": true,
"eqeqeq": false,
"forin": false,
"immed": true,
......@@ -26,7 +25,7 @@
"boss": false,
"debug": false,
"eqnull": true,
"esnext": false,
"esversion": 6,
"evil": true,
"expr": true,
"funcscope": false,
......@@ -65,8 +64,6 @@
"white": false,
"predef": [
"define",
"require",
"__DEV__",
"global"
]
......
#!/bin/bash
basePath=$(cd `dirname $0`; pwd)
cd ${basePath}
rm -r dist
npm run prepublish
./node_modules/rollup/bin/rollup --config
#!/bin/bash
basePath=$(cd `dirname $0`; pwd)
cd ${basePath}/../
rm -r dist
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
......@@ -4,12 +4,17 @@ import uglify from 'rollup-plugin-uglify';
function plugins(production) {
let plugins = [
resolve(),
resolve({
extensions: ['.js'],
jsnext: true,
main: true
}),
commonjs()
];
if (production) {
plugins.push(uglify({
compress: {
// Eliminate __DEV__ code.
global_defs: {
__DEV__: true
}
......@@ -19,6 +24,11 @@ function plugins(production) {
return plugins;
}
// ??????????
// en lang
function createBuild(type, production) {
if (type) {
type = '.' + type;
......@@ -28,11 +38,18 @@ function createBuild(type, production) {
postfix = '.min';
}
return {
entry: `./index${type}.js`,
format: 'umd',
moduleName: 'echarts',
input: `./index${type}.js`,
name: 'echarts',
plugins: plugins(production),
dest: `dist/echarts${type}${postfix}.js`
legacy: true, // Support IE8-
output: {
format: 'umd',
sourcemap: true,
file: `dist/echarts${type}${postfix}.js`
},
watch: {
include: ['./src/**', './index*.js']
}
};
}
......
define(function (require) {
var echarts = require('../echarts');
var zrUtil = require('zrender/core/util');
return function (seriesType, actionInfos) {
zrUtil.each(actionInfos, function (actionInfo) {
actionInfo.update = 'updateView';
/**
* @payload
* @property {string} seriesName
* @property {string} name
*/
echarts.registerAction(actionInfo, function (payload, ecModel) {
var selected = {};
ecModel.eachComponent(
{mainType: 'series', subType: seriesType, query: payload},
function (seriesModel) {
if (seriesModel[actionInfo.method]) {
seriesModel[actionInfo.method](
payload.name,
payload.dataIndex
);
}
var data = seriesModel.getData();
// Create selected map
data.each(function (idx) {
var name = data.getName(idx);
selected[name] = seriesModel.isSelected(name)
|| false;
});
import echarts from '../echarts';
import {util as zrUtil} from 'zrender';
export default function (seriesType, actionInfos) {
zrUtil.each(actionInfos, function (actionInfo) {
actionInfo.update = 'updateView';
/**
* @payload
* @property {string} seriesName
* @property {string} name
*/
echarts.registerAction(actionInfo, function (payload, ecModel) {
var selected = {};
ecModel.eachComponent(
{mainType: 'series', subType: seriesType, query: payload},
function (seriesModel) {
if (seriesModel[actionInfo.method]) {
seriesModel[actionInfo.method](
payload.name,
payload.dataIndex
);
}
);
return {
name: payload.name,
selected: selected
};
});
var data = seriesModel.getData();
// Create selected map
data.each(function (idx) {
var name = data.getName(idx);
selected[name] = seriesModel.isSelected(name)
|| false;
});
}
);
return {
name: payload.name,
selected: selected
};
});
};
});
\ No newline at end of file
});
}
\ No newline at end of file
define(function (require) {
var zrUtil = require('zrender/core/util');
var roamHelper = require('./roamHelper');
var echarts = require('../echarts');
/**
* @payload
* @property {string} [componentType=series]
* @property {number} [dx]
* @property {number} [dy]
* @property {number} [zoom]
* @property {number} [originX]
* @property {number} [originY]
*/
echarts.registerAction({
type: 'geoRoam',
event: 'geoRoam',
update: 'updateLayout'
}, function (payload, ecModel) {
var componentType = payload.componentType || 'series';
ecModel.eachComponent(
{ mainType: componentType, query: payload },
function (componentModel) {
var geo = componentModel.coordinateSystem;
if (geo.type !== 'geo') {
return;
}
import echarts from '../echarts';
import {util as zrUtil} from 'zrender';
import {updateCenterAndZoom} from './roamHelper';
/**
* @payload
* @property {string} [componentType=series]
* @property {number} [dx]
* @property {number} [dy]
* @property {number} [zoom]
* @property {number} [originX]
* @property {number} [originY]
*/
echarts.registerAction({
type: 'geoRoam',
event: 'geoRoam',
update: 'updateLayout'
}, function (payload, ecModel) {
var componentType = payload.componentType || 'series';
ecModel.eachComponent(
{ mainType: componentType, query: payload },
function (componentModel) {
var geo = componentModel.coordinateSystem;
if (geo.type !== 'geo') {
return;
}
var res = roamHelper.updateCenterAndZoom(
geo, payload, componentModel.get('scaleLimit')
);
var res = updateCenterAndZoom(
geo, payload, componentModel.get('scaleLimit')
);
componentModel.setCenter
&& componentModel.setCenter(res.center);
componentModel.setCenter
&& componentModel.setCenter(res.center);
componentModel.setZoom
&& componentModel.setZoom(res.zoom);
componentModel.setZoom
&& componentModel.setZoom(res.zoom);
// All map series with same `map` use the same geo coordinate system
// So the center and zoom must be in sync. Include the series not selected by legend
if (componentType === 'series') {
zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
seriesModel.setCenter(res.center);
seriesModel.setZoom(res.zoom);
});
}
// All map series with same `map` use the same geo coordinate system
// So the center and zoom must be in sync. Include the series not selected by legend
if (componentType === 'series') {
zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
seriesModel.setCenter(res.center);
seriesModel.setZoom(res.zoom);
});
}
);
});
}
);
});
\ No newline at end of file
define(function (require) {
var roamHelper = {};
/**
* @param {module:echarts/coord/View} view
* @param {Object} payload
* @param {Object} [zoomLimit]
*/
roamHelper.updateCenterAndZoom = function (
view, payload, zoomLimit
) {
var previousZoom = view.getZoom();
var center = view.getCenter();
var zoom = payload.zoom;
var point = view.dataToPoint(center);
if (payload.dx != null && payload.dy != null) {
point[0] -= payload.dx;
point[1] -= payload.dy;
var center = view.pointToData(point);
view.setCenter(center);
/**
* @param {module:echarts/coord/View} view
* @param {Object} payload
* @param {Object} [zoomLimit]
*/
export function updateCenterAndZoom(
view, payload, zoomLimit
) {
var previousZoom = view.getZoom();
var center = view.getCenter();
var zoom = payload.zoom;
var point = view.dataToPoint(center);
if (payload.dx != null && payload.dy != null) {
point[0] -= payload.dx;
point[1] -= payload.dy;
var center = view.pointToData(point);
view.setCenter(center);
}
if (zoom != null) {
if (zoomLimit) {
var zoomMin = zoomLimit.min || 0;
var zoomMax = zoomLimit.max || Infinity;
zoom = Math.max(
Math.min(previousZoom * zoom, zoomMax),
zoomMin
) / previousZoom;
}
if (zoom != null) {
if (zoomLimit) {
var zoomMin = zoomLimit.min || 0;
var zoomMax = zoomLimit.max || Infinity;
zoom = Math.max(
Math.min(previousZoom * zoom, zoomMax),
zoomMin
) / previousZoom;
}
// Zoom on given point(originX, originY)
view.scale[0] *= zoom;
view.scale[1] *= zoom;
var position = view.position;
var fixX = (payload.originX - position[0]) * (zoom - 1);
var fixY = (payload.originY - position[1]) * (zoom - 1);
position[0] -= fixX;
position[1] -= fixY;
view.updateTransform();
// Get the new center
var center = view.pointToData(point);
view.setCenter(center);
view.setZoom(zoom * previousZoom);
}
return {
center: view.getCenter(),
zoom: view.getZoom()
};
// Zoom on given point(originX, originY)
view.scale[0] *= zoom;
view.scale[1] *= zoom;
var position = view.position;
var fixX = (payload.originX - position[0]) * (zoom - 1);
var fixY = (payload.originY - position[1]) * (zoom - 1);
position[0] -= fixX;
position[1] -= fixY;
view.updateTransform();
// Get the new center
var center = view.pointToData(point);
view.setCenter(center);
view.setZoom(zoom * previousZoom);
}
return {
center: view.getCenter(),
zoom: view.getZoom()
};
return roamHelper;
});
\ No newline at end of file
}
define(function (require) {
import {util as zrUtil} from 'zrender';
import '../coord/cartesian/Grid';
import './bar/BarSeries';
import './bar/BarView';
var zrUtil = require('zrender/core/util');
import barLayoutGrid from '../layout/barGrid';
import echarts from '../echarts';
require('../coord/cartesian/Grid');
// In case developer forget to include grid component
import '../component/gridSimple';
require('./bar/BarSeries');
require('./bar/BarView');
var barLayoutGrid = require('../layout/barGrid');
var echarts = require('../echarts');
echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
// Visual coding for legend
echarts.registerVisual(function (ecModel) {
ecModel.eachSeriesByType('bar', function (seriesModel) {
var data = seriesModel.getData();
data.setVisual('legendSymbol', 'roundRect');
});
// Visual coding for legend
echarts.registerVisual(function (ecModel) {
ecModel.eachSeriesByType('bar', function (seriesModel) {
var data = seriesModel.getData();
data.setVisual('legendSymbol', 'roundRect');
});
// In case developer forget to include grid component
require('../component/gridSimple');
});
\ No newline at end of file
});
define(function(require) {
import BaseBarSeries from './BaseBarSeries';
return require('./BaseBarSeries').extend({
export default BaseBarSeries.extend({
type: 'series.bar',
type: 'series.bar',
dependencies: ['grid', 'polar'],
dependencies: ['grid', 'polar'],
brushSelector: 'rect'
});
});
\ No newline at end of file
brushSelector: 'rect'
});
define(function (require) {
import echarts from '../../echarts';
import {util as zrUtil} from 'zrender';
import graphic from '../../util/graphic';
import {setLabel} from './helper';
import Model from '../../model/Model';
import barItemStyle from './barItemStyle';
'use strict';
var zrUtil = require('zrender/core/util');
var graphic = require('../../util/graphic');
var helper = require('./helper');
var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'barBorderWidth'];
var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'barBorderWidth'];
// FIXME
// Just for compatible with ec2.
zrUtil.extend(Model.prototype, barItemStyle);
// FIXME
// Just for compatible with ec2.
zrUtil.extend(require('../../model/Model').prototype, require('./barItemStyle'));
export default echarts.extendChartView({
var BarView = require('../../echarts').extendChartView({
type: 'bar',
type: 'bar',
render: function (seriesModel, ecModel, api) {
var coordinateSystemType = seriesModel.get('coordinateSystem');
render: function (seriesModel, ecModel, api) {
var coordinateSystemType = seriesModel.get('coordinateSystem');
if (coordinateSystemType === 'cartesian2d'
|| coordinateSystemType === 'polar'
) {
this._render(seriesModel, ecModel, api);
}
else if (__DEV__) {
console.warn('Only cartesian2d and polar supported for bar.');
}
if (coordinateSystemType === 'cartesian2d'
|| coordinateSystemType === 'polar'
) {
this._render(seriesModel, ecModel, api);
}
else if (__DEV__) {
console.warn('Only cartesian2d and polar supported for bar.');
}
return this.group;
},
return this.group;
},
dispose: zrUtil.noop,
dispose: zrUtil.noop,
_render: function (seriesModel, ecModel, api) {
var group = this.group;
var data = seriesModel.getData();
var oldData = this._data;
_render: function (seriesModel, ecModel, api) {
var group = this.group;
var data = seriesModel.getData();
var oldData = this._data;
var coord = seriesModel.coordinateSystem;
var baseAxis = coord.getBaseAxis();
var isHorizontalOrRadial;
var coord = seriesModel.coordinateSystem;
var baseAxis = coord.getBaseAxis();
var isHorizontalOrRadial;
if (coord.type === 'cartesian2d') {
isHorizontalOrRadial = baseAxis.isHorizontal();
}
else if (coord.type === 'polar') {
isHorizontalOrRadial = baseAxis.dim === 'angle';
}
if (coord.type === 'cartesian2d') {
isHorizontalOrRadial = baseAxis.isHorizontal();
}
else if (coord.type === 'polar') {
isHorizontalOrRadial = baseAxis.dim === 'angle';
}
var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
data.diff(oldData)
.add(function (dataIndex) {
if (!data.hasValue(dataIndex)) {
return;
}
data.diff(oldData)
.add(function (dataIndex) {
if (!data.hasValue(dataIndex)) {
return;
}
var itemModel = data.getItemModel(dataIndex);
var layout = getLayout[coord.type](data, dataIndex, itemModel);
var el = elementCreator[coord.type](
data, dataIndex, itemModel, layout, isHorizontalOrRadial, animationModel
);
data.setItemGraphicEl(dataIndex, el);
group.add(el);
updateStyle(
el, data, dataIndex, itemModel, layout,
seriesModel, isHorizontalOrRadial, coord.type === 'polar'
);
})
.update(function (newIndex, oldIndex) {
var el = oldData.getItemGraphicEl(oldIndex);
if (!data.hasValue(newIndex)) {
group.remove(el);
return;
}
var itemModel = data.getItemModel(dataIndex);
var layout = getLayout[coord.type](data, dataIndex, itemModel);
var el = elementCreator[coord.type](
data, dataIndex, itemModel, layout, isHorizontalOrRadial, animationModel
);
data.setItemGraphicEl(dataIndex, el);
group.add(el);
var itemModel = data.getItemModel(newIndex);
var layout = getLayout[coord.type](data, newIndex, itemModel);
updateStyle(
el, data, dataIndex, itemModel, layout,
seriesModel, isHorizontalOrRadial, coord.type === 'polar'
if (el) {
graphic.updateProps(el, {shape: layout}, animationModel, newIndex);
}
else {
el = elementCreator[coord.type](
data, newIndex, itemModel, layout, isHorizontalOrRadial, animationModel, true
);
})
.update(function (newIndex, oldIndex) {
var el = oldData.getItemGraphicEl(oldIndex);
if (!data.hasValue(newIndex)) {
group.remove(el);
return;
}
var itemModel = data.getItemModel(newIndex);
var layout = getLayout[coord.type](data, newIndex, itemModel);
if (el) {
graphic.updateProps(el, {shape: layout}, animationModel, newIndex);
}
else {
el = elementCreator[coord.type](
data, newIndex, itemModel, layout, isHorizontalOrRadial, animationModel, true
);
}
data.setItemGraphicEl(newIndex, el);
// Add back
group.add(el);
}
updateStyle(
el, data, newIndex, itemModel, layout,
seriesModel, isHorizontalOrRadial, coord.type === 'polar'
);
})
.remove(function (dataIndex) {
var el = oldData.getItemGraphicEl(dataIndex);
if (coord.type === 'cartesian2d') {
el && removeRect(dataIndex, animationModel, el);
data.setItemGraphicEl(newIndex, el);
// Add back
group.add(el);
updateStyle(
el, data, newIndex, itemModel, layout,
seriesModel, isHorizontalOrRadial, coord.type === 'polar'
);
})
.remove(function (dataIndex) {
var el = oldData.getItemGraphicEl(dataIndex);
if (coord.type === 'cartesian2d') {
el && removeRect(dataIndex, animationModel, el);
}
else {
el && removeSector(dataIndex, animationModel, el);
}
})
.execute();
this._data = data;
},
remove: function (ecModel, api) {
var group = this.group;
var data = this._data;
if (ecModel.get('animation')) {
if (data) {
data.eachItemGraphicEl(function (el) {
if (el.type === 'sector') {
removeSector(el.dataIndex, ecModel, el);
}
else {
el && removeSector(dataIndex, animationModel, el);
removeRect(el.dataIndex, ecModel, el);
}
})
.execute();
this._data = data;
},
remove: function (ecModel, api) {
var group = this.group;
var data = this._data;
if (ecModel.get('animation')) {
if (data) {
data.eachItemGraphicEl(function (el) {
if (el.type === 'sector') {
removeSector(el.dataIndex, ecModel, el);
}
else {
removeRect(el.dataIndex, ecModel, el);
}
});
}
}
else {
group.removeAll();
});
}
}
});
else {
group.removeAll();
}
}
});
var elementCreator = {
var elementCreator = {
cartesian2d: function (
data, dataIndex, itemModel, layout, isHorizontal,
animationModel, isUpdate
) {
var rect = new graphic.Rect({shape: zrUtil.extend({}, layout)});
// Animation
if (animationModel) {
var rectShape = rect.shape;
var animateProperty = isHorizontal ? 'height' : 'width';
var animateTarget = {};
rectShape[animateProperty] = 0;
animateTarget[animateProperty] = layout[animateProperty];
graphic[isUpdate ? 'updateProps' : 'initProps'](rect, {
shape: animateTarget
}, animationModel, dataIndex);
}
cartesian2d: function (
data, dataIndex, itemModel, layout, isHorizontal,
animationModel, isUpdate
) {
var rect = new graphic.Rect({shape: zrUtil.extend({}, layout)});
// Animation
if (animationModel) {
var rectShape = rect.shape;
var animateProperty = isHorizontal ? 'height' : 'width';
var animateTarget = {};
rectShape[animateProperty] = 0;
animateTarget[animateProperty] = layout[animateProperty];
graphic[isUpdate ? 'updateProps' : 'initProps'](rect, {
shape: animateTarget
}, animationModel, dataIndex);
}
return rect;
},
return rect;
},
polar: function (
data, dataIndex, itemModel, layout, isRadial,
animationModel, isUpdate
) {
var sector = new graphic.Sector({shape: zrUtil.extend({}, layout)});
// Animation
if (animationModel) {
var sectorShape = sector.shape;
var animateProperty = isRadial ? 'r' : 'endAngle';
var animateTarget = {};
sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
animateTarget[animateProperty] = layout[animateProperty];
graphic[isUpdate ? 'updateProps' : 'initProps'](sector, {
shape: animateTarget
}, animationModel, dataIndex);
}
polar: function (
data, dataIndex, itemModel, layout, isRadial,
animationModel, isUpdate
) {
var sector = new graphic.Sector({shape: zrUtil.extend({}, layout)});
// Animation
if (animationModel) {
var sectorShape = sector.shape;
var animateProperty = isRadial ? 'r' : 'endAngle';
var animateTarget = {};
sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
animateTarget[animateProperty] = layout[animateProperty];
graphic[isUpdate ? 'updateProps' : 'initProps'](sector, {
shape: animateTarget
}, animationModel, dataIndex);
}
return sector;
return sector;
}
};
function removeRect(dataIndex, animationModel, el) {
// Not show text when animating
el.style.text = null;
graphic.updateProps(el, {
shape: {
width: 0
}
};
function removeRect(dataIndex, animationModel, el) {
// Not show text when animating
el.style.text = null;
graphic.updateProps(el, {
shape: {
width: 0
}
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
});
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
});
}
function removeSector(dataIndex, animationModel, el) {
// Not show text when animating
el.style.text = null;
graphic.updateProps(el, {
shape: {
r: el.shape.r0
}
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
});
}
var getLayout = {
cartesian2d: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
var fixedLineWidth = getLineWidth(itemModel, layout);
// fix layout with lineWidth
var signX = layout.width > 0 ? 1 : -1;
var signY = layout.height > 0 ? 1 : -1;
return {
x: layout.x + signX * fixedLineWidth / 2,
y: layout.y + signY * fixedLineWidth / 2,
width: layout.width - signX * fixedLineWidth,
height: layout.height - signY * fixedLineWidth
};
},
polar: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
return {
cx: layout.cx,
cy: layout.cy,
r0: layout.r0,
r: layout.r,
startAngle: layout.startAngle,
endAngle: layout.endAngle
};
}
function removeSector(dataIndex, animationModel, el) {
// Not show text when animating
el.style.text = null;
graphic.updateProps(el, {
shape: {
r: el.shape.r0
}
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
});
};
function updateStyle(
el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
) {
var color = data.getItemVisual(dataIndex, 'color');
var opacity = data.getItemVisual(dataIndex, 'opacity');
var itemStyleModel = itemModel.getModel('itemStyle.normal');
var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
if (!isPolar) {
el.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
}
var getLayout = {
cartesian2d: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
var fixedLineWidth = getLineWidth(itemModel, layout);
// fix layout with lineWidth
var signX = layout.width > 0 ? 1 : -1;
var signY = layout.height > 0 ? 1 : -1;
return {
x: layout.x + signX * fixedLineWidth / 2,
y: layout.y + signY * fixedLineWidth / 2,
width: layout.width - signX * fixedLineWidth,
height: layout.height - signY * fixedLineWidth
};
el.useStyle(zrUtil.defaults(
{
fill: color,
opacity: opacity
},
itemStyleModel.getBarItemStyle()
));
polar: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
return {
cx: layout.cx,
cy: layout.cy,
r0: layout.r0,
r: layout.r,
startAngle: layout.startAngle,
endAngle: layout.endAngle
};
}
};
function updateStyle(
el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
) {
var color = data.getItemVisual(dataIndex, 'color');
var opacity = data.getItemVisual(dataIndex, 'opacity');
var itemStyleModel = itemModel.getModel('itemStyle.normal');
var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
var cursorStyle = itemModel.getShallow('cursor');
cursorStyle && el.attr('cursor', cursorStyle);
if (!isPolar) {
el.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
}
var labelPositionOutside = isHorizontal
? (layout.height > 0 ? 'bottom' : 'top')
: (layout.width > 0 ? 'left' : 'right');
el.useStyle(zrUtil.defaults(
{
fill: color,
opacity: opacity
},
itemStyleModel.getBarItemStyle()
));
var cursorStyle = itemModel.getShallow('cursor');
cursorStyle && el.attr('cursor', cursorStyle);
var labelPositionOutside = isHorizontal
? (layout.height > 0 ? 'bottom' : 'top')
: (layout.width > 0 ? 'left' : 'right');
if (!isPolar) {
helper.setLabel(
el.style, hoverStyle, itemModel, color,
seriesModel, dataIndex, labelPositionOutside
);
}
graphic.setHoverStyle(el, hoverStyle);
if (!isPolar) {
setLabel(
el.style, hoverStyle, itemModel, color,
seriesModel, dataIndex, labelPositionOutside
);
}
// In case width or height are too small.
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
graphic.setHoverStyle(el, hoverStyle);
}
return BarView;
});
\ No newline at end of file
// In case width or height are too small.
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
define(function(require) {
'use strict';
var SeriesModel = require('../../model/Series');
var createListFromArray = require('../helper/createListFromArray');
return SeriesModel.extend({
type: 'series.__base_bar__',
getInitialData: function (option, ecModel) {
return createListFromArray(option.data, this, ecModel);
},
getMarkerPosition: function (value) {
var coordSys = this.coordinateSystem;
if (coordSys) {
// PENDING if clamp ?
var pt = coordSys.dataToPoint(value, true);
var data = this.getData();
var offset = data.getLayout('offset');
var size = data.getLayout('size');
var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
pt[offsetIndex] += offset + size / 2;
return pt;
}
return [NaN, NaN];
},
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
// stack: null
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// 最小高度改为0
barMinHeight: 0,
// 最小角度为0,仅对极坐标系下的柱状图有效
barMinAngle: 0,
// cursor: null,
// barMaxWidth: null,
// 默认自适应
// barWidth: null,
// 柱间距离,默认为柱形宽度的30%,可设固定值
// barGap: '30%',
// 类目间柱形距离,默认为类目间距的20%,可设固定值
// barCategoryGap: '20%',
// label: {
// normal: {
// show: false
// }
import SeriesModel from '../../model/Series';
import createListFromArray from '../helper/createListFromArray';
export default SeriesModel.extend({
type: 'series.__base_bar__',
getInitialData: function (option, ecModel) {
return createListFromArray(option.data, this, ecModel);
},
getMarkerPosition: function (value) {
var coordSys = this.coordinateSystem;
if (coordSys) {
// PENDING if clamp ?
var pt = coordSys.dataToPoint(value, true);
var data = this.getData();
var offset = data.getLayout('offset');
var size = data.getLayout('size');
var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
pt[offsetIndex] += offset + size / 2;
return pt;
}
return [NaN, NaN];
},
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
// stack: null
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// 最小高度改为0
barMinHeight: 0,
// 最小角度为0,仅对极坐标系下的柱状图有效
barMinAngle: 0,
// cursor: null,
// barMaxWidth: null,
// 默认自适应
// barWidth: null,
// 柱间距离,默认为柱形宽度的30%,可设固定值
// barGap: '30%',
// 类目间柱形距离,默认为类目间距的20%,可设固定值
// barCategoryGap: '20%',
// label: {
// normal: {
// show: false
// }
// },
itemStyle: {
// normal: {
// color: '各异'
// },
itemStyle: {
// normal: {
// color: '各异'
// },
// emphasis: {}
}
// emphasis: {}
}
});
}
});
\ No newline at end of file
define(function(require) {
import BaseBarSeries from './BaseBarSeries';
var PictorialBarSeries = require('./BaseBarSeries').extend({
var PictorialBarSeries = BaseBarSeries.extend({
type: 'series.pictorialBar',
type: 'series.pictorialBar',
dependencies: ['grid'],
dependencies: ['grid'],
defaultOption: {
symbol: 'circle', // Customized bar shape
symbolSize: null, // Can be ['100%', '100%'], null means auto.
symbolRotate: null,
defaultOption: {
symbol: 'circle', // Customized bar shape
symbolSize: null, // Can be ['100%', '100%'], null means auto.
symbolRotate: null,
symbolPosition: null, // 'start' or 'end' or 'center', null means auto.
symbolOffset: null,
symbolMargin: null, // start margin and end margin. Can be a number or a percent string.
// Auto margin by defualt.
symbolRepeat: false, // false/null/undefined, means no repeat.
// Can be true, means auto calculate repeat times and cut by data.
// Can be a number, specifies repeat times, and do not cut by data.
// Can be 'fixed', means auto calculate repeat times but do not cut by data.
symbolRepeatDirection: 'end', // 'end' means from 'start' to 'end'.
symbolPosition: null, // 'start' or 'end' or 'center', null means auto.
symbolOffset: null,
symbolMargin: null, // start margin and end margin. Can be a number or a percent string.
// Auto margin by defualt.
symbolRepeat: false, // false/null/undefined, means no repeat.
// Can be true, means auto calculate repeat times and cut by data.
// Can be a number, specifies repeat times, and do not cut by data.
// Can be 'fixed', means auto calculate repeat times but do not cut by data.
symbolRepeatDirection: 'end', // 'end' means from 'start' to 'end'.
symbolClip: false,
symbolBoundingData: null, // Can be 60 or -40 or [-40, 60]
symbolPatternSize: 400, // 400 * 400 px
symbolClip: false,
symbolBoundingData: null, // Can be 60 or -40 or [-40, 60]
symbolPatternSize: 400, // 400 * 400 px
barGap: '-100%', // In most case, overlap is needed.
barGap: '-100%', // In most case, overlap is needed.
// z can be set in data item, which is z2 actually.
// z can be set in data item, which is z2 actually.
// Disable progressive
progressive: 0,
hoverAnimation: false // Open only when needed.
},
// Disable progressive
progressive: 0,
hoverAnimation: false // Open only when needed.
},
getInitialData: function (option) {
// Disable stack.
option.stack = null;
return PictorialBarSeries.superApply(this, 'getInitialData', arguments);
}
});
getInitialData: function (option) {
// Disable stack.
option.stack = null;
return PictorialBarSeries.superApply(this, 'getInitialData', arguments);
}
});
return PictorialBarSeries;
});
\ No newline at end of file
export default PictorialBarSeries;
\ No newline at end of file
此差异已折叠。
define(function (require) {
import makeStyleMapper from '../../model/mixin/makeStyleMapper';
var getBarItemStyle = makeStyleMapper(
[
['fill', 'color'],
['stroke', 'borderColor'],
['lineWidth', 'borderWidth'],
// Compatitable with 2
['stroke', 'barBorderColor'],
['lineWidth', 'barBorderWidth'],
['opacity'],
['shadowBlur'],
['shadowOffsetX'],
['shadowOffsetY'],
['shadowColor']
]
);
export function getBarItemStyle(excludes) {
var style = getBarItemStyle(this, excludes);
if (this.getBorderLineDash) {
var lineDash = this.getBorderLineDash();
lineDash && (style.lineDash = lineDash);
}
return style;
}
var getBarItemStyle = require('../../model/mixin/makeStyleMapper')(
[
['fill', 'color'],
['stroke', 'borderColor'],
['lineWidth', 'borderWidth'],
// Compatitable with 2
['stroke', 'barBorderColor'],
['lineWidth', 'barBorderWidth'],
['opacity'],
['shadowBlur'],
['shadowOffsetX'],
['shadowOffsetY'],
['shadowColor']
]
);
return {
getBarItemStyle: function (excludes) {
var style = getBarItemStyle(this, excludes);
if (this.getBorderLineDash) {
var lineDash = this.getBorderLineDash();
lineDash && (style.lineDash = lineDash);
}
return style;
}
};
});
\ No newline at end of file
define(function (require) {
import graphic from '../../util/graphic';
var graphic = require('../../util/graphic');
export function setLabel(
normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside
) {
var labelModel = itemModel.getModel('label.normal');
var hoverLabelModel = itemModel.getModel('label.emphasis');
var helper = {};
helper.setLabel = function (
normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside
) {
var labelModel = itemModel.getModel('label.normal');
var hoverLabelModel = itemModel.getModel('label.emphasis');
graphic.setLabelStyle(
normalStyle, hoverStyle, labelModel, hoverLabelModel,
{
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: seriesModel.getRawValue(dataIndex),
isRectText: true,
autoColor: color
}
);
graphic.setLabelStyle(
normalStyle, hoverStyle, labelModel, hoverLabelModel,
{
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: seriesModel.getRawValue(dataIndex),
isRectText: true,
autoColor: color
}
);
fixPosition(normalStyle);
fixPosition(hoverStyle);
};
fixPosition(normalStyle);
fixPosition(hoverStyle);
}
function fixPosition(style, labelPositionOutside) {
if (style.textPosition === 'outside') {
style.textPosition = labelPositionOutside;
}
function fixPosition(style, labelPositionOutside) {
if (style.textPosition === 'outside') {
style.textPosition = labelPositionOutside;
}
return helper;
});
\ No newline at end of file
}
\ No newline at end of file
define(function (require) {
var echarts = require('../echarts');
import echarts from '../echarts';
import './boxplot/BoxplotSeries';
import './boxplot/BoxplotView';
import boxplotVisual from './boxplot/boxplotVisual';
import boxplotLayout from './boxplot/boxplotLayout';
require('./boxplot/BoxplotSeries');
require('./boxplot/BoxplotView');
echarts.registerVisual(require('./boxplot/boxplotVisual'));
echarts.registerLayout(require('./boxplot/boxplotLayout'));
});
\ No newline at end of file
echarts.registerVisual(boxplotVisual);
echarts.registerLayout(boxplotLayout);
define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var SeriesModel = require('../../model/Series');
var whiskerBoxCommon = require('../helper/whiskerBoxCommon');
var BoxplotSeries = SeriesModel.extend({
type: 'series.boxplot',
dependencies: ['xAxis', 'yAxis', 'grid'],
// TODO
// box width represents group size, so dimension should have 'size'.
/**
* @see <https://en.wikipedia.org/wiki/Box_plot>
* The meanings of 'min' and 'max' depend on user,
* and echarts do not need to know it.
* @readOnly
*/
defaultValueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
/**
* @type {Array.<string>}
* @readOnly
*/
dimensions: null,
/**
* @override
*/
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
hoverAnimation: true,
// xAxisIndex: 0,
// yAxisIndex: 0,
layout: null, // 'horizontal' or 'vertical'
boxWidth: [7, 50], // [min, max] can be percent of band width.
itemStyle: {
normal: {
color: '#fff',
borderWidth: 1
},
emphasis: {
borderWidth: 2,
shadowBlur: 5,
shadowOffsetX: 2,
shadowOffsetY: 2,
shadowColor: 'rgba(0,0,0,0.4)'
}
import {util as zrUtil} from 'zrender';
import SeriesModel from '../../model/Series';
import {seriesModelMixin} from '../helper/whiskerBoxCommon';
var BoxplotSeries = SeriesModel.extend({
type: 'series.boxplot',
dependencies: ['xAxis', 'yAxis', 'grid'],
// TODO
// box width represents group size, so dimension should have 'size'.
/**
* @see <https://en.wikipedia.org/wiki/Box_plot>
* The meanings of 'min' and 'max' depend on user,
* and echarts do not need to know it.
* @readOnly
*/
defaultValueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
/**
* @type {Array.<string>}
* @readOnly
*/
dimensions: null,
/**
* @override
*/
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
hoverAnimation: true,
// xAxisIndex: 0,
// yAxisIndex: 0,
layout: null, // 'horizontal' or 'vertical'
boxWidth: [7, 50], // [min, max] can be percent of band width.
itemStyle: {
normal: {
color: '#fff',
borderWidth: 1
},
animationEasing: 'elasticOut',
animationDuration: 800
}
});
zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
return BoxplotSeries;
});
\ No newline at end of file
emphasis: {
borderWidth: 2,
shadowBlur: 5,
shadowOffsetX: 2,
shadowOffsetY: 2,
shadowColor: 'rgba(0,0,0,0.4)'
}
},
animationEasing: 'elasticOut',
animationDuration: 800
}
});
zrUtil.mixin(BoxplotSeries, seriesModelMixin, true);
export default BoxplotSeries;
define(function(require) {
import {util as zrUtil} from 'zrender';
import ChartView from '../../view/Chart';
import graphic from '../../util/graphic';
import {viewMixin} from '../helper/whiskerBoxCommon';
'use strict';
var BoxplotView = ChartView.extend({
var zrUtil = require('zrender/core/util');
var ChartView = require('../../view/Chart');
var graphic = require('../../util/graphic');
var whiskerBoxCommon = require('../helper/whiskerBoxCommon');
type: 'boxplot',
var BoxplotView = ChartView.extend({
getStyleUpdater: function () {
return updateStyle;
},
type: 'boxplot',
dispose: zrUtil.noop
});
getStyleUpdater: function () {
return updateStyle;
},
zrUtil.mixin(BoxplotView, viewMixin, true);
dispose: zrUtil.noop
});
// Update common properties
var normalStyleAccessPath = ['itemStyle', 'normal'];
var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
function updateStyle(itemGroup, data, idx) {
var itemModel = data.getItemModel(idx);
var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
var borderColor = data.getItemVisual(idx, 'color');
// Update common properties
var normalStyleAccessPath = ['itemStyle', 'normal'];
var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
// Exclude borderColor.
var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
function updateStyle(itemGroup, data, idx) {
var itemModel = data.getItemModel(idx);
var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
var borderColor = data.getItemVisual(idx, 'color');
var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
whiskerEl.style.set(itemStyle);
whiskerEl.style.stroke = borderColor;
whiskerEl.dirty();
// Exclude borderColor.
var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
bodyEl.style.set(itemStyle);
bodyEl.style.stroke = borderColor;
bodyEl.dirty();
var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
whiskerEl.style.set(itemStyle);
whiskerEl.style.stroke = borderColor;
whiskerEl.dirty();
var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
graphic.setHoverStyle(itemGroup, hoverStyle);
}
var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
bodyEl.style.set(itemStyle);
bodyEl.style.stroke = borderColor;
bodyEl.dirty();
var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
graphic.setHoverStyle(itemGroup, hoverStyle);
}
return BoxplotView;
});
\ No newline at end of file
export default BoxplotView;
define(function (require) {
import {util as zrUtil} from 'zrender';
import {parsePercent} from '../../util/number';
var zrUtil = require('zrender/core/util');
var numberUtil = require('../../util/number');
var parsePercent = numberUtil.parsePercent;
var each = zrUtil.each;
var each = zrUtil.each;
return function (ecModel) {
export default function (ecModel) {
var groupResult = groupSeriesByAxis(ecModel);
var groupResult = groupSeriesByAxis(ecModel);
each(groupResult, function (groupItem) {
var seriesModels = groupItem.seriesModels;
each(groupResult, function (groupItem) {
var seriesModels = groupItem.seriesModels;
if (!seriesModels.length) {
return;
}
if (!seriesModels.length) {
return;
}
calculateBase(groupItem);
calculateBase(groupItem);
each(seriesModels, function (seriesModel, idx) {
layoutSingleSeries(
seriesModel,
groupItem.boxOffsetList[idx],
groupItem.boxWidthList[idx]
);
});
});
};
/**
* Group series by axis.
*/
function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
each(seriesModels, function (seriesModel, idx) {
layoutSingleSeries(
seriesModel,
groupItem.boxOffsetList[idx],
groupItem.boxWidthList[idx]
);
});
});
}
/**
* Group series by axis.
*/
function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
return result;
}
result[idx].seriesModels.push(seriesModel);
});
/**
* Calculate offset and box width for each series.
*/
function calculateBase(groupItem) {
var extent;
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
return result;
}
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
/**
* Calculate offset and box width for each series.
*/
function calculateBase(groupItem) {
var extent;
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else {
var maxDataCount = 0;
each(seriesModels, function (seriesModel) {
maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
});
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / maxDataCount;
}
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else {
var maxDataCount = 0;
each(seriesModels, function (seriesModel) {
var boxWidthBound = seriesModel.get('boxWidth');
if (!zrUtil.isArray(boxWidthBound)) {
boxWidthBound = [boxWidthBound, boxWidthBound];
}
boundList.push([
parsePercent(boxWidthBound[0], bandWidth) || 0,
parsePercent(boxWidthBound[1], bandWidth) || 0
]);
maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
});
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / maxDataCount;
}
var availableWidth = bandWidth * 0.8 - 2;
var boxGap = availableWidth / seriesCount * 0.3;
var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
var base = boxWidth / 2 - availableWidth / 2;
each(seriesModels, function (seriesModel, idx) {
boxOffsetList.push(base);
base += boxGap + boxWidth;
each(seriesModels, function (seriesModel) {
var boxWidthBound = seriesModel.get('boxWidth');
if (!zrUtil.isArray(boxWidthBound)) {
boxWidthBound = [boxWidthBound, boxWidthBound];
}
boundList.push([
parsePercent(boxWidthBound[0], bandWidth) || 0,
parsePercent(boxWidthBound[1], bandWidth) || 0
]);
});
var availableWidth = bandWidth * 0.8 - 2;
var boxGap = availableWidth / seriesCount * 0.3;
var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
var base = boxWidth / 2 - availableWidth / 2;
each(seriesModels, function (seriesModel, idx) {
boxOffsetList.push(base);
base += boxGap + boxWidth;
boxWidthList.push(
Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
);
});
}
/**
* Calculate points location for each series.
*/
function layoutSingleSeries(seriesModel, offset, boxWidth) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var halfWidth = boxWidth / 2;
var chartLayout = seriesModel.get('layout');
var variableDim = chartLayout === 'horizontal' ? 0 : 1;
var constDim = 1 - variableDim;
var coordDims = ['x', 'y'];
var vDims = [];
var cDim;
zrUtil.each(data.dimensions, function (dimName) {
var dimInfo = data.getDimensionInfo(dimName);
var coordDim = dimInfo.coordDim;
if (coordDim === coordDims[constDim]) {
vDims.push(dimName);
}
else if (coordDim === coordDims[variableDim]) {
cDim = dimName;
}
});
boxWidthList.push(
Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
);
});
if (cDim == null || vDims.length < 5) {
return;
}
/**
* Calculate points location for each series.
*/
function layoutSingleSeries(seriesModel, offset, boxWidth) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var halfWidth = boxWidth / 2;
var chartLayout = seriesModel.get('layout');
var variableDim = chartLayout === 'horizontal' ? 0 : 1;
var constDim = 1 - variableDim;
var coordDims = ['x', 'y'];
var vDims = [];
var cDim;
zrUtil.each(data.dimensions, function (dimName) {
var dimInfo = data.getDimensionInfo(dimName);
var coordDim = dimInfo.coordDim;
if (coordDim === coordDims[constDim]) {
vDims.push(dimName);
}
else if (coordDim === coordDims[variableDim]) {
cDim = dimName;
}
data.each([cDim].concat(vDims), function () {
var args = arguments;
var axisDimVal = args[0];
var idx = args[vDims.length + 1];
var median = getPoint(args[3]);
var end1 = getPoint(args[1]);
var end5 = getPoint(args[5]);
var whiskerEnds = [
[end1, getPoint(args[2])],
[end5, getPoint(args[4])]
];
layEndLine(end1);
layEndLine(end5);
layEndLine(median);
var bodyEnds = [];
addBodyEnd(whiskerEnds[0][1], 0);
addBodyEnd(whiskerEnds[1][1], 1);
data.setItemLayout(idx, {
chartLayout: chartLayout,
initBaseline: median[constDim],
median: median,
bodyEnds: bodyEnds,
whiskerEnds: whiskerEnds
});
if (cDim == null || vDims.length < 5) {
return;
}
data.each([cDim].concat(vDims), function () {
var args = arguments;
var axisDimVal = args[0];
var idx = args[vDims.length + 1];
var median = getPoint(args[3]);
var end1 = getPoint(args[1]);
var end5 = getPoint(args[5]);
var whiskerEnds = [
[end1, getPoint(args[2])],
[end5, getPoint(args[4])]
];
layEndLine(end1);
layEndLine(end5);
layEndLine(median);
var bodyEnds = [];
addBodyEnd(whiskerEnds[0][1], 0);
addBodyEnd(whiskerEnds[1][1], 1);
data.setItemLayout(idx, {
chartLayout: chartLayout,
initBaseline: median[constDim],
median: median,
bodyEnds: bodyEnds,
whiskerEnds: whiskerEnds
});
function getPoint(val) {
var p = [];
p[variableDim] = axisDimVal;
p[constDim] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
}
else {
point = coordSys.dataToPoint(p);
point[variableDim] += offset;
}
return point;
function getPoint(val) {
var p = [];
p[variableDim] = axisDimVal;
p[constDim] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
}
function addBodyEnd(point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[variableDim] += halfWidth;
point2[variableDim] -= halfWidth;
start
? bodyEnds.push(point1, point2)
: bodyEnds.push(point2, point1);
else {
point = coordSys.dataToPoint(p);
point[variableDim] += offset;
}
return point;
}
function layEndLine(endCenter) {
var line = [endCenter.slice(), endCenter.slice()];
line[0][variableDim] -= halfWidth;
line[1][variableDim] += halfWidth;
whiskerEnds.push(line);
}
});
}
function addBodyEnd(point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[variableDim] += halfWidth;
point2[variableDim] -= halfWidth;
start
? bodyEnds.push(point1, point2)
: bodyEnds.push(point2, point1);
}
});
\ No newline at end of file
function layEndLine(endCenter) {
var line = [endCenter.slice(), endCenter.slice()];
line[0][variableDim] -= halfWidth;
line[1][variableDim] += halfWidth;
whiskerEnds.push(line);
}
});
}
define(function (require) {
var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
return function (ecModel, api) {
export default function (ecModel, api) {
var globalColors = ecModel.get('color');
var globalColors = ecModel.get('color');
ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
var data = seriesModel.getData();
var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
var data = seriesModel.getData();
data.setVisual({
legendSymbol: 'roundRect',
// Use name 'color' but not 'borderColor' for legend usage and
// visual coding from other component like dataRange.
color: seriesModel.get(borderColorQuery) || defaulColor
});
// Only visible series has each data be visual encoded
if (!ecModel.isSeriesFiltered(seriesModel)) {
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
data.setItemVisual(
idx,
{color: itemModel.get(borderColorQuery, true)}
);
});
}
data.setVisual({
legendSymbol: 'roundRect',
// Use name 'color' but not 'borderColor' for legend usage and
// visual coding from other component like dataRange.
color: seriesModel.get(borderColorQuery) || defaulColor
});
};
});
\ No newline at end of file
// Only visible series has each data be visual encoded
if (!ecModel.isSeriesFiltered(seriesModel)) {
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
data.setItemVisual(
idx,
{color: itemModel.get(borderColorQuery, true)}
);
});
}
});
}
\ No newline at end of file
define(function (require) {
import echarts from '../echarts';
var echarts = require('../echarts');
import './candlestick/CandlestickSeries';
import './candlestick/CandlestickView';
import './candlestick/CandlestickView';
import preprocessor from './candlestick/preprocessor';
require('./candlestick/CandlestickSeries');
require('./candlestick/CandlestickView');
import candlestickVisual from './candlestick/candlestickVisual';
import candlestickLayout from './candlestick/candlestickLayout';
echarts.registerPreprocessor(
require('./candlestick/preprocessor')
);
echarts.registerVisual(require('./candlestick/candlestickVisual'));
echarts.registerLayout(require('./candlestick/candlestickLayout'));
});
\ No newline at end of file
echarts.registerPreprocessor(preprocessor);
echarts.registerVisual(candlestickVisual);
echarts.registerLayout(candlestickLayout);
define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var SeriesModel = require('../../model/Series');
var whiskerBoxCommon = require('../helper/whiskerBoxCommon');
var CandlestickSeries = SeriesModel.extend({
type: 'series.candlestick',
dependencies: ['xAxis', 'yAxis', 'grid'],
/**
* @readOnly
*/
defaultValueDimensions: ['open', 'close', 'lowest', 'highest'],
/**
* @type {Array.<string>}
* @readOnly
*/
dimensions: null,
/**
* @override
*/
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
hoverAnimation: true,
// xAxisIndex: 0,
// yAxisIndex: 0,
layout: null, // 'horizontal' or 'vertical'
itemStyle: {
normal: {
color: '#c23531', // 阳线 positive
color0: '#314656', // 阴线 negative '#c23531', '#314656'
borderWidth: 1,
// FIXME
// ec2中使用的是lineStyle.color 和 lineStyle.color0
borderColor: '#c23531',
borderColor0: '#314656'
},
emphasis: {
borderWidth: 2
}
import {util as zrUtil} from 'zrender';
import SeriesModel from '../../model/Series';
import {seriesModelMixin} from '../helper/whiskerBoxCommon';
var CandlestickSeries = SeriesModel.extend({
type: 'series.candlestick',
dependencies: ['xAxis', 'yAxis', 'grid'],
/**
* @readOnly
*/
defaultValueDimensions: ['open', 'close', 'lowest', 'highest'],
/**
* @type {Array.<string>}
* @readOnly
*/
dimensions: null,
/**
* @override
*/
defaultOption: {
zlevel: 0, // 一级层叠
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
hoverAnimation: true,
// xAxisIndex: 0,
// yAxisIndex: 0,
layout: null, // 'horizontal' or 'vertical'
itemStyle: {
normal: {
color: '#c23531', // 阳线 positive
color0: '#314656', // 阴线 negative '#c23531', '#314656'
borderWidth: 1,
// FIXME
// ec2中使用的是lineStyle.color 和 lineStyle.color0
borderColor: '#c23531',
borderColor0: '#314656'
},
barMaxWidth: null,
barMinWidth: null,
barWidth: null,
animationUpdate: false,
animationEasing: 'linear',
animationDuration: 300
emphasis: {
borderWidth: 2
}
},
/**
* Get dimension for shadow in dataZoom
* @return {string} dimension name
*/
getShadowDim: function () {
return 'open';
},
barMaxWidth: null,
barMinWidth: null,
barWidth: null,
animationUpdate: false,
animationEasing: 'linear',
animationDuration: 300
},
brushSelector: function (dataIndex, data, selectors) {
var itemLayout = data.getItemLayout(dataIndex);
return selectors.rect(itemLayout.brushRect);
}
/**
* Get dimension for shadow in dataZoom
* @return {string} dimension name
*/
getShadowDim: function () {
return 'open';
},
});
brushSelector: function (dataIndex, data, selectors) {
var itemLayout = data.getItemLayout(dataIndex);
return selectors.rect(itemLayout.brushRect);
}
zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
});
return CandlestickSeries;
zrUtil.mixin(CandlestickSeries, seriesModelMixin, true);
});
\ No newline at end of file
export default CandlestickSeries;
define(function(require) {
import {util as zrUtil} from 'zrender';
import ChartView from '../../view/Chart';
import graphic from '../../util/graphic';
import {viewMixin} from '../helper/whiskerBoxCommon';
'use strict';
var CandlestickView = ChartView.extend({
var zrUtil = require('zrender/core/util');
var ChartView = require('../../view/Chart');
var graphic = require('../../util/graphic');
var whiskerBoxCommon = require('../helper/whiskerBoxCommon');
type: 'candlestick',
var CandlestickView = ChartView.extend({
getStyleUpdater: function () {
return updateStyle;
},
type: 'candlestick',
dispose: zrUtil.noop
});
getStyleUpdater: function () {
return updateStyle;
},
zrUtil.mixin(CandlestickView, viewMixin, true);
dispose: zrUtil.noop
});
// Update common properties
var normalStyleAccessPath = ['itemStyle', 'normal'];
var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
function updateStyle(itemGroup, data, idx) {
var itemModel = data.getItemModel(idx);
var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
var color = data.getItemVisual(idx, 'color');
var borderColor = data.getItemVisual(idx, 'borderColor') || color;
// Update common properties
var normalStyleAccessPath = ['itemStyle', 'normal'];
var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
// Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
var itemStyle = normalItemStyleModel.getItemStyle(
['color', 'color0', 'borderColor', 'borderColor0']
);
function updateStyle(itemGroup, data, idx) {
var itemModel = data.getItemModel(idx);
var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
var color = data.getItemVisual(idx, 'color');
var borderColor = data.getItemVisual(idx, 'borderColor') || color;
var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
whiskerEl.useStyle(itemStyle);
whiskerEl.style.stroke = borderColor;
// Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
var itemStyle = normalItemStyleModel.getItemStyle(
['color', 'color0', 'borderColor', 'borderColor0']
);
var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
bodyEl.useStyle(itemStyle);
bodyEl.style.fill = color;
bodyEl.style.stroke = borderColor;
var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
whiskerEl.useStyle(itemStyle);
whiskerEl.style.stroke = borderColor;
var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
graphic.setHoverStyle(itemGroup, hoverStyle);
}
var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
bodyEl.useStyle(itemStyle);
bodyEl.style.fill = color;
bodyEl.style.stroke = borderColor;
var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
graphic.setHoverStyle(itemGroup, hoverStyle);
}
return CandlestickView;
});
\ No newline at end of file
export default CandlestickView;
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) {
ecModel.eachSeriesByType('candlestick', function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var candleWidth = calculateCandleWidth(seriesModel, data);
var chartLayout = seriesModel.get('layout');
var variableDim = chartLayout === 'horizontal' ? 0 : 1;
var constDim = 1 - variableDim;
var coordDims = ['x', 'y'];
var vDims = [];
var cDim;
zrUtil.each(data.dimensions, function (dimName) {
var dimInfo = data.getDimensionInfo(dimName);
var coordDim = dimInfo.coordDim;
if (coordDim === coordDims[constDim]) {
vDims.push(dimName);
import {util as zrUtil} from 'zrender';
import {parsePercent} from '../../util/number';
import {subPixelOptimize} from '../../util/graphic';
var retrieve2 = zrUtil.retrieve2;
export default function (ecModel) {
ecModel.eachSeriesByType('candlestick', function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var candleWidth = calculateCandleWidth(seriesModel, data);
var chartLayout = seriesModel.get('layout');
var variableDim = chartLayout === 'horizontal' ? 0 : 1;
var constDim = 1 - variableDim;
var coordDims = ['x', 'y'];
var vDims = [];
var cDim;
zrUtil.each(data.dimensions, function (dimName) {
var dimInfo = data.getDimensionInfo(dimName);
var coordDim = dimInfo.coordDim;
if (coordDim === coordDims[constDim]) {
vDims.push(dimName);
}
else if (coordDim === coordDims[variableDim]) {
cDim = dimName;
}
});
if (cDim == null || vDims.length < 4) {
return;
}
var dataIndex = 0;
data.each([cDim].concat(vDims), function () {
var args = arguments;
var axisDimVal = args[0];
var idx = args[vDims.length + 1];
var openVal = args[1];
var closeVal = args[2];
var lowestVal = args[3];
var highestVal = args[4];
var ocLow = Math.min(openVal, closeVal);
var ocHigh = Math.max(openVal, closeVal);
var ocLowPoint = getPoint(ocLow);
var ocHighPoint = getPoint(ocHigh);
var lowestPoint = getPoint(lowestVal);
var highestPoint = getPoint(highestVal);
var whiskerEnds = [
[
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 if (coordDim === coordDims[variableDim]) {
cDim = dimName;
else {
// No record of previous, set to be positive
sign = 1;
}
}
data.setItemLayout(idx, {
chartLayout: chartLayout,
sign: sign,
initBaseline: openVal > closeVal
? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
bodyEnds: bodyEnds,
whiskerEnds: whiskerEnds,
brushRect: makeBrushRect()
});
if (cDim == null || vDims.length < 4) {
return;
++dataIndex;
function getPoint(val) {
var p = [];
p[variableDim] = axisDimVal;
p[constDim] = val;
return (isNaN(axisDimVal) || isNaN(val))
? [NaN, NaN]
: coordSys.dataToPoint(p);
}
var dataIndex = 0;
data.each([cDim].concat(vDims), function () {
var args = arguments;
var axisDimVal = args[0];
var idx = args[vDims.length + 1];
var openVal = args[1];
var closeVal = args[2];
var lowestVal = args[3];
var highestVal = args[4];
var ocLow = Math.min(openVal, closeVal);
var ocHigh = Math.max(openVal, closeVal);
var ocLowPoint = getPoint(ocLow);
var ocHighPoint = getPoint(ocHigh);
var lowestPoint = getPoint(lowestVal);
var highestPoint = getPoint(highestVal);
var whiskerEnds = [
[
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;
}
}
function addBodyEnd(point, start) {
var point1 = point.slice();
var point2 = point.slice();
data.setItemLayout(idx, {
chartLayout: chartLayout,
sign: sign,
initBaseline: openVal > closeVal
? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
bodyEnds: bodyEnds,
whiskerEnds: whiskerEnds,
brushRect: makeBrushRect()
});
++dataIndex;
function getPoint(val) {
var p = [];
p[variableDim] = axisDimVal;
p[constDim] = val;
return (isNaN(axisDimVal) || isNaN(val))
? [NaN, NaN]
: coordSys.dataToPoint(p);
}
point1[variableDim] = subPixelOptimize(
point1[variableDim] + candleWidth / 2, 1, false
);
point2[variableDim] = subPixelOptimize(
point2[variableDim] - candleWidth / 2, 1, true
);
function addBodyEnd(point, start) {
var point1 = point.slice();
var point2 = point.slice();
start
? bodyEnds.push(point1, point2)
: bodyEnds.push(point2, point1);
}
point1[variableDim] = graphic.subPixelOptimize(
point1[variableDim] + candleWidth / 2, 1, false
);
point2[variableDim] = graphic.subPixelOptimize(
point2[variableDim] - candleWidth / 2, 1, true
);
function makeBrushRect() {
var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
start
? bodyEnds.push(point1, point2)
: bodyEnds.push(point2, point1);
}
pmin[variableDim] -= candleWidth / 2;
pmax[variableDim] -= candleWidth / 2;
function makeBrushRect() {
var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
return {
x: pmin[0],
y: pmin[1],
width: constDim ? candleWidth : pmax[0] - pmin[0],
height: constDim ? pmax[1] - pmin[1] : candleWidth
};
}
pmin[variableDim] -= candleWidth / 2;
pmax[variableDim] -= candleWidth / 2;
function subPixelOptimizePoint(point) {
point[variableDim] = subPixelOptimize(point[variableDim], 1);
return point;
}
return {
x: pmin[0],
y: pmin[1],
width: constDim ? candleWidth : pmax[0] - pmin[0],
height: constDim ? pmax[1] - pmin[1] : candleWidth
};
}
}, true);
});
}
function subPixelOptimizePoint(point) {
point[variableDim] = graphic.subPixelOptimize(point[variableDim], 1);
return point;
}
function calculateCandleWidth(seriesModel, data) {
var baseAxis = seriesModel.getBaseAxis();
var extent;
}, true);
});
};
function calculateCandleWidth(seriesModel, data) {
var baseAxis = seriesModel.getBaseAxis();
var extent;
var bandWidth = baseAxis.type === 'category'
? baseAxis.getBandWidth()
: (
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / data.count()
);
var barMaxWidth = parsePercent(
retrieve(seriesModel.get('barMaxWidth'), bandWidth),
bandWidth
);
var barMinWidth = parsePercent(
retrieve(seriesModel.get('barMinWidth'), 1),
bandWidth
var bandWidth = baseAxis.type === 'category'
? baseAxis.getBandWidth()
: (
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / data.count()
);
var barWidth = seriesModel.get('barWidth');
return barWidth != null
? 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
var barMaxWidth = parsePercent(
retrieve2(seriesModel.get('barMaxWidth'), bandWidth),
bandWidth
);
var barMinWidth = parsePercent(
retrieve2(seriesModel.get('barMinWidth'), 1),
bandWidth
);
var barWidth = seriesModel.get('barWidth');
return barWidth != null
? parsePercent(barWidth, bandWidth)
// Put max outer to ensure bar visible in spite of overlap.
: Math.max(Math.min(bandWidth / 2, barMaxWidth), barMinWidth);
}
define(function (require) {
var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
var positiveColorQuery = ['itemStyle', 'normal', 'color'];
var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
var positiveColorQuery = ['itemStyle', 'normal', 'color'];
var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
return function (ecModel, api) {
export default function (ecModel, api) {
ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
var data = seriesModel.getData();
var data = seriesModel.getData();
data.setVisual({
legendSymbol: 'roundRect'
});
// Only visible series has each data be visual encoded
if (!ecModel.isSeriesFiltered(seriesModel)) {
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
var sign = data.getItemLayout(idx).sign;
data.setItemVisual(
idx,
{
color: itemModel.get(
sign > 0 ? positiveColorQuery : negativeColorQuery
),
borderColor: itemModel.get(
sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
)
}
);
});
}
data.setVisual({
legendSymbol: 'roundRect'
});
};
});
\ No newline at end of file
// Only visible series has each data be visual encoded
if (!ecModel.isSeriesFiltered(seriesModel)) {
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
var sign = data.getItemLayout(idx).sign;
data.setItemVisual(
idx,
{
color: itemModel.get(
sign > 0 ? positiveColorQuery : negativeColorQuery
),
borderColor: itemModel.get(
sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
)
}
);
});
}
});
}
\ No newline at end of file
define(function (require) {
import {util as zrUtil} from 'zrender';
var zrUtil = require('zrender/core/util');
export default function (option) {
if (!option || !zrUtil.isArray(option.series)) {
return;
}
return function (option) {
if (!option || !zrUtil.isArray(option.series)) {
return;
// Translate 'k' to 'candlestick'.
zrUtil.each(option.series, function (seriesItem) {
if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
seriesItem.type = 'candlestick';
}
// Translate 'k' to 'candlestick'.
zrUtil.each(option.series, function (seriesItem) {
if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
seriesItem.type = 'candlestick';
}
});
};
});
\ No newline at end of file
});
}
define(function (require) {
require('./chord/ChordSeries');
require('./chord/ChordView');
import './chord/ChordSeries';
import './chord/ChordView';
var echarts = require('../echarts');
var zrUtil = require('zrender/core/util');
echarts.registerLayout(require('./chord/chordCircularLayout'));
import echarts from '../echarts';
import {util as zrUtil} from 'zrender';
echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'chord'));
import chordCircularLayout from './chord/chordCircularLayout';
import dataColor from '../visual/dataColor';
import dataFilter from '../processor/dataFilter';
echarts.registerProcessor(zrUtil.curry(require('../processor/dataFilter'), 'pie'));
});
\ No newline at end of file
echarts.registerLayout(chordCircularLayout);
echarts.registerVisual(zrUtil.curry(dataColor, 'chord'));
echarts.registerProcessor(zrUtil.curry(dataFilter, 'pie'));
\ No newline at end of file
define(function (require) {
import SeriesModel from '../../model/Series';
import createGraphFromNodeEdge from '../helper/createGraphFromNodeEdge';
import createGraphFromNodeMatrix from '../helper/createGraphFromNodeMatrix';
var SeriesModel = require('../../model/Series');
var createGraphFromNodeEdge = require('../helper/createGraphFromNodeEdge');
var createGraphFromNodeMatrix = require('../helper/createGraphFromNodeMatrix');
var ChordSeries = SeriesModel.extend({
var ChordSeries = SeriesModel.extend({
type: 'series.chord',
type: 'series.chord',
getInitialData: function (option) {
var edges = option.edges || option.links;
var nodes = option.data || option.nodes;
var matrix = option.matrix;
if (nodes && edges) {
var graph = createGraphFromNodeEdge(nodes, edges, this, true);
return graph.data;
}
else if (nodes && matrix) {
var graph = createGraphFromNodeMatrix(nodes, matrix, this, true);
return graph.data;
}
},
/**
* @return {module:echarts/data/Graph}
*/
getGraph: function () {
return this.getData().graph;
},
/**
* @return {module:echarts/data/List}
*/
getEdgeData: function () {
return this.getGraph().edgeData;
getInitialData: function (option) {
var edges = option.edges || option.links;
var nodes = option.data || option.nodes;
var matrix = option.matrix;
if (nodes && edges) {
var graph = createGraphFromNodeEdge(nodes, edges, this, true);
return graph.data;
}
else if (nodes && matrix) {
var graph = createGraphFromNodeMatrix(nodes, matrix, this, true);
return graph.data;
}
},
/**
* @return {module:echarts/data/Graph}
*/
getGraph: function () {
return this.getData().graph;
},
/**
* @return {module:echarts/data/List}
*/
getEdgeData: function () {
return this.getGraph().edgeData;
},
defaultOption: {
center: ['50%', '50%'],
radius: ['65%', '75%'],
//
// layout: 'circular',
sort: 'none',
sortSub: 'none',
padding: 0.02,
startAngle: 90,
clockwise: true,
itemStyle: {
normal: {},
emphasis: {}
},
defaultOption: {
center: ['50%', '50%'],
radius: ['65%', '75%'],
//
// layout: 'circular',
sort: 'none',
sortSub: 'none',
padding: 0.02,
startAngle: 90,
clockwise: true,
itemStyle: {
normal: {},
emphasis: {}
},
chordStyle: {
normal: {},
emphasis: {}
}
chordStyle: {
normal: {},
emphasis: {}
}
});
}
});
return ChordSeries;
});
\ No newline at end of file
export default ChordSeries;
define(function (require) {
import echarts from '../../echarts';
import RibbonPath from './Ribbon';
import graphic from '../../util/graphic';
var RibbonPath = require('./Ribbon');
var graphic = require('../../util/graphic');
export default echarts.extendChartView({
return require('../../echarts').extendChartView({
type: 'chord',
type: 'chord',
init: function (option) {
init: function (option) {
},
},
render: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var graph = seriesModel.getGraph();
var edgeData = seriesModel.getEdgeData();
render: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var graph = seriesModel.getGraph();
var edgeData = seriesModel.getEdgeData();
var group = this.group;
group.removeAll();
var group = this.group;
group.removeAll();
data.each(function (idx) {
var layout = data.getItemLayout(idx);
var sector = new graphic.Sector({
shape: {
cx: layout.cx,
cy: layout.cy,
clockwise: layout.clockwise,
r0: layout.r0,
r: layout.r,
startAngle: layout.startAngle,
endAngle: layout.endAngle
}
});
sector.setStyle({
fill: data.getItemVisual(idx, 'color')
});
data.each(function (idx) {
var layout = data.getItemLayout(idx);
var sector = new graphic.Sector({
shape: {
cx: layout.cx,
cy: layout.cy,
clockwise: layout.clockwise,
r0: layout.r0,
r: layout.r,
startAngle: layout.startAngle,
endAngle: layout.endAngle
}
});
data.setItemLayout(idx);
group.add(sector);
sector.setStyle({
fill: data.getItemVisual(idx, 'color')
});
var edgeRendered = {};
edgeData.each(function (idx) {
if (edgeRendered[idx]) {
return;
data.setItemLayout(idx);
group.add(sector);
});
var edgeRendered = {};
edgeData.each(function (idx) {
if (edgeRendered[idx]) {
return;
}
var layout = edgeData.getItemLayout(idx);
var edge = graph.getEdgeByIndex(idx);
var otherEdge = graph.getEdge(edge.node2, edge.node1);
var otherEdgeLayout = otherEdge.getLayout();
edgeRendered[idx] = edgeRendered[otherEdge.dataIndex] = true;
var ribbon = new RibbonPath({
shape: {
cx: layout.cx,
cy: layout.cy,
r: layout.r,
s0: layout.startAngle,
s1: layout.endAngle,
t0: otherEdgeLayout.startAngle,
t1: otherEdgeLayout.endAngle,
clockwise: layout.clockwise
}
var layout = edgeData.getItemLayout(idx);
var edge = graph.getEdgeByIndex(idx);
var otherEdge = graph.getEdge(edge.node2, edge.node1);
var otherEdgeLayout = otherEdge.getLayout();
edgeRendered[idx] = edgeRendered[otherEdge.dataIndex] = true;
var ribbon = new RibbonPath({
shape: {
cx: layout.cx,
cy: layout.cy,
r: layout.r,
s0: layout.startAngle,
s1: layout.endAngle,
t0: otherEdgeLayout.startAngle,
t1: otherEdgeLayout.endAngle,
clockwise: layout.clockwise
}
});
ribbon.setStyle({
// Use color of source
fill: edge.node1.getVisual('color'),
opacity: 0.5
});
group.add(ribbon);
});
},
ribbon.setStyle({
// Use color of source
fill: edge.node1.getVisual('color'),
opacity: 0.5
});
group.add(ribbon);
});
},
dispose: function () {}
});
dispose: function () {}
});
\ No newline at end of file
define(function (require) {
import graphic from '../../util/graphic';
var sin = Math.sin;
var cos = Math.cos;
var sin = Math.sin;
var cos = Math.cos;
return require('../../util/graphic').extendShape({
export default graphic.extendShape({
type: 'ec-ribbon',
type: 'ec-ribbon',
shape: {
cx: 0,
cy: 0,
r: 0,
s0: 0,
s1: 0,
t0: 0,
t1: 0
},
shape: {
cx: 0,
cy: 0,
r: 0,
s0: 0,
s1: 0,
t0: 0,
t1: 0
},
style: {
fill: '#000'
},
style: {
fill: '#000'
},
buildPath: function (ctx, shape) {
buildPath: function (ctx, shape) {
var clockwise = shape.clockwise || false;
var clockwise = shape.clockwise || false;
var cx = shape.cx;
var cy = shape.cy;
var r = shape.r;
var s0 = shape.s0;
var s1 = shape.s1;
var t0 = shape.t0;
var t1 = shape.t1;
var sx0 = cx + cos(s0) * r;
var sy0 = cy + sin(s0) * r;
var sx1 = cx + cos(s1) * r;
var sy1 = cy + sin(s1) * r;
var tx0 = cx + cos(t0) * r;
var ty0 = cy + sin(t0) * r;
var tx1 = cx + cos(t1) * r;
var ty1 = cy + sin(t1) * r;
var cx = shape.cx;
var cy = shape.cy;
var r = shape.r;
var s0 = shape.s0;
var s1 = shape.s1;
var t0 = shape.t0;
var t1 = shape.t1;
var sx0 = cx + cos(s0) * r;
var sy0 = cy + sin(s0) * r;
var sx1 = cx + cos(s1) * r;
var sy1 = cy + sin(s1) * r;
var tx0 = cx + cos(t0) * r;
var ty0 = cy + sin(t0) * r;
var tx1 = cx + cos(t1) * r;
var ty1 = cy + sin(t1) * r;
ctx.moveTo(sx0, sy0);
ctx.arc(cx, cy, shape.r, s0, s1, !clockwise);
ctx.bezierCurveTo(
(cx - sx1) * 0.70 + sx1,
(cy - sy1) * 0.70 + sy1,
(cx - tx0) * 0.70 + tx0,
(cy - ty0) * 0.70 + ty0,
tx0, ty0
);
// Chord to self
if (shape.s0 === shape.t0 && shape.s1 === shape.t1) {
return;
}
ctx.arc(cx, cy, shape.r, t0, t1, !clockwise);
ctx.bezierCurveTo(
(cx - tx1) * 0.70 + tx1,
(cy - ty1) * 0.70 + ty1,
(cx - sx0) * 0.70 + sx0,
(cy - sy0) * 0.70 + sy0,
sx0, sy0
);
ctx.moveTo(sx0, sy0);
ctx.arc(cx, cy, shape.r, s0, s1, !clockwise);
ctx.bezierCurveTo(
(cx - sx1) * 0.70 + sx1,
(cy - sy1) * 0.70 + sy1,
(cx - tx0) * 0.70 + tx0,
(cy - ty0) * 0.70 + ty0,
tx0, ty0
);
// Chord to self
if (shape.s0 === shape.t0 && shape.s1 === shape.t1) {
return;
}
});
ctx.arc(cx, cy, shape.r, t0, t1, !clockwise);
ctx.bezierCurveTo(
(cx - tx1) * 0.70 + tx1,
(cy - ty1) * 0.70 + ty1,
(cx - sx0) * 0.70 + sx0,
(cy - sy0) * 0.70 + sy0,
sx0, sy0
);
}
});
\ No newline at end of file
......@@ -3,121 +3,119 @@
* @module echarts/chart/chord/chordCircularLayout
* @author pissang(http://github.com/pissang)
*/
define(function (require) {
var zrUtil = require('zrender/core/util');
var numberUtil = require('../../util/number');
/**
* @param {module:echarts/data/Graph} graph
*/
function layout(graphs, opts) {
if (!zrUtil.isArray(graphs)) {
graphs = [graphs];
}
import {util as zrUtil} from 'zrender';
import {parsePercent} from '../../util/number';
var graph0 = graphs[0];
/**
* @param {module:echarts/data/Graph} graph
*/
function layout(graphs, opts) {
if (!zrUtil.isArray(graphs)) {
graphs = [graphs];
}
var groups = [];
var graph0 = graphs[0];
// Init groups
graph0.eachNode(function (node) {
var group = {
size: 0,
subGroups: [],
node: node
};
groups.push(group);
});
var groups = [];
zrUtil.each(graphs, function (graph) {
graph.eachEdge(function (edge) {
var g1 = groups[edge.node1.dataIndex];
g1.size += edge.getValue('value') || 0;
// Init groups
graph0.eachNode(function (node) {
var group = {
size: 0,
subGroups: [],
node: node
};
groups.push(group);
});
g1.subGroups.push({
size: edge.getValue('value'),
edge: edge
});
zrUtil.each(graphs, function (graph) {
graph.eachEdge(function (edge) {
var g1 = groups[edge.node1.dataIndex];
g1.size += edge.getValue('value') || 0;
g1.subGroups.push({
size: edge.getValue('value'),
edge: edge
});
});
});
var sumSize = zrUtil.reduce(groups, function (sumSize, group) {
return sumSize + group.size;
}, 0);
var sumSize = zrUtil.reduce(groups, function (sumSize, group) {
return sumSize + group.size;
}, 0);
if (opts.sort && opts.sort != 'none') {
groups.sort(compareGroups);
if (opts.sort === 'descending') {
groups.reverse();
}
if (opts.sort && opts.sort != 'none') {
groups.sort(compareGroups);
if (opts.sort === 'descending') {
groups.reverse();
}
}
var unitAngle = (Math.PI * 2 - opts.padding * graph0.data.count()) / sumSize;
var angle = opts.startAngle * Math.PI / 180;
var sign = opts.clockwise ? -1 : 1;
zrUtil.each(groups, function (group) {
if (opts.sortSub && opts.sortSub != 'none') {
group.subGroups.sort(compareGroups);
if (opts.sortSub === 'descending') {
group.subGroups.reverse();
}
var unitAngle = (Math.PI * 2 - opts.padding * graph0.data.count()) / sumSize;
var angle = opts.startAngle * Math.PI / 180;
var sign = opts.clockwise ? -1 : 1;
zrUtil.each(groups, function (group) {
if (opts.sortSub && opts.sortSub != 'none') {
group.subGroups.sort(compareGroups);
if (opts.sortSub === 'descending') {
group.subGroups.reverse();
}
}
var endAngle = angle + sign * group.size * unitAngle;
group.node.setLayout({
startAngle: -angle,
endAngle: -endAngle,
var endAngle = angle + sign * group.size * unitAngle;
group.node.setLayout({
startAngle: -angle,
endAngle: -endAngle,
cx: opts.cx,
cy: opts.cy,
r0: opts.r0,
r: opts.r,
clockwise: opts.clockwise
});
zrUtil.each(group.subGroups, function (subGroup) {
var startAngle = angle;
var endAngle = angle + sign * subGroup.size * unitAngle;
var layout = subGroup.edge.getLayout() || {
cx: opts.cx,
cy: opts.cy,
r0: opts.r0,
r: opts.r,
r: opts.r0,
clockwise: opts.clockwise
});
zrUtil.each(group.subGroups, function (subGroup) {
var startAngle = angle;
var endAngle = angle + sign * subGroup.size * unitAngle;
var layout = subGroup.edge.getLayout() || {
cx: opts.cx,
cy: opts.cy,
r: opts.r0,
clockwise: opts.clockwise
};
layout.startAngle = -startAngle;
layout.endAngle = -endAngle;
subGroup.edge.setLayout(layout);
angle = endAngle;
});
angle = endAngle + sign * opts.padding;
};
layout.startAngle = -startAngle;
layout.endAngle = -endAngle;
subGroup.edge.setLayout(layout);
angle = endAngle;
});
}
var compareGroups = function (a, b) {
return a.size - b.size;
};
return function (ecModel, api, payload) {
ecModel.eachSeriesByType('chord', function (chordSeries) {
var graph = chordSeries.getGraph();
var center = chordSeries.get('center');
var radius = chordSeries.get('radius');
var parsePercent = numberUtil.parsePercent;
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var viewSize = Math.min(viewWidth, viewHeight) / 2;
layout(graph, {
sort: chordSeries.get('sort'),
sortSub: chordSeries.get('sortSub'),
padding: chordSeries.get('padding'),
startAngle: chordSeries.get('startAngle'),
clockwise: chordSeries.get('clockwise'),
cx: parsePercent(center[0], viewWidth),
cy: parsePercent(center[1], viewHeight),
r0: parsePercent(radius[0], viewSize),
r: parsePercent(radius[1], viewSize)
});
angle = endAngle + sign * opts.padding;
});
}
var compareGroups = function (a, b) {
return a.size - b.size;
};
export default function (ecModel, api, payload) {
ecModel.eachSeriesByType('chord', function (chordSeries) {
var graph = chordSeries.getGraph();
var center = chordSeries.get('center');
var radius = chordSeries.get('radius');
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var viewSize = Math.min(viewWidth, viewHeight) / 2;
layout(graph, {
sort: chordSeries.get('sort'),
sortSub: chordSeries.get('sortSub'),
padding: chordSeries.get('padding'),
startAngle: chordSeries.get('startAngle'),
clockwise: chordSeries.get('clockwise'),
cx: parsePercent(center[0], viewWidth),
cy: parsePercent(center[1], viewHeight),
r0: parsePercent(radius[0], viewSize),
r: parsePercent(radius[1], viewSize)
});
};
});
\ No newline at end of file
});
}
\ No newline at end of file
此差异已折叠。
define(function (require) {
import {util as zrUtil} from 'zrender';
import echarts from '../echarts';
var zrUtil = require('zrender/core/util');
var echarts = require('../echarts');
import './effectScatter/EffectScatterSeries';
import './effectScatter/EffectScatterView';
require('./effectScatter/EffectScatterSeries');
require('./effectScatter/EffectScatterView');
import visualSymbol from '../visual/symbol';
import layoutPoints from '../layout/points';
echarts.registerVisual(zrUtil.curry(
require('../visual/symbol'), 'effectScatter', 'circle', null
));
echarts.registerLayout(zrUtil.curry(
require('../layout/points'), 'effectScatter'
));
});
\ No newline at end of file
echarts.registerVisual(zrUtil.curry(
visualSymbol, 'effectScatter', 'circle', null
));
echarts.registerLayout(zrUtil.curry(
layoutPoints, 'effectScatter'
));
\ No newline at end of file
define(function (require) {
import createListFromArray from '../helper/createListFromArray';
import SeriesModel from '../../model/Series';
'use strict';
export default SeriesModel.extend({
var createListFromArray = require('../helper/createListFromArray');
var SeriesModel = require('../../model/Series');
type: 'series.effectScatter',
return SeriesModel.extend({
dependencies: ['grid', 'polar'],
type: 'series.effectScatter',
getInitialData: function (option, ecModel) {
var list = createListFromArray(option.data, this, ecModel);
return list;
},
dependencies: ['grid', 'polar'],
brushSelector: 'point',
getInitialData: function (option, ecModel) {
var list = createListFromArray(option.data, this, ecModel);
return list;
},
brushSelector: 'point',
defaultOption: {
coordinateSystem: 'cartesian2d',
zlevel: 0,
z: 2,
legendHoverLink: true,
defaultOption: {
coordinateSystem: 'cartesian2d',
zlevel: 0,
z: 2,
legendHoverLink: true,
effectType: 'ripple',
effectType: 'ripple',
progressive: 0,
progressive: 0,
// When to show the effect, option: 'render'|'emphasis'
showEffectOn: 'render',
// When to show the effect, option: 'render'|'emphasis'
showEffectOn: 'render',
// Ripple effect config
rippleEffect: {
period: 4,
// Scale of ripple
scale: 2.5,
// Brush type can be fill or stroke
brushType: 'fill'
},
// Ripple effect config
rippleEffect: {
period: 4,
// Scale of ripple
scale: 2.5,
// Brush type can be fill or stroke
brushType: 'fill'
},
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// Polar coordinate system
// polarIndex: 0,
// Polar coordinate system
// polarIndex: 0,
// Geo coordinate system
// geoIndex: 0,
// Geo coordinate system
// geoIndex: 0,
// symbol: null, // 图形类型
symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
// symbolRotate: null, // 图形旋转控制
// symbol: null, // 图形类型
symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
// symbolRotate: null, // 图形旋转控制
// large: false,
// Available when large is true
// largeThreshold: 2000,
// large: false,
// Available when large is true
// largeThreshold: 2000,
// itemStyle: {
// normal: {
// opacity: 1
// }
// }
}
// itemStyle: {
// normal: {
// opacity: 1
// }
// }
}
});
});
\ No newline at end of file
define(function (require) {
import echarts from '../../echarts';
import SymbolDraw from '../helper/SymbolDraw';
import EffectSymbol from '../helper/EffectSymbol';
var SymbolDraw = require('../helper/SymbolDraw');
var EffectSymbol = require('../helper/EffectSymbol');
echarts.extendChartView({
require('../../echarts').extendChartView({
type: 'effectScatter',
type: 'effectScatter',
init: function () {
this._symbolDraw = new SymbolDraw(EffectSymbol);
},
init: function () {
this._symbolDraw = new SymbolDraw(EffectSymbol);
},
render: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var effectSymbolDraw = this._symbolDraw;
effectSymbolDraw.updateData(data);
this.group.add(effectSymbolDraw.group);
},
render: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var effectSymbolDraw = this._symbolDraw;
effectSymbolDraw.updateData(data);
this.group.add(effectSymbolDraw.group);
},
updateLayout: function () {
this._symbolDraw.updateLayout();
},
updateLayout: function () {
this._symbolDraw.updateLayout();
},
remove: function (ecModel, api) {
this._symbolDraw && this._symbolDraw.remove(api);
},
remove: function (ecModel, api) {
this._symbolDraw && this._symbolDraw.remove(api);
},
dispose: function () {}
});
});
\ No newline at end of file
dispose: function () {}
});
define(function (require) {
import {util as zrUtil} from 'zrender';
import echarts from '../echarts';
var zrUtil = require('zrender/core/util');
var echarts = require('../echarts');
import './funnel/FunnelSeries';
import './funnel/FunnelView';
require('./funnel/FunnelSeries');
require('./funnel/FunnelView');
import dataColor from '../visual/dataColor';
import funnelLayout from './funnel/funnelLayout';
import dataFilter from '../processor/dataFilter';
echarts.registerVisual(zrUtil.curry(require('../visual/dataColor'), 'funnel'));
echarts.registerLayout(require('./funnel/funnelLayout'));
echarts.registerProcessor(zrUtil.curry(require('../processor/dataFilter'), 'funnel'));
});
\ No newline at end of file
echarts.registerVisual(zrUtil.curry(dataColor, 'funnel'));
echarts.registerLayout(funnelLayout);
echarts.registerProcessor(zrUtil.curry(dataFilter, 'funnel'));
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
define(function (require) {
require('./gauge/GaugeSeries');
require('./gauge/GaugeView');
});
\ No newline at end of file
import './gauge/GaugeSeries';
import './gauge/GaugeView';
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
define(function (require) {
});
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册