first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:44:12 +08:00
commit b9bdc8598b
42390 changed files with 4467935 additions and 0 deletions

91
node_modules/echarts/lib/chart/bar/BarSeries.js generated vendored Normal file
View File

@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var BaseBarSeries = require("./BaseBarSeries");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var _default = BaseBarSeries.extend({
type: 'series.bar',
dependencies: ['grid', 'polar'],
brushSelector: 'rect',
/**
* @override
*/
getProgressive: function () {
// Do not support progressive in normal mode.
return this.get('large') ? this.get('progressive') : false;
},
/**
* @override
*/
getProgressiveThreshold: function () {
// Do not support progressive in normal mode.
var progressiveThreshold = this.get('progressiveThreshold');
var largeThreshold = this.get('largeThreshold');
if (largeThreshold > progressiveThreshold) {
progressiveThreshold = largeThreshold;
}
return progressiveThreshold;
},
defaultOption: {
// If clipped
// Only available on cartesian2d
clip: true,
// If use caps on two sides of bars
// Only available on tangential polar bar
roundCap: false,
showBackground: false,
backgroundStyle: {
color: 'rgba(180, 180, 180, 0.2)',
borderColor: null,
borderWidth: 0,
borderType: 'solid',
borderRadius: 0,
shadowBlur: 0,
shadowColor: null,
shadowOffsetX: 0,
shadowOffsetY: 0,
opacity: 1
}
}
});
module.exports = _default;

698
node_modules/echarts/lib/chart/bar/BarView.js generated vendored Normal file
View File

@ -0,0 +1,698 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var _config = require("../../config");
var __DEV__ = _config.__DEV__;
var echarts = require("../../echarts");
var zrUtil = require("zrender/lib/core/util");
var graphic = require("../../util/graphic");
var _helper = require("./helper");
var setLabel = _helper.setLabel;
var Model = require("../../model/Model");
var barItemStyle = require("./barItemStyle");
var Path = require("zrender/lib/graphic/Path");
var Group = require("zrender/lib/container/Group");
var _throttle = require("../../util/throttle");
var throttle = _throttle.throttle;
var _createClipPathFromCoordSys = require("../helper/createClipPathFromCoordSys");
var createClipPath = _createClipPathFromCoordSys.createClipPath;
var Sausage = require("../../util/shape/sausage");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'barBorderWidth'];
var _eventPos = [0, 0]; // FIXME
// Just for compatible with ec2.
zrUtil.extend(Model.prototype, barItemStyle);
function getClipArea(coord, data) {
var coordSysClipArea = coord.getArea && coord.getArea();
if (coord.type === 'cartesian2d') {
var baseAxis = coord.getBaseAxis(); // When boundaryGap is false or using time axis. bar may exceed the grid.
// We should not clip this part.
// See test/bar2.html
if (baseAxis.type !== 'category' || !baseAxis.onBand) {
var expandWidth = data.getLayout('bandWidth');
if (baseAxis.isHorizontal()) {
coordSysClipArea.x -= expandWidth;
coordSysClipArea.width += expandWidth * 2;
} else {
coordSysClipArea.y -= expandWidth;
coordSysClipArea.height += expandWidth * 2;
}
}
}
return coordSysClipArea;
}
var _default = echarts.extendChartView({
type: 'bar',
render: function (seriesModel, ecModel, api) {
this._updateDrawMode(seriesModel);
var coordinateSystemType = seriesModel.get('coordinateSystem');
if (coordinateSystemType === 'cartesian2d' || coordinateSystemType === 'polar') {
this._isLargeDraw ? this._renderLarge(seriesModel, ecModel, api) : this._renderNormal(seriesModel, ecModel, api);
} else {}
return this.group;
},
incrementalPrepareRender: function (seriesModel, ecModel, api) {
this._clear();
this._updateDrawMode(seriesModel);
},
incrementalRender: function (params, seriesModel, ecModel, api) {
// Do not support progressive in normal mode.
this._incrementalRenderLarge(params, seriesModel);
},
_updateDrawMode: function (seriesModel) {
var isLargeDraw = seriesModel.pipelineContext.large;
if (this._isLargeDraw == null || isLargeDraw ^ this._isLargeDraw) {
this._isLargeDraw = isLargeDraw;
this._clear();
}
},
_renderNormal: 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;
if (coord.type === 'cartesian2d') {
isHorizontalOrRadial = baseAxis.isHorizontal();
} else if (coord.type === 'polar') {
isHorizontalOrRadial = baseAxis.dim === 'angle';
}
var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
var needsClip = seriesModel.get('clip', true);
var coordSysClipArea = getClipArea(coord, data); // If there is clipPath created in large mode. Remove it.
group.removeClipPath(); // We don't use clipPath in normal mode because we needs a perfect animation
// And don't want the label are clipped.
var roundCap = seriesModel.get('roundCap', true);
var drawBackground = seriesModel.get('showBackground', true);
var backgroundModel = seriesModel.getModel('backgroundStyle');
var barBorderRadius = backgroundModel.get('barBorderRadius') || 0;
var bgEls = [];
var oldBgEls = this._backgroundEls || [];
var createBackground = function (dataIndex) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle()); // Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[dataIndex] = bgEl;
return bgEl;
};
data.diff(oldData).add(function (dataIndex) {
var itemModel = data.getItemModel(dataIndex);
var layout = getLayout[coord.type](data, dataIndex, itemModel);
if (drawBackground) {
createBackground(dataIndex);
} // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
if (!data.hasValue(dataIndex)) {
return;
}
if (needsClip) {
// Clip will modify the layout params.
// And return a boolean to determine if the shape are fully clipped.
var isClipped = clip[coord.type](coordSysClipArea, layout);
if (isClipped) {
group.remove(el);
return;
}
}
var el = elementCreator[coord.type](dataIndex, layout, isHorizontalOrRadial, animationModel, false, roundCap);
data.setItemGraphicEl(dataIndex, el);
group.add(el);
updateStyle(el, data, dataIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, coord.type === 'polar');
}).update(function (newIndex, oldIndex) {
var itemModel = data.getItemModel(newIndex);
var layout = getLayout[coord.type](data, newIndex, itemModel);
if (drawBackground) {
var bgEl;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
} else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle()); // Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
}
bgEls[newIndex] = bgEl;
}
var bgLayout = getLayout[coord.type](data, newIndex);
var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
graphic.updateProps(bgEl, {
shape: shape
}, animationModel, newIndex);
}
var el = oldData.getItemGraphicEl(oldIndex);
if (!data.hasValue(newIndex)) {
group.remove(el);
return;
}
if (needsClip) {
var isClipped = clip[coord.type](coordSysClipArea, layout);
if (isClipped) {
group.remove(el);
return;
}
}
if (el) {
graphic.updateProps(el, {
shape: layout
}, animationModel, newIndex);
} else {
el = elementCreator[coord.type](newIndex, layout, isHorizontalOrRadial, animationModel, true, roundCap);
}
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();
var bgGroup = this._backgroundGroup || (this._backgroundGroup = new Group());
bgGroup.removeAll();
for (var i = 0; i < bgEls.length; ++i) {
bgGroup.add(bgEls[i]);
}
group.add(bgGroup);
this._backgroundEls = bgEls;
this._data = data;
},
_renderLarge: function (seriesModel, ecModel, api) {
this._clear();
createLarge(seriesModel, this.group); // Use clipPath in large mode.
var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
if (clipPath) {
this.group.setClipPath(clipPath);
} else {
this.group.removeClipPath();
}
},
_incrementalRenderLarge: function (params, seriesModel) {
this._removeBackground();
createLarge(seriesModel, this.group, true);
},
dispose: zrUtil.noop,
remove: function (ecModel) {
this._clear(ecModel);
},
_clear: function (ecModel) {
var group = this.group;
var data = this._data;
if (ecModel && ecModel.get('animation') && data && !this._isLargeDraw) {
this._removeBackground();
this._backgroundEls = [];
data.eachItemGraphicEl(function (el) {
if (el.type === 'sector') {
removeSector(el.dataIndex, ecModel, el);
} else {
removeRect(el.dataIndex, ecModel, el);
}
});
} else {
group.removeAll();
}
this._data = null;
},
_removeBackground: function () {
this.group.remove(this._backgroundGroup);
this._backgroundGroup = null;
}
});
var mathMax = Math.max;
var mathMin = Math.min;
var clip = {
cartesian2d: function (coordSysBoundingRect, layout) {
var signWidth = layout.width < 0 ? -1 : 1;
var signHeight = layout.height < 0 ? -1 : 1; // Needs positive width and height
if (signWidth < 0) {
layout.x += layout.width;
layout.width = -layout.width;
}
if (signHeight < 0) {
layout.y += layout.height;
layout.height = -layout.height;
}
var x = mathMax(layout.x, coordSysBoundingRect.x);
var x2 = mathMin(layout.x + layout.width, coordSysBoundingRect.x + coordSysBoundingRect.width);
var y = mathMax(layout.y, coordSysBoundingRect.y);
var y2 = mathMin(layout.y + layout.height, coordSysBoundingRect.y + coordSysBoundingRect.height);
layout.x = x;
layout.y = y;
layout.width = x2 - x;
layout.height = y2 - y;
var clipped = layout.width < 0 || layout.height < 0; // Reverse back
if (signWidth < 0) {
layout.x += layout.width;
layout.width = -layout.width;
}
if (signHeight < 0) {
layout.y += layout.height;
layout.height = -layout.height;
}
return clipped;
},
polar: function (coordSysClipArea, layout) {
var signR = layout.r0 <= layout.r ? 1 : -1; // Make sure r is larger than r0
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
var r = mathMin(layout.r, coordSysClipArea.r);
var r0 = mathMax(layout.r0, coordSysClipArea.r0);
layout.r = r;
layout.r0 = r0;
var clipped = r - r0 < 0; // Reverse back
if (signR < 0) {
var r = layout.r;
layout.r = layout.r0;
layout.r0 = r;
}
return clipped;
}
};
var elementCreator = {
cartesian2d: function (dataIndex, layout, isHorizontal, animationModel, isUpdate) {
var rect = new graphic.Rect({
shape: zrUtil.extend({}, layout),
z2: 1
});
rect.name = 'item'; // 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;
},
polar: function (dataIndex, layout, isRadial, animationModel, isUpdate, roundCap) {
// Keep the same logic with bar in catesion: use end value to control
// direction. Notice that if clockwise is true (by default), the sector
// will always draw clockwisely, no matter whether endAngle is greater
// or less than startAngle.
var clockwise = layout.startAngle < layout.endAngle;
var ShapeClass = !isRadial && roundCap ? Sausage : graphic.Sector;
var sector = new ShapeClass({
shape: zrUtil.defaults({
clockwise: clockwise
}, layout),
z2: 1
});
sector.name = 'item'; // 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;
}
};
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);
});
}
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 = {
// itemModel is only used to get borderWidth, which is not needed
// when calculating bar background layout.
cartesian2d: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
var fixedLineWidth = itemModel ? getLineWidth(itemModel, layout) : 0; // 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 isZeroOnPolar(layout) {
return layout.startAngle != null && layout.endAngle != null && layout.startAngle === 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 stroke = data.getVisual('borderColor');
var itemStyleModel = itemModel.getModel('itemStyle');
var hoverStyle = itemModel.getModel('emphasis.itemStyle').getBarItemStyle();
if (!isPolar) {
el.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
}
el.useStyle(zrUtil.defaults({
stroke: isZeroOnPolar(layout) ? 'none' : stroke,
fill: isZeroOnPolar(layout) ? 'none' : 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) {
setLabel(el.style, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside);
}
if (isZeroOnPolar(layout)) {
hoverStyle.fill = hoverStyle.stroke = 'none';
}
graphic.setHoverStyle(el, hoverStyle);
} // In case width or height are too small.
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0; // width or height may be NaN for empty data
var width = isNaN(rawLayout.width) ? Number.MAX_VALUE : Math.abs(rawLayout.width);
var height = isNaN(rawLayout.height) ? Number.MAX_VALUE : Math.abs(rawLayout.height);
return Math.min(lineWidth, width, height);
}
var LargePath = Path.extend({
type: 'largeBar',
shape: {
points: []
},
buildPath: function (ctx, shape) {
// Drawing lines is more efficient than drawing
// a whole line or drawing rects.
var points = shape.points;
var startPoint = this.__startPoint;
var baseDimIdx = this.__baseDimIdx;
for (var i = 0; i < points.length; i += 2) {
startPoint[baseDimIdx] = points[i + baseDimIdx];
ctx.moveTo(startPoint[0], startPoint[1]);
ctx.lineTo(points[i], points[i + 1]);
}
}
});
function createLarge(seriesModel, group, incremental) {
// TODO support polar
var data = seriesModel.getData();
var startPoint = [];
var baseDimIdx = data.getLayout('valueAxisHorizontal') ? 1 : 0;
startPoint[1 - baseDimIdx] = data.getLayout('valueAxisStart');
var largeDataIndices = data.getLayout('largeDataIndices');
var barWidth = data.getLayout('barWidth');
var backgroundModel = seriesModel.getModel('backgroundStyle');
var drawBackground = seriesModel.get('showBackground', true);
if (drawBackground) {
var points = data.getLayout('largeBackgroundPoints');
var backgroundStartPoint = [];
backgroundStartPoint[1 - baseDimIdx] = data.getLayout('backgroundStart');
var bgEl = new LargePath({
shape: {
points: points
},
incremental: !!incremental,
__startPoint: backgroundStartPoint,
__baseDimIdx: baseDimIdx,
__largeDataIndices: largeDataIndices,
__barWidth: barWidth,
silent: true,
z2: 0
});
setLargeBackgroundStyle(bgEl, backgroundModel, data);
group.add(bgEl);
}
var el = new LargePath({
shape: {
points: data.getLayout('largePoints')
},
incremental: !!incremental,
__startPoint: startPoint,
__baseDimIdx: baseDimIdx,
__largeDataIndices: largeDataIndices,
__barWidth: barWidth
});
group.add(el);
setLargeStyle(el, seriesModel, data); // Enable tooltip and user mouse/touch event handlers.
el.seriesIndex = seriesModel.seriesIndex;
if (!seriesModel.get('silent')) {
el.on('mousedown', largePathUpdateDataIndex);
el.on('mousemove', largePathUpdateDataIndex);
}
} // Use throttle to avoid frequently traverse to find dataIndex.
var largePathUpdateDataIndex = throttle(function (event) {
var largePath = this;
var dataIndex = largePathFindDataIndex(largePath, event.offsetX, event.offsetY);
largePath.dataIndex = dataIndex >= 0 ? dataIndex : null;
}, 30, false);
function largePathFindDataIndex(largePath, x, y) {
var baseDimIdx = largePath.__baseDimIdx;
var valueDimIdx = 1 - baseDimIdx;
var points = largePath.shape.points;
var largeDataIndices = largePath.__largeDataIndices;
var barWidthHalf = Math.abs(largePath.__barWidth / 2);
var startValueVal = largePath.__startPoint[valueDimIdx];
_eventPos[0] = x;
_eventPos[1] = y;
var pointerBaseVal = _eventPos[baseDimIdx];
var pointerValueVal = _eventPos[1 - baseDimIdx];
var baseLowerBound = pointerBaseVal - barWidthHalf;
var baseUpperBound = pointerBaseVal + barWidthHalf;
for (var i = 0, len = points.length / 2; i < len; i++) {
var ii = i * 2;
var barBaseVal = points[ii + baseDimIdx];
var barValueVal = points[ii + valueDimIdx];
if (barBaseVal >= baseLowerBound && barBaseVal <= baseUpperBound && (startValueVal <= barValueVal ? pointerValueVal >= startValueVal && pointerValueVal <= barValueVal : pointerValueVal >= barValueVal && pointerValueVal <= startValueVal)) {
return largeDataIndices[i];
}
}
return -1;
}
function setLargeStyle(el, seriesModel, data) {
var borderColor = data.getVisual('borderColor') || data.getVisual('color');
var itemStyle = seriesModel.getModel('itemStyle').getItemStyle(['color', 'borderColor']);
el.useStyle(itemStyle);
el.style.fill = null;
el.style.stroke = borderColor;
el.style.lineWidth = data.getLayout('barWidth');
}
function setLargeBackgroundStyle(el, backgroundModel, data) {
var borderColor = backgroundModel.get('borderColor') || backgroundModel.get('color');
var itemStyle = backgroundModel.getItemStyle(['color', 'borderColor']);
el.useStyle(itemStyle);
el.style.fill = null;
el.style.stroke = borderColor;
el.style.lineWidth = data.getLayout('barWidth');
}
function createBackgroundShape(isHorizontalOrRadial, layout, coord) {
var coordLayout;
var isPolar = coord.type === 'polar';
if (isPolar) {
coordLayout = coord.getArea();
} else {
coordLayout = coord.grid.getRect();
}
if (isPolar) {
return {
cx: coordLayout.cx,
cy: coordLayout.cy,
r0: isHorizontalOrRadial ? coordLayout.r0 : layout.r0,
r: isHorizontalOrRadial ? coordLayout.r : layout.r,
startAngle: isHorizontalOrRadial ? layout.startAngle : 0,
endAngle: isHorizontalOrRadial ? layout.endAngle : Math.PI * 2
};
} else {
return {
x: isHorizontalOrRadial ? layout.x : coordLayout.x,
y: isHorizontalOrRadial ? coordLayout.y : layout.y,
width: isHorizontalOrRadial ? layout.width : coordLayout.width,
height: isHorizontalOrRadial ? coordLayout.height : layout.height
};
}
}
function createBackgroundEl(coord, isHorizontalOrRadial, layout) {
var ElementClz = coord.type === 'polar' ? graphic.Sector : graphic.Rect;
return new ElementClz({
shape: createBackgroundShape(isHorizontalOrRadial, layout, coord),
silent: true,
z2: 0
});
}
module.exports = _default;

103
node_modules/echarts/lib/chart/bar/BaseBarSeries.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var SeriesModel = require("../../model/Series");
var createListFromArray = require("../helper/createListFromArray");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var _default = SeriesModel.extend({
type: 'series.__base_bar__',
getInitialData: function (option, ecModel) {
return createListFromArray(this.getSource(), this, {
useEncodeDefaulter: true
});
},
getMarkerPosition: function (value) {
var coordSys = this.coordinateSystem;
if (coordSys) {
// PENDING if clamp ?
var pt = coordSys.dataToPoint(coordSys.clampData(value));
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,
large: false,
largeThreshold: 400,
progressive: 3e3,
progressiveChunkMode: 'mod',
// barMaxWidth: null,
// In cartesian, the default value is 1. Otherwise null.
// barMinWidth: null,
// 默认自适应
// barWidth: null,
// 柱间距离默认为柱形宽度的30%,可设固定值
// barGap: '30%',
// 类目间柱形距离默认为类目间距的20%,可设固定值
// barCategoryGap: '20%',
// label: {
// show: false
// },
itemStyle: {},
emphasis: {}
}
});
module.exports = _default;

View File

@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var BaseBarSeries = require("./BaseBarSeries");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var PictorialBarSeries = BaseBarSeries.extend({
type: 'series.pictorialBar',
dependencies: ['grid'],
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 default.
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
barGap: '-100%',
// In most case, overlap is needed.
// z can be set in data item, which is z2 actually.
// Disable progressive
progressive: 0,
hoverAnimation: false // Open only when needed.
},
getInitialData: function (option) {
// Disable stack.
option.stack = null;
return PictorialBarSeries.superApply(this, 'getInitialData', arguments);
}
});
var _default = PictorialBarSeries;
module.exports = _default;

677
node_modules/echarts/lib/chart/bar/PictorialBarView.js generated vendored Normal file
View File

@ -0,0 +1,677 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var echarts = require("../../echarts");
var zrUtil = require("zrender/lib/core/util");
var graphic = require("../../util/graphic");
var _symbol = require("../../util/symbol");
var createSymbol = _symbol.createSymbol;
var _number = require("../../util/number");
var parsePercent = _number.parsePercent;
var isNumeric = _number.isNumeric;
var _helper = require("./helper");
var setLabel = _helper.setLabel;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'borderWidth']; // index: +isHorizontal
var LAYOUT_ATTRS = [{
xy: 'x',
wh: 'width',
index: 0,
posDesc: ['left', 'right']
}, {
xy: 'y',
wh: 'height',
index: 1,
posDesc: ['top', 'bottom']
}];
var pathForLineWidth = new graphic.Circle();
var BarView = echarts.extendChartView({
type: 'pictorialBar',
render: function (seriesModel, ecModel, api) {
var group = this.group;
var data = seriesModel.getData();
var oldData = this._data;
var cartesian = seriesModel.coordinateSystem;
var baseAxis = cartesian.getBaseAxis();
var isHorizontal = !!baseAxis.isHorizontal();
var coordSysRect = cartesian.grid.getRect();
var opt = {
ecSize: {
width: api.getWidth(),
height: api.getHeight()
},
seriesModel: seriesModel,
coordSys: cartesian,
coordSysExtent: [[coordSysRect.x, coordSysRect.x + coordSysRect.width], [coordSysRect.y, coordSysRect.y + coordSysRect.height]],
isHorizontal: isHorizontal,
valueDim: LAYOUT_ATTRS[+isHorizontal],
categoryDim: LAYOUT_ATTRS[1 - isHorizontal]
};
data.diff(oldData).add(function (dataIndex) {
if (!data.hasValue(dataIndex)) {
return;
}
var itemModel = getItemModel(data, dataIndex);
var symbolMeta = getSymbolMeta(data, dataIndex, itemModel, opt);
var bar = createBar(data, opt, symbolMeta);
data.setItemGraphicEl(dataIndex, bar);
group.add(bar);
updateCommon(bar, opt, symbolMeta);
}).update(function (newIndex, oldIndex) {
var bar = oldData.getItemGraphicEl(oldIndex);
if (!data.hasValue(newIndex)) {
group.remove(bar);
return;
}
var itemModel = getItemModel(data, newIndex);
var symbolMeta = getSymbolMeta(data, newIndex, itemModel, opt);
var pictorialShapeStr = getShapeStr(data, symbolMeta);
if (bar && pictorialShapeStr !== bar.__pictorialShapeStr) {
group.remove(bar);
data.setItemGraphicEl(newIndex, null);
bar = null;
}
if (bar) {
updateBar(bar, opt, symbolMeta);
} else {
bar = createBar(data, opt, symbolMeta, true);
}
data.setItemGraphicEl(newIndex, bar);
bar.__pictorialSymbolMeta = symbolMeta; // Add back
group.add(bar);
updateCommon(bar, opt, symbolMeta);
}).remove(function (dataIndex) {
var bar = oldData.getItemGraphicEl(dataIndex);
bar && removeBar(oldData, dataIndex, bar.__pictorialSymbolMeta.animationModel, bar);
}).execute();
this._data = data;
return this.group;
},
dispose: zrUtil.noop,
remove: function (ecModel, api) {
var group = this.group;
var data = this._data;
if (ecModel.get('animation')) {
if (data) {
data.eachItemGraphicEl(function (bar) {
removeBar(data, bar.dataIndex, ecModel, bar);
});
}
} else {
group.removeAll();
}
}
}); // Set or calculate default value about symbol, and calculate layout info.
function getSymbolMeta(data, dataIndex, itemModel, opt) {
var layout = data.getItemLayout(dataIndex);
var symbolRepeat = itemModel.get('symbolRepeat');
var symbolClip = itemModel.get('symbolClip');
var symbolPosition = itemModel.get('symbolPosition') || 'start';
var symbolRotate = itemModel.get('symbolRotate');
var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
var isAnimationEnabled = itemModel.isAnimationEnabled();
var symbolMeta = {
dataIndex: dataIndex,
layout: layout,
itemModel: itemModel,
symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
color: data.getItemVisual(dataIndex, 'color'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
z2: itemModel.getShallow('z', true) || 0
};
prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
prepareSymbolSize(data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength, symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta);
prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
var symbolSize = symbolMeta.symbolSize;
var symbolOffset = itemModel.get('symbolOffset');
if (zrUtil.isArray(symbolOffset)) {
symbolOffset = [parsePercent(symbolOffset[0], symbolSize[0]), parsePercent(symbolOffset[1], symbolSize[1])];
}
prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength, opt, symbolMeta);
return symbolMeta;
} // bar length can be negative.
function prepareBarLength(itemModel, symbolRepeat, layout, opt, output) {
var valueDim = opt.valueDim;
var symbolBoundingData = itemModel.get('symbolBoundingData');
var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
var boundingLength;
if (zrUtil.isArray(symbolBoundingData)) {
var symbolBoundingExtent = [convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx, convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx];
symbolBoundingExtent[1] < symbolBoundingExtent[0] && symbolBoundingExtent.reverse();
boundingLength = symbolBoundingExtent[pxSignIdx];
} else if (symbolBoundingData != null) {
boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
} else if (symbolRepeat) {
boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
} else {
boundingLength = layout[valueDim.wh];
}
output.boundingLength = boundingLength;
if (symbolRepeat) {
output.repeatCutLength = layout[valueDim.wh];
}
output.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
}
function convertToCoordOnAxis(axis, value) {
return axis.toGlobalCoord(axis.dataToCoord(axis.scale.parse(value)));
} // Support ['100%', '100%']
function prepareSymbolSize(data, dataIndex, layout, symbolRepeat, symbolClip, boundingLength, pxSign, symbolPatternSize, opt, output) {
var valueDim = opt.valueDim;
var categoryDim = opt.categoryDim;
var categorySize = Math.abs(layout[categoryDim.wh]);
var symbolSize = data.getItemVisual(dataIndex, 'symbolSize');
if (zrUtil.isArray(symbolSize)) {
symbolSize = symbolSize.slice();
} else {
if (symbolSize == null) {
symbolSize = '100%';
}
symbolSize = [symbolSize, symbolSize];
} // Note: percentage symbolSize (like '100%') do not consider lineWidth, because it is
// to complicated to calculate real percent value if considering scaled lineWidth.
// So the actual size will bigger than layout size if lineWidth is bigger than zero,
// which can be tolerated in pictorial chart.
symbolSize[categoryDim.index] = parsePercent(symbolSize[categoryDim.index], categorySize);
symbolSize[valueDim.index] = parsePercent(symbolSize[valueDim.index], symbolRepeat ? categorySize : Math.abs(boundingLength));
output.symbolSize = symbolSize; // If x or y is less than zero, show reversed shape.
var symbolScale = output.symbolScale = [symbolSize[0] / symbolPatternSize, symbolSize[1] / symbolPatternSize]; // Follow convention, 'right' and 'top' is the normal scale.
symbolScale[valueDim.index] *= (opt.isHorizontal ? -1 : 1) * pxSign;
}
function prepareLineWidth(itemModel, symbolScale, rotation, opt, output) {
// In symbols are drawn with scale, so do not need to care about the case that width
// or height are too small. But symbol use strokeNoScale, where acture lineWidth should
// be calculated.
var valueLineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
if (valueLineWidth) {
pathForLineWidth.attr({
scale: symbolScale.slice(),
rotation: rotation
});
pathForLineWidth.updateTransform();
valueLineWidth /= pathForLineWidth.getLineScale();
valueLineWidth *= symbolScale[opt.valueDim.index];
}
output.valueLineWidth = valueLineWidth;
}
function prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, output) {
var categoryDim = opt.categoryDim;
var valueDim = opt.valueDim;
var pxSign = output.pxSign;
var unitLength = Math.max(symbolSize[valueDim.index] + valueLineWidth, 0);
var pathLen = unitLength; // Note: rotation will not effect the layout of symbols, because user may
// want symbols to rotate on its center, which should not be translated
// when rotating.
if (symbolRepeat) {
var absBoundingLength = Math.abs(boundingLength);
var symbolMargin = zrUtil.retrieve(itemModel.get('symbolMargin'), '15%') + '';
var hasEndGap = false;
if (symbolMargin.lastIndexOf('!') === symbolMargin.length - 1) {
hasEndGap = true;
symbolMargin = symbolMargin.slice(0, symbolMargin.length - 1);
}
symbolMargin = parsePercent(symbolMargin, symbolSize[valueDim.index]);
var uLenWithMargin = Math.max(unitLength + symbolMargin * 2, 0); // When symbol margin is less than 0, margin at both ends will be subtracted
// to ensure that all of the symbols will not be overflow the given area.
var endFix = hasEndGap ? 0 : symbolMargin * 2; // Both final repeatTimes and final symbolMargin area calculated based on
// boundingLength.
var repeatSpecified = isNumeric(symbolRepeat);
var repeatTimes = repeatSpecified ? symbolRepeat : toIntTimes((absBoundingLength + endFix) / uLenWithMargin); // Adjust calculate margin, to ensure each symbol is displayed
// entirely in the given layout area.
var mDiff = absBoundingLength - repeatTimes * unitLength;
symbolMargin = mDiff / 2 / (hasEndGap ? repeatTimes : repeatTimes - 1);
uLenWithMargin = unitLength + symbolMargin * 2;
endFix = hasEndGap ? 0 : symbolMargin * 2; // Update repeatTimes when not all symbol will be shown.
if (!repeatSpecified && symbolRepeat !== 'fixed') {
repeatTimes = repeatCutLength ? toIntTimes((Math.abs(repeatCutLength) + endFix) / uLenWithMargin) : 0;
}
pathLen = repeatTimes * uLenWithMargin - endFix;
output.repeatTimes = repeatTimes;
output.symbolMargin = symbolMargin;
}
var sizeFix = pxSign * (pathLen / 2);
var pathPosition = output.pathPosition = [];
pathPosition[categoryDim.index] = layout[categoryDim.wh] / 2;
pathPosition[valueDim.index] = symbolPosition === 'start' ? sizeFix : symbolPosition === 'end' ? boundingLength - sizeFix : boundingLength / 2; // 'center'
if (symbolOffset) {
pathPosition[0] += symbolOffset[0];
pathPosition[1] += symbolOffset[1];
}
var bundlePosition = output.bundlePosition = [];
bundlePosition[categoryDim.index] = layout[categoryDim.xy];
bundlePosition[valueDim.index] = layout[valueDim.xy];
var barRectShape = output.barRectShape = zrUtil.extend({}, layout);
barRectShape[valueDim.wh] = pxSign * Math.max(Math.abs(layout[valueDim.wh]), Math.abs(pathPosition[valueDim.index] + sizeFix));
barRectShape[categoryDim.wh] = layout[categoryDim.wh];
var clipShape = output.clipShape = {}; // Consider that symbol may be overflow layout rect.
clipShape[categoryDim.xy] = -layout[categoryDim.xy];
clipShape[categoryDim.wh] = opt.ecSize[categoryDim.wh];
clipShape[valueDim.xy] = 0;
clipShape[valueDim.wh] = layout[valueDim.wh];
}
function createPath(symbolMeta) {
var symbolPatternSize = symbolMeta.symbolPatternSize;
var path = createSymbol( // Consider texture img, make a big size.
symbolMeta.symbolType, -symbolPatternSize / 2, -symbolPatternSize / 2, symbolPatternSize, symbolPatternSize, symbolMeta.color);
path.attr({
culling: true
});
path.type !== 'image' && path.setStyle({
strokeNoScale: true
});
return path;
}
function createOrUpdateRepeatSymbols(bar, opt, symbolMeta, isUpdate) {
var bundle = bar.__pictorialBundle;
var symbolSize = symbolMeta.symbolSize;
var valueLineWidth = symbolMeta.valueLineWidth;
var pathPosition = symbolMeta.pathPosition;
var valueDim = opt.valueDim;
var repeatTimes = symbolMeta.repeatTimes || 0;
var index = 0;
var unit = symbolSize[opt.valueDim.index] + valueLineWidth + symbolMeta.symbolMargin * 2;
eachPath(bar, function (path) {
path.__pictorialAnimationIndex = index;
path.__pictorialRepeatTimes = repeatTimes;
if (index < repeatTimes) {
updateAttr(path, null, makeTarget(index), symbolMeta, isUpdate);
} else {
updateAttr(path, null, {
scale: [0, 0]
}, symbolMeta, isUpdate, function () {
bundle.remove(path);
});
}
updateHoverAnimation(path, symbolMeta);
index++;
});
for (; index < repeatTimes; index++) {
var path = createPath(symbolMeta);
path.__pictorialAnimationIndex = index;
path.__pictorialRepeatTimes = repeatTimes;
bundle.add(path);
var target = makeTarget(index);
updateAttr(path, {
position: target.position,
scale: [0, 0]
}, {
scale: target.scale,
rotation: target.rotation
}, symbolMeta, isUpdate); // FIXME
// If all emphasis/normal through action.
path.on('mouseover', onMouseOver).on('mouseout', onMouseOut);
updateHoverAnimation(path, symbolMeta);
}
function makeTarget(index) {
var position = pathPosition.slice(); // (start && pxSign > 0) || (end && pxSign < 0): i = repeatTimes - index
// Otherwise: i = index;
var pxSign = symbolMeta.pxSign;
var i = index;
if (symbolMeta.symbolRepeatDirection === 'start' ? pxSign > 0 : pxSign < 0) {
i = repeatTimes - 1 - index;
}
position[valueDim.index] = unit * (i - repeatTimes / 2 + 0.5) + pathPosition[valueDim.index];
return {
position: position,
scale: symbolMeta.symbolScale.slice(),
rotation: symbolMeta.rotation
};
}
function onMouseOver() {
eachPath(bar, function (path) {
path.trigger('emphasis');
});
}
function onMouseOut() {
eachPath(bar, function (path) {
path.trigger('normal');
});
}
}
function createOrUpdateSingleSymbol(bar, opt, symbolMeta, isUpdate) {
var bundle = bar.__pictorialBundle;
var mainPath = bar.__pictorialMainPath;
if (!mainPath) {
mainPath = bar.__pictorialMainPath = createPath(symbolMeta);
bundle.add(mainPath);
updateAttr(mainPath, {
position: symbolMeta.pathPosition.slice(),
scale: [0, 0],
rotation: symbolMeta.rotation
}, {
scale: symbolMeta.symbolScale.slice()
}, symbolMeta, isUpdate);
mainPath.on('mouseover', onMouseOver).on('mouseout', onMouseOut);
} else {
updateAttr(mainPath, null, {
position: symbolMeta.pathPosition.slice(),
scale: symbolMeta.symbolScale.slice(),
rotation: symbolMeta.rotation
}, symbolMeta, isUpdate);
}
updateHoverAnimation(mainPath, symbolMeta);
function onMouseOver() {
this.trigger('emphasis');
}
function onMouseOut() {
this.trigger('normal');
}
} // bar rect is used for label.
function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);
var barRect = bar.__pictorialBarRect;
if (!barRect) {
barRect = bar.__pictorialBarRect = new graphic.Rect({
z2: 2,
shape: rectShape,
silent: true,
style: {
stroke: 'transparent',
fill: 'transparent',
lineWidth: 0
}
});
bar.add(barRect);
} else {
updateAttr(barRect, null, {
shape: rectShape
}, symbolMeta, isUpdate);
}
}
function createOrUpdateClip(bar, opt, symbolMeta, isUpdate) {
// If not clip, symbol will be remove and rebuilt.
if (symbolMeta.symbolClip) {
var clipPath = bar.__pictorialClipPath;
var clipShape = zrUtil.extend({}, symbolMeta.clipShape);
var valueDim = opt.valueDim;
var animationModel = symbolMeta.animationModel;
var dataIndex = symbolMeta.dataIndex;
if (clipPath) {
graphic.updateProps(clipPath, {
shape: clipShape
}, animationModel, dataIndex);
} else {
clipShape[valueDim.wh] = 0;
clipPath = new graphic.Rect({
shape: clipShape
});
bar.__pictorialBundle.setClipPath(clipPath);
bar.__pictorialClipPath = clipPath;
var target = {};
target[valueDim.wh] = symbolMeta.clipShape[valueDim.wh];
graphic[isUpdate ? 'updateProps' : 'initProps'](clipPath, {
shape: target
}, animationModel, dataIndex);
}
}
}
function getItemModel(data, dataIndex) {
var itemModel = data.getItemModel(dataIndex);
itemModel.getAnimationDelayParams = getAnimationDelayParams;
itemModel.isAnimationEnabled = isAnimationEnabled;
return itemModel;
}
function getAnimationDelayParams(path) {
// The order is the same as the z-order, see `symbolRepeatDiretion`.
return {
index: path.__pictorialAnimationIndex,
count: path.__pictorialRepeatTimes
};
}
function isAnimationEnabled() {
// `animation` prop can be set on itemModel in pictorial bar chart.
return this.parentModel.isAnimationEnabled() && !!this.getShallow('animation');
}
function updateHoverAnimation(path, symbolMeta) {
path.off('emphasis').off('normal');
var scale = symbolMeta.symbolScale.slice();
symbolMeta.hoverAnimation && path.on('emphasis', function () {
this.animateTo({
scale: [scale[0] * 1.1, scale[1] * 1.1]
}, 400, 'elasticOut');
}).on('normal', function () {
this.animateTo({
scale: scale.slice()
}, 400, 'elasticOut');
});
}
function createBar(data, opt, symbolMeta, isUpdate) {
// bar is the main element for each data.
var bar = new graphic.Group(); // bundle is used for location and clip.
var bundle = new graphic.Group();
bar.add(bundle);
bar.__pictorialBundle = bundle;
bundle.attr('position', symbolMeta.bundlePosition.slice());
if (symbolMeta.symbolRepeat) {
createOrUpdateRepeatSymbols(bar, opt, symbolMeta);
} else {
createOrUpdateSingleSymbol(bar, opt, symbolMeta);
}
createOrUpdateBarRect(bar, symbolMeta, isUpdate);
createOrUpdateClip(bar, opt, symbolMeta, isUpdate);
bar.__pictorialShapeStr = getShapeStr(data, symbolMeta);
bar.__pictorialSymbolMeta = symbolMeta;
return bar;
}
function updateBar(bar, opt, symbolMeta) {
var animationModel = symbolMeta.animationModel;
var dataIndex = symbolMeta.dataIndex;
var bundle = bar.__pictorialBundle;
graphic.updateProps(bundle, {
position: symbolMeta.bundlePosition.slice()
}, animationModel, dataIndex);
if (symbolMeta.symbolRepeat) {
createOrUpdateRepeatSymbols(bar, opt, symbolMeta, true);
} else {
createOrUpdateSingleSymbol(bar, opt, symbolMeta, true);
}
createOrUpdateBarRect(bar, symbolMeta, true);
createOrUpdateClip(bar, opt, symbolMeta, true);
}
function removeBar(data, dataIndex, animationModel, bar) {
// Not show text when animating
var labelRect = bar.__pictorialBarRect;
labelRect && (labelRect.style.text = null);
var pathes = [];
eachPath(bar, function (path) {
pathes.push(path);
});
bar.__pictorialMainPath && pathes.push(bar.__pictorialMainPath); // I do not find proper remove animation for clip yet.
bar.__pictorialClipPath && (animationModel = null);
zrUtil.each(pathes, function (path) {
graphic.updateProps(path, {
scale: [0, 0]
}, animationModel, dataIndex, function () {
bar.parent && bar.parent.remove(bar);
});
});
data.setItemGraphicEl(dataIndex, null);
}
function getShapeStr(data, symbolMeta) {
return [data.getItemVisual(symbolMeta.dataIndex, 'symbol') || 'none', !!symbolMeta.symbolRepeat, !!symbolMeta.symbolClip].join(':');
}
function eachPath(bar, cb, context) {
// Do not use Group#eachChild, because it do not support remove.
zrUtil.each(bar.__pictorialBundle.children(), function (el) {
el !== bar.__pictorialBarRect && cb.call(context, el);
});
}
function updateAttr(el, immediateAttrs, animationAttrs, symbolMeta, isUpdate, cb) {
immediateAttrs && el.attr(immediateAttrs); // when symbolCip used, only clip path has init animation, otherwise it would be weird effect.
if (symbolMeta.symbolClip && !isUpdate) {
animationAttrs && el.attr(animationAttrs);
} else {
animationAttrs && graphic[isUpdate ? 'updateProps' : 'initProps'](el, animationAttrs, symbolMeta.animationModel, symbolMeta.dataIndex, cb);
}
}
function updateCommon(bar, opt, symbolMeta) {
var color = symbolMeta.color;
var dataIndex = symbolMeta.dataIndex;
var itemModel = symbolMeta.itemModel; // Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
var normalStyle = itemModel.getModel('itemStyle').getItemStyle(['color']);
var hoverStyle = itemModel.getModel('emphasis.itemStyle').getItemStyle();
var cursorStyle = itemModel.getShallow('cursor');
eachPath(bar, function (path) {
// PENDING setColor should be before setStyle!!!
path.setColor(color);
path.setStyle(zrUtil.defaults({
fill: color,
opacity: symbolMeta.opacity
}, normalStyle));
graphic.setHoverStyle(path, hoverStyle);
cursorStyle && (path.cursor = cursorStyle);
path.z2 = symbolMeta.z2;
});
var barRectHoverStyle = {};
var barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
var barRect = bar.__pictorialBarRect;
setLabel(barRect.style, barRectHoverStyle, itemModel, color, opt.seriesModel, dataIndex, barPositionOutside);
graphic.setHoverStyle(barRect, barRectHoverStyle);
}
function toIntTimes(times) {
var roundedTimes = Math.round(times); // Escapse accurate error
return Math.abs(times - roundedTimes) < 1e-4 ? roundedTimes : Math.ceil(times);
}
var _default = BarView;
module.exports = _default;

55
node_modules/echarts/lib/chart/bar/barItemStyle.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var makeStyleMapper = require("../../model/mixin/makeStyleMapper");
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var getBarItemStyle = makeStyleMapper([['fill', 'color'], ['stroke', 'borderColor'], ['lineWidth', 'borderWidth'], // Compatitable with 2
['stroke', 'barBorderColor'], ['lineWidth', 'barBorderWidth'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor']]);
var _default = {
getBarItemStyle: function (excludes) {
var style = getBarItemStyle(this, excludes);
if (this.getBorderLineDash) {
var lineDash = this.getBorderLineDash();
lineDash && (style.lineDash = lineDash);
}
return style;
}
};
module.exports = _default;

65
node_modules/echarts/lib/chart/bar/helper.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var graphic = require("../../util/graphic");
var _labelHelper = require("../helper/labelHelper");
var getDefaultLabel = _labelHelper.getDefaultLabel;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function setLabel(normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside) {
var labelModel = itemModel.getModel('label');
var hoverLabelModel = itemModel.getModel('emphasis.label');
graphic.setLabelStyle(normalStyle, hoverStyle, labelModel, hoverLabelModel, {
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
isRectText: true,
autoColor: color
});
fixPosition(normalStyle);
fixPosition(hoverStyle);
}
function fixPosition(style, labelPositionOutside) {
if (style.textPosition === 'outside') {
style.textPosition = labelPositionOutside;
}
}
exports.setLabel = setLabel;