逐步完成前后端服务器

This commit is contained in:
2025-09-09 15:00:30 +08:00
parent fcb09432e9
commit c7dfa1e9fc
2937 changed files with 1477567 additions and 0 deletions

80
frontend/node_modules/echarts/lib/action/roamHelper.js generated vendored Normal file
View File

@ -0,0 +1,80 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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 getCenterCoord(view, point) {
// Use projected coord as center because it's linear.
return view.pointToProjected ? view.pointToProjected(point) : view.pointToData(point);
}
export function updateCenterAndZoom(view, payload, zoomLimit, api) {
var previousZoom = view.getZoom();
var center = view.getCenter();
var zoom = payload.zoom;
var point = view.projectedToPoint ? view.projectedToPoint(center) : view.dataToPoint(center);
if (payload.dx != null && payload.dy != null) {
point[0] -= payload.dx;
point[1] -= payload.dy;
view.setCenter(getCenterCoord(view, point), api);
}
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.scaleX *= zoom;
view.scaleY *= zoom;
var fixX = (payload.originX - view.x) * (zoom - 1);
var fixY = (payload.originY - view.y) * (zoom - 1);
view.x -= fixX;
view.y -= fixY;
view.updateTransform();
// Get the new center
view.setCenter(getCenterCoord(view, point), api);
view.setZoom(zoom * previousZoom);
}
return {
center: view.getCenter(),
zoom: view.getZoom()
};
}

View File

@ -0,0 +1,243 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { isFunction, isObject, retrieve2 } from 'zrender/lib/core/util.js';
import { makeInner } from '../util/model.js';
// Stored properties for further transition.
export var transitionStore = makeInner();
/**
* Return null if animation is disabled.
*/
export function getAnimationConfig(animationType, animatableModel, dataIndex,
// Extra opts can override the option in animatable model.
extraOpts,
// TODO It's only for pictorial bar now.
extraDelayParams) {
var animationPayload;
// Check if there is global animation configuration from dataZoom/resize can override the config in option.
// If animation is enabled. Will use this animation config in payload.
// If animation is disabled. Just ignore it.
if (animatableModel && animatableModel.ecModel) {
var updatePayload = animatableModel.ecModel.getUpdatePayload();
animationPayload = updatePayload && updatePayload.animation;
}
var animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
var isUpdate = animationType === 'update';
if (animationEnabled) {
var duration = void 0;
var easing = void 0;
var delay = void 0;
if (extraOpts) {
duration = retrieve2(extraOpts.duration, 200);
easing = retrieve2(extraOpts.easing, 'cubicOut');
delay = 0;
} else {
duration = animatableModel.getShallow(isUpdate ? 'animationDurationUpdate' : 'animationDuration');
easing = animatableModel.getShallow(isUpdate ? 'animationEasingUpdate' : 'animationEasing');
delay = animatableModel.getShallow(isUpdate ? 'animationDelayUpdate' : 'animationDelay');
}
// animation from payload has highest priority.
if (animationPayload) {
animationPayload.duration != null && (duration = animationPayload.duration);
animationPayload.easing != null && (easing = animationPayload.easing);
animationPayload.delay != null && (delay = animationPayload.delay);
}
if (isFunction(delay)) {
delay = delay(dataIndex, extraDelayParams);
}
if (isFunction(duration)) {
duration = duration(dataIndex);
}
var config = {
duration: duration || 0,
delay: delay,
easing: easing
};
return config;
} else {
return null;
}
}
function animateOrSetProps(animationType, el, props, animatableModel, dataIndex, cb, during) {
var isFrom = false;
var removeOpt;
if (isFunction(dataIndex)) {
during = cb;
cb = dataIndex;
dataIndex = null;
} else if (isObject(dataIndex)) {
cb = dataIndex.cb;
during = dataIndex.during;
isFrom = dataIndex.isFrom;
removeOpt = dataIndex.removeOpt;
dataIndex = dataIndex.dataIndex;
}
var isRemove = animationType === 'leave';
if (!isRemove) {
// Must stop the remove animation.
el.stopAnimation('leave');
}
var animationConfig = getAnimationConfig(animationType, animatableModel, dataIndex, isRemove ? removeOpt || {} : null, animatableModel && animatableModel.getAnimationDelayParams ? animatableModel.getAnimationDelayParams(el, dataIndex) : null);
if (animationConfig && animationConfig.duration > 0) {
var duration = animationConfig.duration;
var animationDelay = animationConfig.delay;
var animationEasing = animationConfig.easing;
var animateConfig = {
duration: duration,
delay: animationDelay || 0,
easing: animationEasing,
done: cb,
force: !!cb || !!during,
// Set to final state in update/init animation.
// So the post processing based on the path shape can be done correctly.
setToFinal: !isRemove,
scope: animationType,
during: during
};
isFrom ? el.animateFrom(props, animateConfig) : el.animateTo(props, animateConfig);
} else {
el.stopAnimation();
// If `isFrom`, the props is the "from" props.
!isFrom && el.attr(props);
// Call during at least once.
during && during(1);
cb && cb();
}
}
/**
* Update graphic element properties with or without animation according to the
* configuration in series.
*
* Caution: this method will stop previous animation.
* So do not use this method to one element twice before
* animation starts, unless you know what you are doing.
* @example
* graphic.updateProps(el, {
* position: [100, 100]
* }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
* // Or
* graphic.updateProps(el, {
* position: [100, 100]
* }, seriesModel, function () { console.log('Animation done!'); });
*/
function updateProps(el, props,
// TODO: TYPE AnimatableModel
animatableModel, dataIndex, cb, during) {
animateOrSetProps('update', el, props, animatableModel, dataIndex, cb, during);
}
export { updateProps };
/**
* Init graphic element properties with or without animation according to the
* configuration in series.
*
* Caution: this method will stop previous animation.
* So do not use this method to one element twice before
* animation starts, unless you know what you are doing.
*/
export function initProps(el, props, animatableModel, dataIndex, cb, during) {
animateOrSetProps('enter', el, props, animatableModel, dataIndex, cb, during);
}
/**
* If element is removed.
* It can determine if element is having remove animation.
*/
export function isElementRemoved(el) {
if (!el.__zr) {
return true;
}
for (var i = 0; i < el.animators.length; i++) {
var animator = el.animators[i];
if (animator.scope === 'leave') {
return true;
}
}
return false;
}
/**
* Remove graphic element
*/
export function removeElement(el, props, animatableModel, dataIndex, cb, during) {
// Don't do remove animation twice.
if (isElementRemoved(el)) {
return;
}
animateOrSetProps('leave', el, props, animatableModel, dataIndex, cb, during);
}
function fadeOutDisplayable(el, animatableModel, dataIndex, done) {
el.removeTextContent();
el.removeTextGuideLine();
removeElement(el, {
style: {
opacity: 0
}
}, animatableModel, dataIndex, done);
}
export function removeElementWithFadeOut(el, animatableModel, dataIndex) {
function doRemove() {
el.parent && el.parent.remove(el);
}
// Hide label and labelLine first
// TODO Also use fade out animation?
if (!el.isGroup) {
fadeOutDisplayable(el, animatableModel, dataIndex, doRemove);
} else {
el.traverse(function (disp) {
if (!disp.isGroup) {
// Can invoke doRemove multiple times.
fadeOutDisplayable(disp, animatableModel, dataIndex, doRemove);
}
});
}
}
/**
* Save old style for style transition in universalTransition module.
* It's used when element will be reused in each render.
* For chart like map, heatmap, which will always create new element.
* We don't need to save this because universalTransition can get old style from the old element
*/
export function saveOldStyle(el) {
transitionStore(el).oldStyle = el.style;
}
export function getOldStyle(el) {
return transitionStore(el).oldStyle;
}

View File

@ -0,0 +1,143 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { keys, filter, each, isArray, indexOf } from 'zrender/lib/core/util.js';
import { ELEMENT_ANIMATABLE_PROPS } from './customGraphicTransition.js';
import { getAnimationConfig } from './basicTransition.js';
import { warn } from '../util/log.js';
import { makeInner } from '../util/model.js';
var getStateToRestore = makeInner();
var KEYFRAME_EXCLUDE_KEYS = ['percent', 'easing', 'shape', 'style', 'extra'];
/**
* Stop previous keyframe animation and restore the attributes.
* Avoid new keyframe animation starts with wrong internal state when the percent: 0 is not set.
*/
export function stopPreviousKeyframeAnimationAndRestore(el) {
// Stop previous keyframe animation.
el.stopAnimation('keyframe');
// Restore
el.attr(getStateToRestore(el));
}
export function applyKeyframeAnimation(el, animationOpts, animatableModel) {
if (!animatableModel.isAnimationEnabled() || !animationOpts) {
return;
}
if (isArray(animationOpts)) {
each(animationOpts, function (singleAnimationOpts) {
applyKeyframeAnimation(el, singleAnimationOpts, animatableModel);
});
return;
}
var keyframes = animationOpts.keyframes;
var duration = animationOpts.duration;
if (animatableModel && duration == null) {
// Default to use duration of config.
// NOTE: animation config from payload will be ignored because they are mainly for transitions.
var config = getAnimationConfig('enter', animatableModel, 0);
duration = config && config.duration;
}
if (!keyframes || !duration) {
return;
}
var stateToRestore = getStateToRestore(el);
each(ELEMENT_ANIMATABLE_PROPS, function (targetPropName) {
if (targetPropName && !el[targetPropName]) {
return;
}
var animator;
var endFrameIsSet = false;
// Sort keyframes by percent.
keyframes.sort(function (a, b) {
return a.percent - b.percent;
});
each(keyframes, function (kf) {
// Stop current animation.
var animators = el.animators;
var kfValues = targetPropName ? kf[targetPropName] : kf;
if (process.env.NODE_ENV !== 'production') {
if (kf.percent >= 1) {
endFrameIsSet = true;
}
}
if (!kfValues) {
return;
}
var propKeys = keys(kfValues);
if (!targetPropName) {
// PENDING performance?
propKeys = filter(propKeys, function (key) {
return indexOf(KEYFRAME_EXCLUDE_KEYS, key) < 0;
});
}
if (!propKeys.length) {
return;
}
if (!animator) {
animator = el.animate(targetPropName, animationOpts.loop, true);
animator.scope = 'keyframe';
}
for (var i = 0; i < animators.length; i++) {
// Stop all other animation that is not keyframe.
if (animators[i] !== animator && animators[i].targetName === animator.targetName) {
animators[i].stopTracks(propKeys);
}
}
targetPropName && (stateToRestore[targetPropName] = stateToRestore[targetPropName] || {});
var savedTarget = targetPropName ? stateToRestore[targetPropName] : stateToRestore;
each(propKeys, function (key) {
// Save original value.
savedTarget[key] = ((targetPropName ? el[targetPropName] : el) || {})[key];
});
animator.whenWithKeys(duration * kf.percent, kfValues, propKeys, kf.easing);
});
if (!animator) {
return;
}
if (process.env.NODE_ENV !== 'production') {
if (!endFrameIsSet) {
warn('End frame with percent: 1 is missing in the keyframeAnimation.', true);
}
}
animator.delay(animationOpts.delay || 0).duration(duration).start(animationOpts.easing);
});
}

View File

@ -0,0 +1,480 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { makeInner, normalizeToArray } from '../util/model.js';
import { assert, bind, each, eqNaN, extend, hasOwn, indexOf, isArrayLike, keys, reduce } from 'zrender/lib/core/util.js';
import { cloneValue } from 'zrender/lib/animation/Animator.js';
import Displayable from 'zrender/lib/graphic/Displayable.js';
import { getAnimationConfig } from './basicTransition.js';
import { Path } from '../util/graphic.js';
import { warn } from '../util/log.js';
import { TRANSFORMABLE_PROPS } from 'zrender/lib/core/Transformable.js';
var LEGACY_TRANSFORM_PROPS_MAP = {
position: ['x', 'y'],
scale: ['scaleX', 'scaleY'],
origin: ['originX', 'originY']
};
var LEGACY_TRANSFORM_PROPS = keys(LEGACY_TRANSFORM_PROPS_MAP);
var TRANSFORM_PROPS_MAP = reduce(TRANSFORMABLE_PROPS, function (obj, key) {
obj[key] = 1;
return obj;
}, {});
var transformPropNamesStr = TRANSFORMABLE_PROPS.join(', ');
// '' means root
export var ELEMENT_ANIMATABLE_PROPS = ['', 'style', 'shape', 'extra'];
;
var transitionInnerStore = makeInner();
;
function getElementAnimationConfig(animationType, el, elOption, parentModel, dataIndex) {
var animationProp = animationType + "Animation";
var config = getAnimationConfig(animationType, parentModel, dataIndex) || {};
var userDuring = transitionInnerStore(el).userDuring;
// Only set when duration is > 0 and it's need to be animated.
if (config.duration > 0) {
// For simplicity, if during not specified, the previous during will not work any more.
config.during = userDuring ? bind(duringCall, {
el: el,
userDuring: userDuring
}) : null;
config.setToFinal = true;
config.scope = animationType;
}
extend(config, elOption[animationProp]);
return config;
}
export function applyUpdateTransition(el, elOption, animatableModel, opts) {
opts = opts || {};
var dataIndex = opts.dataIndex,
isInit = opts.isInit,
clearStyle = opts.clearStyle;
var hasAnimation = animatableModel.isAnimationEnabled();
// Save the meta info for further morphing. Like apply on the sub morphing elements.
var store = transitionInnerStore(el);
var styleOpt = elOption.style;
store.userDuring = elOption.during;
var transFromProps = {};
var propsToSet = {};
prepareTransformAllPropsFinal(el, elOption, propsToSet);
prepareShapeOrExtraAllPropsFinal('shape', elOption, propsToSet);
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);
if (!isInit && hasAnimation) {
prepareTransformTransitionFrom(el, elOption, transFromProps);
prepareShapeOrExtraTransitionFrom('shape', el, elOption, transFromProps);
prepareShapeOrExtraTransitionFrom('extra', el, elOption, transFromProps);
prepareStyleTransitionFrom(el, elOption, styleOpt, transFromProps);
}
propsToSet.style = styleOpt;
applyPropsDirectly(el, propsToSet, clearStyle);
applyMiscProps(el, elOption);
if (hasAnimation) {
if (isInit) {
var enterFromProps_1 = {};
each(ELEMENT_ANIMATABLE_PROPS, function (propName) {
var prop = propName ? elOption[propName] : elOption;
if (prop && prop.enterFrom) {
if (propName) {
enterFromProps_1[propName] = enterFromProps_1[propName] || {};
}
extend(propName ? enterFromProps_1[propName] : enterFromProps_1, prop.enterFrom);
}
});
var config = getElementAnimationConfig('enter', el, elOption, animatableModel, dataIndex);
if (config.duration > 0) {
el.animateFrom(enterFromProps_1, config);
}
} else {
applyPropsTransition(el, elOption, dataIndex || 0, animatableModel, transFromProps);
}
}
// Store leave to be used in leave transition.
updateLeaveTo(el, elOption);
styleOpt ? el.dirty() : el.markRedraw();
}
export function updateLeaveTo(el, elOption) {
// Try merge to previous set leaveTo
var leaveToProps = transitionInnerStore(el).leaveToProps;
for (var i = 0; i < ELEMENT_ANIMATABLE_PROPS.length; i++) {
var propName = ELEMENT_ANIMATABLE_PROPS[i];
var prop = propName ? elOption[propName] : elOption;
if (prop && prop.leaveTo) {
if (!leaveToProps) {
leaveToProps = transitionInnerStore(el).leaveToProps = {};
}
if (propName) {
leaveToProps[propName] = leaveToProps[propName] || {};
}
extend(propName ? leaveToProps[propName] : leaveToProps, prop.leaveTo);
}
}
}
export function applyLeaveTransition(el, elOption, animatableModel, onRemove) {
if (el) {
var parent_1 = el.parent;
var leaveToProps = transitionInnerStore(el).leaveToProps;
if (leaveToProps) {
// TODO TODO use leave after leaveAnimation in series is introduced
// TODO Data index?
var config = getElementAnimationConfig('update', el, elOption, animatableModel, 0);
config.done = function () {
parent_1.remove(el);
onRemove && onRemove();
};
el.animateTo(leaveToProps, config);
} else {
parent_1.remove(el);
onRemove && onRemove();
}
}
}
export function isTransitionAll(transition) {
return transition === 'all';
}
function applyPropsDirectly(el,
// Can be null/undefined
allPropsFinal, clearStyle) {
var styleOpt = allPropsFinal.style;
if (!el.isGroup && styleOpt) {
if (clearStyle) {
el.useStyle({});
// When style object changed, how to trade the existing animation?
// It is probably complicated and not needed to cover all the cases.
// But still need consider the case:
// (1) When using init animation on `style.opacity`, and before the animation
// ended users triggers an update by mousewhel. At that time the init
// animation should better be continued rather than terminated.
// So after `useStyle` called, we should change the animation target manually
// to continue the effect of the init animation.
// (2) PENDING: If the previous animation targeted at a `val1`, and currently we need
// to update the value to `val2` and no animation declared, should be terminate
// the previous animation or just modify the target of the animation?
// Therotically That will happen not only on `style` but also on `shape` and
// `transfrom` props. But we haven't handle this case at present yet.
// (3) PENDING: Is it proper to visit `animators` and `targetName`?
var animators = el.animators;
for (var i = 0; i < animators.length; i++) {
var animator = animators[i];
// targetName is the "topKey".
if (animator.targetName === 'style') {
animator.changeTarget(el.style);
}
}
}
el.setStyle(styleOpt);
}
if (allPropsFinal) {
// Not set style here.
allPropsFinal.style = null;
// Set el to the final state firstly.
allPropsFinal && el.attr(allPropsFinal);
allPropsFinal.style = styleOpt;
}
}
function applyPropsTransition(el, elOption, dataIndex, model,
// Can be null/undefined
transFromProps) {
if (transFromProps) {
var config = getElementAnimationConfig('update', el, elOption, model, dataIndex);
if (config.duration > 0) {
el.animateFrom(transFromProps, config);
}
}
}
function applyMiscProps(el, elOption) {
// Merge by default.
hasOwn(elOption, 'silent') && (el.silent = elOption.silent);
hasOwn(elOption, 'ignore') && (el.ignore = elOption.ignore);
if (el instanceof Displayable) {
hasOwn(elOption, 'invisible') && (el.invisible = elOption.invisible);
}
if (el instanceof Path) {
hasOwn(elOption, 'autoBatch') && (el.autoBatch = elOption.autoBatch);
}
}
// Use it to avoid it be exposed to user.
var tmpDuringScope = {};
var transitionDuringAPI = {
// Usually other props do not need to be changed in animation during.
setTransform: function (key, val) {
if (process.env.NODE_ENV !== 'production') {
assert(hasOwn(TRANSFORM_PROPS_MAP, key), 'Only ' + transformPropNamesStr + ' available in `setTransform`.');
}
tmpDuringScope.el[key] = val;
return this;
},
getTransform: function (key) {
if (process.env.NODE_ENV !== 'production') {
assert(hasOwn(TRANSFORM_PROPS_MAP, key), 'Only ' + transformPropNamesStr + ' available in `getTransform`.');
}
return tmpDuringScope.el[key];
},
setShape: function (key, val) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var el = tmpDuringScope.el;
var shape = el.shape || (el.shape = {});
shape[key] = val;
el.dirtyShape && el.dirtyShape();
return this;
},
getShape: function (key) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var shape = tmpDuringScope.el.shape;
if (shape) {
return shape[key];
}
},
setStyle: function (key, val) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var el = tmpDuringScope.el;
var style = el.style;
if (style) {
if (process.env.NODE_ENV !== 'production') {
if (eqNaN(val)) {
warn('style.' + key + ' must not be assigned with NaN.');
}
}
style[key] = val;
el.dirtyStyle && el.dirtyStyle();
}
return this;
},
getStyle: function (key) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var style = tmpDuringScope.el.style;
if (style) {
return style[key];
}
},
setExtra: function (key, val) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var extra = tmpDuringScope.el.extra || (tmpDuringScope.el.extra = {});
extra[key] = val;
return this;
},
getExtra: function (key) {
if (process.env.NODE_ENV !== 'production') {
assertNotReserved(key);
}
var extra = tmpDuringScope.el.extra;
if (extra) {
return extra[key];
}
}
};
function assertNotReserved(key) {
if (process.env.NODE_ENV !== 'production') {
if (key === 'transition' || key === 'enterFrom' || key === 'leaveTo') {
throw new Error('key must not be "' + key + '"');
}
}
}
function duringCall() {
// Do not provide "percent" until some requirements come.
// Because consider thies case:
// enterFrom: {x: 100, y: 30}, transition: 'x'.
// And enter duration is different from update duration.
// Thus it might be confused about the meaning of "percent" in during callback.
var scope = this;
var el = scope.el;
if (!el) {
return;
}
// If el is remove from zr by reason like legend, during still need to called,
// because el will be added back to zr and the prop value should not be incorrect.
var latestUserDuring = transitionInnerStore(el).userDuring;
var scopeUserDuring = scope.userDuring;
// Ensured a during is only called once in each animation frame.
// If a during is called multiple times in one frame, maybe some users' calculation logic
// might be wrong (not sure whether this usage exists).
// The case of a during might be called twice can be: by default there is a animator for
// 'x', 'y' when init. Before the init animation finished, call `setOption` to start
// another animators for 'style'/'shape'/'extra'.
if (latestUserDuring !== scopeUserDuring) {
// release
scope.el = scope.userDuring = null;
return;
}
tmpDuringScope.el = el;
// Give no `this` to user in "during" calling.
scopeUserDuring(transitionDuringAPI);
// FIXME: if in future meet the case that some prop will be both modified in `during` and `state`,
// consider the issue that the prop might be incorrect when return to "normal" state.
}
function prepareShapeOrExtraTransitionFrom(mainAttr, fromEl, elOption, transFromProps) {
var attrOpt = elOption[mainAttr];
if (!attrOpt) {
return;
}
var elPropsInAttr = fromEl[mainAttr];
var transFromPropsInAttr;
if (elPropsInAttr) {
var transition = elOption.transition;
var attrTransition = attrOpt.transition;
if (attrTransition) {
!transFromPropsInAttr && (transFromPropsInAttr = transFromProps[mainAttr] = {});
if (isTransitionAll(attrTransition)) {
extend(transFromPropsInAttr, elPropsInAttr);
} else {
var transitionKeys = normalizeToArray(attrTransition);
for (var i = 0; i < transitionKeys.length; i++) {
var key = transitionKeys[i];
var elVal = elPropsInAttr[key];
transFromPropsInAttr[key] = elVal;
}
}
} else if (isTransitionAll(transition) || indexOf(transition, mainAttr) >= 0) {
!transFromPropsInAttr && (transFromPropsInAttr = transFromProps[mainAttr] = {});
var elPropsInAttrKeys = keys(elPropsInAttr);
for (var i = 0; i < elPropsInAttrKeys.length; i++) {
var key = elPropsInAttrKeys[i];
var elVal = elPropsInAttr[key];
if (isNonStyleTransitionEnabled(attrOpt[key], elVal)) {
transFromPropsInAttr[key] = elVal;
}
}
}
}
}
function prepareShapeOrExtraAllPropsFinal(mainAttr, elOption, allProps) {
var attrOpt = elOption[mainAttr];
if (!attrOpt) {
return;
}
var allPropsInAttr = allProps[mainAttr] = {};
var keysInAttr = keys(attrOpt);
for (var i = 0; i < keysInAttr.length; i++) {
var key = keysInAttr[i];
// To avoid share one object with different element, and
// to avoid user modify the object inexpectedly, have to clone.
allPropsInAttr[key] = cloneValue(attrOpt[key]);
}
}
function prepareTransformTransitionFrom(el, elOption, transFromProps) {
var transition = elOption.transition;
var transitionKeys = isTransitionAll(transition) ? TRANSFORMABLE_PROPS : normalizeToArray(transition || []);
for (var i = 0; i < transitionKeys.length; i++) {
var key = transitionKeys[i];
if (key === 'style' || key === 'shape' || key === 'extra') {
continue;
}
var elVal = el[key];
if (process.env.NODE_ENV !== 'production') {
checkTransformPropRefer(key, 'el.transition');
}
// Do not clone, animator will perform that clone.
transFromProps[key] = elVal;
}
}
function prepareTransformAllPropsFinal(el, elOption, allProps) {
for (var i = 0; i < LEGACY_TRANSFORM_PROPS.length; i++) {
var legacyName = LEGACY_TRANSFORM_PROPS[i];
var xyName = LEGACY_TRANSFORM_PROPS_MAP[legacyName];
var legacyArr = elOption[legacyName];
if (legacyArr) {
allProps[xyName[0]] = legacyArr[0];
allProps[xyName[1]] = legacyArr[1];
}
}
for (var i = 0; i < TRANSFORMABLE_PROPS.length; i++) {
var key = TRANSFORMABLE_PROPS[i];
if (elOption[key] != null) {
allProps[key] = elOption[key];
}
}
}
function prepareStyleTransitionFrom(fromEl, elOption, styleOpt, transFromProps) {
if (!styleOpt) {
return;
}
var fromElStyle = fromEl.style;
var transFromStyleProps;
if (fromElStyle) {
var styleTransition = styleOpt.transition;
var elTransition = elOption.transition;
if (styleTransition && !isTransitionAll(styleTransition)) {
var transitionKeys = normalizeToArray(styleTransition);
!transFromStyleProps && (transFromStyleProps = transFromProps.style = {});
for (var i = 0; i < transitionKeys.length; i++) {
var key = transitionKeys[i];
var elVal = fromElStyle[key];
// Do not clone, see `checkNonStyleTansitionRefer`.
transFromStyleProps[key] = elVal;
}
} else if (fromEl.getAnimationStyleProps && (isTransitionAll(elTransition) || isTransitionAll(styleTransition) || indexOf(elTransition, 'style') >= 0)) {
var animationProps = fromEl.getAnimationStyleProps();
var animationStyleProps = animationProps ? animationProps.style : null;
if (animationStyleProps) {
!transFromStyleProps && (transFromStyleProps = transFromProps.style = {});
var styleKeys = keys(styleOpt);
for (var i = 0; i < styleKeys.length; i++) {
var key = styleKeys[i];
if (animationStyleProps[key]) {
var elVal = fromElStyle[key];
transFromStyleProps[key] = elVal;
}
}
}
}
}
}
function isNonStyleTransitionEnabled(optVal, elVal) {
// The same as `checkNonStyleTansitionRefer`.
return !isArrayLike(optVal) ? optVal != null && isFinite(optVal) : optVal !== elVal;
}
var checkTransformPropRefer;
if (process.env.NODE_ENV !== 'production') {
checkTransformPropRefer = function (key, usedIn) {
if (!hasOwn(TRANSFORM_PROPS_MAP, key)) {
warn('Prop `' + key + '` is not a permitted in `' + usedIn + '`. ' + 'Only `' + keys(TRANSFORM_PROPS_MAP).join('`, `') + '` are permitted.');
}
};
}

View File

@ -0,0 +1,203 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { separateMorph, combineMorph, morphPath, isCombineMorphing } from 'zrender/lib/tool/morphPath.js';
import { Path } from '../util/graphic.js';
import { defaults, isArray } from 'zrender/lib/core/util.js';
import { getAnimationConfig } from './basicTransition.js';
import { clonePath } from 'zrender/lib/tool/path.js';
function isMultiple(elements) {
return isArray(elements[0]);
}
function prepareMorphBatches(one, many) {
var batches = [];
var batchCount = one.length;
for (var i = 0; i < batchCount; i++) {
batches.push({
one: one[i],
many: []
});
}
for (var i = 0; i < many.length; i++) {
var len = many[i].length;
var k = void 0;
for (k = 0; k < len; k++) {
batches[k % batchCount].many.push(many[i][k]);
}
}
var off = 0;
// If one has more paths than each one of many. average them.
for (var i = batchCount - 1; i >= 0; i--) {
if (!batches[i].many.length) {
var moveFrom = batches[off].many;
if (moveFrom.length <= 1) {
// Not enough
// Start from the first one.
if (off) {
off = 0;
} else {
return batches;
}
}
var len = moveFrom.length;
var mid = Math.ceil(len / 2);
batches[i].many = moveFrom.slice(mid, len);
batches[off].many = moveFrom.slice(0, mid);
off++;
}
}
return batches;
}
var pathDividers = {
clone: function (params) {
var ret = [];
// Fitting the alpha
var approxOpacity = 1 - Math.pow(1 - params.path.style.opacity, 1 / params.count);
for (var i = 0; i < params.count; i++) {
var cloned = clonePath(params.path);
cloned.setStyle('opacity', approxOpacity);
ret.push(cloned);
}
return ret;
},
// Use the default divider
split: null
};
export function applyMorphAnimation(from, to, divideShape, seriesModel, dataIndex, animateOtherProps) {
if (!from.length || !to.length) {
return;
}
var updateAnimationCfg = getAnimationConfig('update', seriesModel, dataIndex);
if (!(updateAnimationCfg && updateAnimationCfg.duration > 0)) {
return;
}
var animationDelay = seriesModel.getModel('universalTransition').get('delay');
var animationCfg = Object.assign({
// Need to setToFinal so the further calculation based on the style can be correct.
// Like emphasis color.
setToFinal: true
}, updateAnimationCfg);
var many;
var one;
if (isMultiple(from)) {
// manyToOne
many = from;
one = to;
}
if (isMultiple(to)) {
// oneToMany
many = to;
one = from;
}
function morphOneBatch(batch, fromIsMany, animateIndex, animateCount, forceManyOne) {
var batchMany = batch.many;
var batchOne = batch.one;
if (batchMany.length === 1 && !forceManyOne) {
// Is one to one
var batchFrom = fromIsMany ? batchMany[0] : batchOne;
var batchTo = fromIsMany ? batchOne : batchMany[0];
if (isCombineMorphing(batchFrom)) {
// Keep doing combine animation.
morphOneBatch({
many: [batchFrom],
one: batchTo
}, true, animateIndex, animateCount, true);
} else {
var individualAnimationCfg = animationDelay ? defaults({
delay: animationDelay(animateIndex, animateCount)
}, animationCfg) : animationCfg;
morphPath(batchFrom, batchTo, individualAnimationCfg);
animateOtherProps(batchFrom, batchTo, batchFrom, batchTo, individualAnimationCfg);
}
} else {
var separateAnimationCfg = defaults({
dividePath: pathDividers[divideShape],
individualDelay: animationDelay && function (idx, count, fromPath, toPath) {
return animationDelay(idx + animateIndex, animateCount);
}
}, animationCfg);
var _a = fromIsMany ? combineMorph(batchMany, batchOne, separateAnimationCfg) : separateMorph(batchOne, batchMany, separateAnimationCfg),
fromIndividuals = _a.fromIndividuals,
toIndividuals = _a.toIndividuals;
var count = fromIndividuals.length;
for (var k = 0; k < count; k++) {
var individualAnimationCfg = animationDelay ? defaults({
delay: animationDelay(k, count)
}, animationCfg) : animationCfg;
animateOtherProps(fromIndividuals[k], toIndividuals[k], fromIsMany ? batchMany[k] : batch.one, fromIsMany ? batch.one : batchMany[k], individualAnimationCfg);
}
}
}
var fromIsMany = many ? many === from
// Is one to one. If the path number not match. also needs do merge and separate morphing.
: from.length > to.length;
var morphBatches = many ? prepareMorphBatches(one, many) : prepareMorphBatches(fromIsMany ? to : from, [fromIsMany ? from : to]);
var animateCount = 0;
for (var i = 0; i < morphBatches.length; i++) {
animateCount += morphBatches[i].many.length;
}
var animateIndex = 0;
for (var i = 0; i < morphBatches.length; i++) {
morphOneBatch(morphBatches[i], fromIsMany, animateIndex, animateCount);
animateIndex += morphBatches[i].many.length;
}
}
export function getPathList(elements) {
if (!elements) {
return [];
}
if (isArray(elements)) {
var pathList_1 = [];
for (var i = 0; i < elements.length; i++) {
pathList_1.push(getPathList(elements[i]));
}
return pathList_1;
}
var pathList = [];
elements.traverse(function (el) {
if (el instanceof Path && !el.disableMorphing && !el.invisible && !el.ignore) {
pathList.push(el);
}
});
return pathList;
}

View File

@ -0,0 +1,649 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
// Universal transitions that can animate between any shapes(series) and any properties in any amounts.
import { SERIES_UNIVERSAL_TRANSITION_PROP } from '../model/Series.js';
import { createHashMap, each, map, filter, isArray, extend } from 'zrender/lib/core/util.js';
import { applyMorphAnimation, getPathList } from './morphTransitionHelper.js';
import Path from 'zrender/lib/graphic/Path.js';
import { initProps } from '../util/graphic.js';
import DataDiffer from '../data/DataDiffer.js';
import { makeInner, normalizeToArray } from '../util/model.js';
import { warn } from '../util/log.js';
import { getAnimationConfig, getOldStyle } from './basicTransition.js';
import Displayable from 'zrender/lib/graphic/Displayable.js';
var DATA_COUNT_THRESHOLD = 1e4;
var TRANSITION_NONE = 0;
var TRANSITION_P2C = 1;
var TRANSITION_C2P = 2;
;
var getUniversalTransitionGlobalStore = makeInner();
function getDimension(data, visualDimension) {
var dimensions = data.dimensions;
for (var i = 0; i < dimensions.length; i++) {
var dimInfo = data.getDimensionInfo(dimensions[i]);
if (dimInfo && dimInfo.otherDims[visualDimension] === 0) {
return dimensions[i];
}
}
}
// get value by dimension. (only get value of itemGroupId or childGroupId, so convert it to string)
function getValueByDimension(data, dataIndex, dimension) {
var dimInfo = data.getDimensionInfo(dimension);
var dimOrdinalMeta = dimInfo && dimInfo.ordinalMeta;
if (dimInfo) {
var value = data.get(dimInfo.name, dataIndex);
if (dimOrdinalMeta) {
return dimOrdinalMeta.categories[value] || value + '';
}
return value + '';
}
}
function getGroupId(data, dataIndex, dataGroupId, isChild) {
// try to get groupId from encode
var visualDimension = isChild ? 'itemChildGroupId' : 'itemGroupId';
var groupIdDim = getDimension(data, visualDimension);
if (groupIdDim) {
var groupId = getValueByDimension(data, dataIndex, groupIdDim);
return groupId;
}
// try to get groupId from raw data item
var rawDataItem = data.getRawDataItem(dataIndex);
var property = isChild ? 'childGroupId' : 'groupId';
if (rawDataItem && rawDataItem[property]) {
return rawDataItem[property] + '';
}
// fallback
if (isChild) {
return;
}
// try to use series.dataGroupId as groupId, otherwise use dataItem's id as groupId
return dataGroupId || data.getId(dataIndex);
}
// flatten all data items from different serieses into one arrary
function flattenDataDiffItems(list) {
var items = [];
each(list, function (seriesInfo) {
var data = seriesInfo.data;
var dataGroupId = seriesInfo.dataGroupId;
if (data.count() > DATA_COUNT_THRESHOLD) {
if (process.env.NODE_ENV !== 'production') {
warn('Universal transition is disabled on large data > 10k.');
}
return;
}
var indices = data.getIndices();
for (var dataIndex = 0; dataIndex < indices.length; dataIndex++) {
items.push({
data: data,
groupId: getGroupId(data, dataIndex, dataGroupId, false),
childGroupId: getGroupId(data, dataIndex, dataGroupId, true),
divide: seriesInfo.divide,
dataIndex: dataIndex
});
}
});
return items;
}
function fadeInElement(newEl, newSeries, newIndex) {
newEl.traverse(function (el) {
if (el instanceof Path) {
// TODO use fade in animation for target element.
initProps(el, {
style: {
opacity: 0
}
}, newSeries, {
dataIndex: newIndex,
isFrom: true
});
}
});
}
function removeEl(el) {
if (el.parent) {
// Bake parent transform to element.
// So it can still have proper transform to transition after it's removed.
var computedTransform = el.getComputedTransform();
el.setLocalTransform(computedTransform);
el.parent.remove(el);
}
}
function stopAnimation(el) {
el.stopAnimation();
if (el.isGroup) {
el.traverse(function (child) {
child.stopAnimation();
});
}
}
function animateElementStyles(el, dataIndex, seriesModel) {
var animationConfig = getAnimationConfig('update', seriesModel, dataIndex);
animationConfig && el.traverse(function (child) {
if (child instanceof Displayable) {
var oldStyle = getOldStyle(child);
if (oldStyle) {
child.animateFrom({
style: oldStyle
}, animationConfig);
}
}
});
}
function isAllIdSame(oldDiffItems, newDiffItems) {
var len = oldDiffItems.length;
if (len !== newDiffItems.length) {
return false;
}
for (var i = 0; i < len; i++) {
var oldItem = oldDiffItems[i];
var newItem = newDiffItems[i];
if (oldItem.data.getId(oldItem.dataIndex) !== newItem.data.getId(newItem.dataIndex)) {
return false;
}
}
return true;
}
function transitionBetween(oldList, newList, api) {
var oldDiffItems = flattenDataDiffItems(oldList);
var newDiffItems = flattenDataDiffItems(newList);
function updateMorphingPathProps(from, to, rawFrom, rawTo, animationCfg) {
if (rawFrom || from) {
to.animateFrom({
style: rawFrom && rawFrom !== from
// dividingMethod like clone may override the style(opacity)
// So extend it to raw style.
? extend(extend({}, rawFrom.style), from.style) : from.style
}, animationCfg);
}
}
var hasMorphAnimation = false;
/**
* With groupId and childGroupId, we can build parent-child relationships between dataItems.
* However, we should mind the parent-child "direction" between old and new options.
*
* For example, suppose we have two dataItems from two series.data:
*
* dataA: [ dataB: [
* { {
* value: 5, value: 3,
* groupId: 'creatures', groupId: 'animals',
* childGroupId: 'animals' childGroupId: 'dogs'
* }, },
* ... ...
* ] ]
*
* where dataA is belong to optionA and dataB is belong to optionB.
*
* When we `setOption(optionB)` from optionA, we choose childGroupId of dataItemA and groupId of
* dataItemB as keys so the two keys are matched (both are 'animals'), then universalTransition
* will work. This derection is "parent -> child".
*
* If we `setOption(optionA)` from optionB, we also choose groupId of dataItemB and childGroupId
* of dataItemA as keys and universalTransition will work. This derection is "child -> parent".
*
* If there is no childGroupId specified, which means no multiLevelDrillDown/Up is needed and no
* parent-child relationship exists. This direction is "none".
*
* So we need to know whether to use groupId or childGroupId as the key when we call the keyGetter
* functions. Thus, we need to decide the direction first.
*
* The rule is:
*
* if (all childGroupIds in oldDiffItems and all groupIds in newDiffItems have common value) {
* direction = 'parent -> child';
* } else if (all groupIds in oldDiffItems and all childGroupIds in newDiffItems have common value) {
* direction = 'child -> parent';
* } else {
* direction = 'none';
* }
*/
var direction = TRANSITION_NONE;
// find all groupIds and childGroupIds from oldDiffItems
var oldGroupIds = createHashMap();
var oldChildGroupIds = createHashMap();
oldDiffItems.forEach(function (item) {
item.groupId && oldGroupIds.set(item.groupId, true);
item.childGroupId && oldChildGroupIds.set(item.childGroupId, true);
});
// traverse newDiffItems and decide the direction according to the rule
for (var i = 0; i < newDiffItems.length; i++) {
var newGroupId = newDiffItems[i].groupId;
if (oldChildGroupIds.get(newGroupId)) {
direction = TRANSITION_P2C;
break;
}
var newChildGroupId = newDiffItems[i].childGroupId;
if (newChildGroupId && oldGroupIds.get(newChildGroupId)) {
direction = TRANSITION_C2P;
break;
}
}
function createKeyGetter(isOld, onlyGetId) {
return function (diffItem) {
var data = diffItem.data;
var dataIndex = diffItem.dataIndex;
// TODO if specified dim
if (onlyGetId) {
return data.getId(dataIndex);
}
if (isOld) {
return direction === TRANSITION_P2C ? diffItem.childGroupId : diffItem.groupId;
} else {
return direction === TRANSITION_C2P ? diffItem.childGroupId : diffItem.groupId;
}
};
}
// Use id if it's very likely to be an one to one animation
// It's more robust than groupId
// TODO Check if key dimension is specified.
var useId = isAllIdSame(oldDiffItems, newDiffItems);
var isElementStillInChart = {};
if (!useId) {
// We may have different diff strategy with basicTransition if we use other dimension as key.
// If so, we can't simply check if oldEl is same with newEl. We need a map to check if oldEl is still being used in the new chart.
// We can't use the elements that already being morphed. Let it keep it's original basic transition.
for (var i = 0; i < newDiffItems.length; i++) {
var newItem = newDiffItems[i];
var el = newItem.data.getItemGraphicEl(newItem.dataIndex);
if (el) {
isElementStillInChart[el.id] = true;
}
}
}
function updateOneToOne(newIndex, oldIndex) {
var oldItem = oldDiffItems[oldIndex];
var newItem = newDiffItems[newIndex];
var newSeries = newItem.data.hostModel;
// TODO Mark this elements is morphed and don't morph them anymore
var oldEl = oldItem.data.getItemGraphicEl(oldItem.dataIndex);
var newEl = newItem.data.getItemGraphicEl(newItem.dataIndex);
// Can't handle same elements.
if (oldEl === newEl) {
newEl && animateElementStyles(newEl, newItem.dataIndex, newSeries);
return;
}
if (
// We can't use the elements that already being morphed
oldEl && isElementStillInChart[oldEl.id]) {
return;
}
if (newEl) {
// TODO: If keep animating the group in case
// some of the elements don't want to be morphed.
// TODO Label?
stopAnimation(newEl);
if (oldEl) {
stopAnimation(oldEl);
// If old element is doing leaving animation. stop it and remove it immediately.
removeEl(oldEl);
hasMorphAnimation = true;
applyMorphAnimation(getPathList(oldEl), getPathList(newEl), newItem.divide, newSeries, newIndex, updateMorphingPathProps);
} else {
fadeInElement(newEl, newSeries, newIndex);
}
}
// else keep oldEl leaving animation.
}
new DataDiffer(oldDiffItems, newDiffItems, createKeyGetter(true, useId), createKeyGetter(false, useId), null, 'multiple').update(updateOneToOne).updateManyToOne(function (newIndex, oldIndices) {
var newItem = newDiffItems[newIndex];
var newData = newItem.data;
var newSeries = newData.hostModel;
var newEl = newData.getItemGraphicEl(newItem.dataIndex);
var oldElsList = filter(map(oldIndices, function (idx) {
return oldDiffItems[idx].data.getItemGraphicEl(oldDiffItems[idx].dataIndex);
}), function (oldEl) {
return oldEl && oldEl !== newEl && !isElementStillInChart[oldEl.id];
});
if (newEl) {
stopAnimation(newEl);
if (oldElsList.length) {
// If old element is doing leaving animation. stop it and remove it immediately.
each(oldElsList, function (oldEl) {
stopAnimation(oldEl);
removeEl(oldEl);
});
hasMorphAnimation = true;
applyMorphAnimation(getPathList(oldElsList), getPathList(newEl), newItem.divide, newSeries, newIndex, updateMorphingPathProps);
} else {
fadeInElement(newEl, newSeries, newItem.dataIndex);
}
}
// else keep oldEl leaving animation.
}).updateOneToMany(function (newIndices, oldIndex) {
var oldItem = oldDiffItems[oldIndex];
var oldEl = oldItem.data.getItemGraphicEl(oldItem.dataIndex);
// We can't use the elements that already being morphed
if (oldEl && isElementStillInChart[oldEl.id]) {
return;
}
var newElsList = filter(map(newIndices, function (idx) {
return newDiffItems[idx].data.getItemGraphicEl(newDiffItems[idx].dataIndex);
}), function (el) {
return el && el !== oldEl;
});
var newSeris = newDiffItems[newIndices[0]].data.hostModel;
if (newElsList.length) {
each(newElsList, function (newEl) {
return stopAnimation(newEl);
});
if (oldEl) {
stopAnimation(oldEl);
// If old element is doing leaving animation. stop it and remove it immediately.
removeEl(oldEl);
hasMorphAnimation = true;
applyMorphAnimation(getPathList(oldEl), getPathList(newElsList), oldItem.divide,
// Use divide on old.
newSeris, newIndices[0], updateMorphingPathProps);
} else {
each(newElsList, function (newEl) {
return fadeInElement(newEl, newSeris, newIndices[0]);
});
}
}
// else keep oldEl leaving animation.
}).updateManyToMany(function (newIndices, oldIndices) {
// If two data are same and both have groupId.
// Normally they should be diff by id.
new DataDiffer(oldIndices, newIndices, function (rawIdx) {
return oldDiffItems[rawIdx].data.getId(oldDiffItems[rawIdx].dataIndex);
}, function (rawIdx) {
return newDiffItems[rawIdx].data.getId(newDiffItems[rawIdx].dataIndex);
}).update(function (newIndex, oldIndex) {
// Use the original index
updateOneToOne(newIndices[newIndex], oldIndices[oldIndex]);
}).execute();
}).execute();
if (hasMorphAnimation) {
each(newList, function (_a) {
var data = _a.data;
var seriesModel = data.hostModel;
var view = seriesModel && api.getViewOfSeriesModel(seriesModel);
var animationCfg = getAnimationConfig('update', seriesModel, 0); // use 0 index.
if (view && seriesModel.isAnimationEnabled() && animationCfg && animationCfg.duration > 0) {
view.group.traverse(function (el) {
if (el instanceof Path && !el.animators.length) {
// We can't accept there still exists element that has no animation
// if universalTransition is enabled
el.animateFrom({
style: {
opacity: 0
}
}, animationCfg);
}
});
}
});
}
}
function getSeriesTransitionKey(series) {
var seriesKey = series.getModel('universalTransition').get('seriesKey');
if (!seriesKey) {
// Use series id by default.
return series.id;
}
return seriesKey;
}
function convertArraySeriesKeyToString(seriesKey) {
if (isArray(seriesKey)) {
// Order independent.
return seriesKey.sort().join(',');
}
return seriesKey;
}
function getDivideShapeFromData(data) {
if (data.hostModel) {
return data.hostModel.getModel('universalTransition').get('divideShape');
}
}
function findTransitionSeriesBatches(globalStore, params) {
var updateBatches = createHashMap();
var oldDataMap = createHashMap();
// Map that only store key in array seriesKey.
// Which is used to query the old data when transition from one to multiple series.
var oldDataMapForSplit = createHashMap();
each(globalStore.oldSeries, function (series, idx) {
var oldDataGroupId = globalStore.oldDataGroupIds[idx];
var oldData = globalStore.oldData[idx];
var transitionKey = getSeriesTransitionKey(series);
var transitionKeyStr = convertArraySeriesKeyToString(transitionKey);
oldDataMap.set(transitionKeyStr, {
dataGroupId: oldDataGroupId,
data: oldData
});
if (isArray(transitionKey)) {
// Same key can't in different array seriesKey.
each(transitionKey, function (key) {
oldDataMapForSplit.set(key, {
key: transitionKeyStr,
dataGroupId: oldDataGroupId,
data: oldData
});
});
}
});
function checkTransitionSeriesKeyDuplicated(transitionKeyStr) {
if (updateBatches.get(transitionKeyStr)) {
warn("Duplicated seriesKey in universalTransition " + transitionKeyStr);
}
}
each(params.updatedSeries, function (series) {
if (series.isUniversalTransitionEnabled() && series.isAnimationEnabled()) {
var newDataGroupId = series.get('dataGroupId');
var newData = series.getData();
var transitionKey = getSeriesTransitionKey(series);
var transitionKeyStr = convertArraySeriesKeyToString(transitionKey);
// Only transition between series with same id.
var oldData = oldDataMap.get(transitionKeyStr);
// string transition key is the best match.
if (oldData) {
if (process.env.NODE_ENV !== 'production') {
checkTransitionSeriesKeyDuplicated(transitionKeyStr);
}
// TODO check if data is same?
updateBatches.set(transitionKeyStr, {
oldSeries: [{
dataGroupId: oldData.dataGroupId,
divide: getDivideShapeFromData(oldData.data),
data: oldData.data
}],
newSeries: [{
dataGroupId: newDataGroupId,
divide: getDivideShapeFromData(newData),
data: newData
}]
});
} else {
// Transition from multiple series.
// e.g. 'female', 'male' -> ['female', 'male']
if (isArray(transitionKey)) {
if (process.env.NODE_ENV !== 'production') {
checkTransitionSeriesKeyDuplicated(transitionKeyStr);
}
var oldSeries_1 = [];
each(transitionKey, function (key) {
var oldData = oldDataMap.get(key);
if (oldData.data) {
oldSeries_1.push({
dataGroupId: oldData.dataGroupId,
divide: getDivideShapeFromData(oldData.data),
data: oldData.data
});
}
});
if (oldSeries_1.length) {
updateBatches.set(transitionKeyStr, {
oldSeries: oldSeries_1,
newSeries: [{
dataGroupId: newDataGroupId,
data: newData,
divide: getDivideShapeFromData(newData)
}]
});
}
} else {
// Try transition to multiple series.
// e.g. ['female', 'male'] -> 'female', 'male'
var oldData_1 = oldDataMapForSplit.get(transitionKey);
if (oldData_1) {
var batch = updateBatches.get(oldData_1.key);
if (!batch) {
batch = {
oldSeries: [{
dataGroupId: oldData_1.dataGroupId,
data: oldData_1.data,
divide: getDivideShapeFromData(oldData_1.data)
}],
newSeries: []
};
updateBatches.set(oldData_1.key, batch);
}
batch.newSeries.push({
dataGroupId: newDataGroupId,
data: newData,
divide: getDivideShapeFromData(newData)
});
}
}
}
}
});
return updateBatches;
}
function querySeries(series, finder) {
for (var i = 0; i < series.length; i++) {
var found = finder.seriesIndex != null && finder.seriesIndex === series[i].seriesIndex || finder.seriesId != null && finder.seriesId === series[i].id;
if (found) {
return i;
}
}
}
function transitionSeriesFromOpt(transitionOpt, globalStore, params, api) {
var from = [];
var to = [];
each(normalizeToArray(transitionOpt.from), function (finder) {
var idx = querySeries(globalStore.oldSeries, finder);
if (idx >= 0) {
from.push({
dataGroupId: globalStore.oldDataGroupIds[idx],
data: globalStore.oldData[idx],
// TODO can specify divideShape in transition.
divide: getDivideShapeFromData(globalStore.oldData[idx]),
groupIdDim: finder.dimension
});
}
});
each(normalizeToArray(transitionOpt.to), function (finder) {
var idx = querySeries(params.updatedSeries, finder);
if (idx >= 0) {
var data = params.updatedSeries[idx].getData();
to.push({
dataGroupId: globalStore.oldDataGroupIds[idx],
data: data,
divide: getDivideShapeFromData(data),
groupIdDim: finder.dimension
});
}
});
if (from.length > 0 && to.length > 0) {
transitionBetween(from, to, api);
}
}
export function installUniversalTransition(registers) {
registers.registerUpdateLifecycle('series:beforeupdate', function (ecMOdel, api, params) {
each(normalizeToArray(params.seriesTransition), function (transOpt) {
each(normalizeToArray(transOpt.to), function (finder) {
var series = params.updatedSeries;
for (var i = 0; i < series.length; i++) {
if (finder.seriesIndex != null && finder.seriesIndex === series[i].seriesIndex || finder.seriesId != null && finder.seriesId === series[i].id) {
series[i][SERIES_UNIVERSAL_TRANSITION_PROP] = true;
}
}
});
});
});
registers.registerUpdateLifecycle('series:transition', function (ecModel, api, params) {
// TODO api provide an namespace that can save stuff per instance
var globalStore = getUniversalTransitionGlobalStore(api);
// TODO multiple to multiple series.
if (globalStore.oldSeries && params.updatedSeries && params.optionChanged) {
// TODO transitionOpt was used in an old implementation and can be removed now
// Use give transition config if its' give;
var transitionOpt = params.seriesTransition;
if (transitionOpt) {
each(normalizeToArray(transitionOpt), function (opt) {
transitionSeriesFromOpt(opt, globalStore, params, api);
});
} else {
// Else guess from series based on transition series key.
var updateBatches_1 = findTransitionSeriesBatches(globalStore, params);
each(updateBatches_1.keys(), function (key) {
var batch = updateBatches_1.get(key);
transitionBetween(batch.oldSeries, batch.newSeries, api);
});
}
// Reset
each(params.updatedSeries, function (series) {
// Reset;
if (series[SERIES_UNIVERSAL_TRANSITION_PROP]) {
series[SERIES_UNIVERSAL_TRANSITION_PROP] = false;
}
});
}
// Save all series of current update. Not only the updated one.
var allSeries = ecModel.getSeries();
var savedSeries = globalStore.oldSeries = [];
var savedDataGroupIds = globalStore.oldDataGroupIds = [];
var savedData = globalStore.oldData = [];
for (var i = 0; i < allSeries.length; i++) {
var data = allSeries[i].getData();
// Only save the data that can have transition.
// Avoid large data costing too much extra memory
if (data.count() < DATA_COUNT_THRESHOLD) {
savedSeries.push(allSeries[i]);
savedDataGroupIds.push(allSeries[i].get('dataGroupId'));
savedData.push(data);
}
}
});
}

46
frontend/node_modules/echarts/lib/chart/bar.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './bar/install.js';
use(install);

View File

@ -0,0 +1,112 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import BaseBarSeriesModel from './BaseBarSeries.js';
import createSeriesData from '../helper/createSeriesData.js';
import { inheritDefaultOption } from '../../util/component.js';
var BarSeriesModel = /** @class */function (_super) {
__extends(BarSeriesModel, _super);
function BarSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = BarSeriesModel.type;
return _this;
}
BarSeriesModel.prototype.getInitialData = function () {
return createSeriesData(null, this, {
useEncodeDefaulter: true,
createInvertedIndices: !!this.get('realtimeSort', true) || null
});
};
/**
* @override
*/
BarSeriesModel.prototype.getProgressive = function () {
// Do not support progressive in normal mode.
return this.get('large') ? this.get('progressive') : false;
};
/**
* @override
*/
BarSeriesModel.prototype.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;
};
BarSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
return selectors.rect(data.getItemLayout(dataIndex));
};
BarSeriesModel.type = 'series.bar';
BarSeriesModel.dependencies = ['grid', 'polar'];
BarSeriesModel.defaultOption = inheritDefaultOption(BaseBarSeriesModel.defaultOption, {
// If clipped
// Only available on cartesian2d
clip: true,
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
},
select: {
itemStyle: {
borderColor: '#212121'
}
},
realtimeSort: false
});
return BarSeriesModel;
}(BaseBarSeriesModel);
export default BarSeriesModel;

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

@ -0,0 +1,894 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import Path from 'zrender/lib/graphic/Path.js';
import Group from 'zrender/lib/graphic/Group.js';
import { extend, each, map } from 'zrender/lib/core/util.js';
import { Rect, Sector, updateProps, initProps, removeElementWithFadeOut, traverseElements } from '../../util/graphic.js';
import { getECData } from '../../util/innerStore.js';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
import { setLabelStyle, getLabelStatesModels, setLabelValueAnimation, labelInner } from '../../label/labelStyle.js';
import { throttle } from '../../util/throttle.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import Sausage from '../../util/shape/sausage.js';
import ChartView from '../../view/Chart.js';
import { isCoordinateSystemType } from '../../coord/CoordinateSystem.js';
import { getDefaultLabel, getDefaultInterpolatedLabel } from '../helper/labelHelper.js';
import { warn } from '../../util/log.js';
import { createSectorCalculateTextPosition, setSectorTextRotation } from '../../label/sectorLabel.js';
import { saveOldStyle } from '../../animation/basicTransition.js';
import { getSectorCornerRadius } from '../helper/sectorHelper.js';
var mathMax = Math.max;
var mathMin = Math.min;
function getClipArea(coord, data) {
var coordSysClipArea = coord.getArea && coord.getArea();
if (isCoordinateSystemType(coord, '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 BarView = /** @class */function (_super) {
__extends(BarView, _super);
function BarView() {
var _this = _super.call(this) || this;
_this.type = BarView.type;
_this._isFirstFrame = true;
return _this;
}
BarView.prototype.render = function (seriesModel, ecModel, api, payload) {
this._model = seriesModel;
this._removeOnRenderedListener(api);
this._updateDrawMode(seriesModel);
var coordinateSystemType = seriesModel.get('coordinateSystem');
if (coordinateSystemType === 'cartesian2d' || coordinateSystemType === 'polar') {
// Clear previously rendered progressive elements.
this._progressiveEls = null;
this._isLargeDraw ? this._renderLarge(seriesModel, ecModel, api) : this._renderNormal(seriesModel, ecModel, api, payload);
} else if (process.env.NODE_ENV !== 'production') {
warn('Only cartesian2d and polar supported for bar.');
}
};
BarView.prototype.incrementalPrepareRender = function (seriesModel) {
this._clear();
this._updateDrawMode(seriesModel);
// incremental also need to clip, otherwise might be overlow.
// But must not set clip in each frame, otherwise all of the children will be marked redraw.
this._updateLargeClip(seriesModel);
};
BarView.prototype.incrementalRender = function (params, seriesModel) {
// Reset
this._progressiveEls = [];
// Do not support progressive in normal mode.
this._incrementalRenderLarge(params, seriesModel);
};
BarView.prototype.eachRendered = function (cb) {
traverseElements(this._progressiveEls || this.group, cb);
};
BarView.prototype._updateDrawMode = function (seriesModel) {
var isLargeDraw = seriesModel.pipelineContext.large;
if (this._isLargeDraw == null || isLargeDraw !== this._isLargeDraw) {
this._isLargeDraw = isLargeDraw;
this._clear();
}
};
BarView.prototype._renderNormal = function (seriesModel, ecModel, api, payload) {
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 realtimeSortCfg = shouldRealtimeSort(seriesModel, coord);
if (realtimeSortCfg) {
this._enableRealtimeSort(realtimeSortCfg, data, api);
}
var needsClip = seriesModel.get('clip', true) || realtimeSortCfg;
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('borderRadius') || 0;
var bgEls = [];
var oldBgEls = this._backgroundEls;
var isInitSort = payload && payload.isInitSort;
var isChangeOrder = payload && payload.type === 'changeAxisOrder';
function createBackground(dataIndex) {
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
} else {
bgEl.setShape('cornerRadius', 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) || !isValidLayout[coord.type](layout)) {
return;
}
var isClipped = false;
if (needsClip) {
// Clip will modify the layout params.
// And return a boolean to determine if the shape are fully clipped.
isClipped = clip[coord.type](coordSysClipArea, layout);
}
var el = elementCreator[coord.type](seriesModel, data, dataIndex, layout, isHorizontalOrRadial, animationModel, baseAxis.model, false, roundCap);
if (realtimeSortCfg) {
/**
* Force label animation because even if the element is
* ignored because it's clipped, it may not be clipped after
* changing order. Then, if not using forceLabelAnimation,
* the label animation was never started, in which case,
* the label will be the final value and doesn't have label
* animation.
*/
el.forceLabelAnimation = true;
}
updateStyle(el, data, dataIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, coord.type === 'polar');
if (isInitSort) {
el.attr({
shape: layout
});
} else if (realtimeSortCfg) {
updateRealtimeAnimation(realtimeSortCfg, animationModel, el, layout, dataIndex, isHorizontalOrRadial, false, false);
} else {
initProps(el, {
shape: layout
}, seriesModel, dataIndex);
}
data.setItemGraphicEl(dataIndex, el);
group.add(el);
el.ignore = isClipped;
}).update(function (newIndex, oldIndex) {
var itemModel = data.getItemModel(newIndex);
var layout = getLayout[coord.type](data, newIndex, itemModel);
if (drawBackground) {
var bgEl = void 0;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
} else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
bgEl.setShape('r', barBorderRadius);
} else {
bgEl.setShape('cornerRadius', barBorderRadius);
}
bgEls[newIndex] = bgEl;
}
var bgLayout = getLayout[coord.type](data, newIndex);
var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
updateProps(bgEl, {
shape: shape
}, animationModel, newIndex);
}
var el = oldData.getItemGraphicEl(oldIndex);
if (!data.hasValue(newIndex) || !isValidLayout[coord.type](layout)) {
group.remove(el);
return;
}
var isClipped = false;
if (needsClip) {
isClipped = clip[coord.type](coordSysClipArea, layout);
if (isClipped) {
group.remove(el);
}
}
if (!el) {
el = elementCreator[coord.type](seriesModel, data, newIndex, layout, isHorizontalOrRadial, animationModel, baseAxis.model, !!el, roundCap);
} else {
saveOldStyle(el);
}
if (realtimeSortCfg) {
el.forceLabelAnimation = true;
}
if (isChangeOrder) {
var textEl = el.getTextContent();
if (textEl) {
var labelInnerStore = labelInner(textEl);
if (labelInnerStore.prevValue != null) {
/**
* Set preValue to be value so that no new label
* should be started, otherwise, it will take a full
* `animationDurationUpdate` time to finish the
* animation, which is not expected.
*/
labelInnerStore.prevValue = labelInnerStore.value;
}
}
}
// Not change anything if only order changed.
// Especially not change label.
else {
updateStyle(el, data, newIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, coord.type === 'polar');
}
if (isInitSort) {
el.attr({
shape: layout
});
} else if (realtimeSortCfg) {
updateRealtimeAnimation(realtimeSortCfg, animationModel, el, layout, newIndex, isHorizontalOrRadial, true, isChangeOrder);
} else {
updateProps(el, {
shape: layout
}, seriesModel, newIndex, null);
}
data.setItemGraphicEl(newIndex, el);
el.ignore = isClipped;
group.add(el);
}).remove(function (dataIndex) {
var el = oldData.getItemGraphicEl(dataIndex);
el && removeElementWithFadeOut(el, seriesModel, dataIndex);
}).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;
};
BarView.prototype._renderLarge = function (seriesModel, ecModel, api) {
this._clear();
createLarge(seriesModel, this.group);
this._updateLargeClip(seriesModel);
};
BarView.prototype._incrementalRenderLarge = function (params, seriesModel) {
this._removeBackground();
createLarge(seriesModel, this.group, this._progressiveEls, true);
};
BarView.prototype._updateLargeClip = function (seriesModel) {
// Use clipPath in large mode.
var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
var group = this.group;
if (clipPath) {
group.setClipPath(clipPath);
} else {
group.removeClipPath();
}
};
BarView.prototype._enableRealtimeSort = function (realtimeSortCfg, data, api) {
var _this = this;
// If no data in the first frame, wait for data to initSort
if (!data.count()) {
return;
}
var baseAxis = realtimeSortCfg.baseAxis;
if (this._isFirstFrame) {
this._dispatchInitSort(data, realtimeSortCfg, api);
this._isFirstFrame = false;
} else {
var orderMapping_1 = function (idx) {
var el = data.getItemGraphicEl(idx);
var shape = el && el.shape;
return shape &&
// The result should be consistent with the initial sort by data value.
// Do not support the case that both positive and negative exist.
Math.abs(baseAxis.isHorizontal() ? shape.height : shape.width)
// If data is NaN, shape.xxx may be NaN, so use || 0 here in case
|| 0;
};
this._onRendered = function () {
_this._updateSortWithinSameData(data, orderMapping_1, baseAxis, api);
};
api.getZr().on('rendered', this._onRendered);
}
};
BarView.prototype._dataSort = function (data, baseAxis, orderMapping) {
var info = [];
data.each(data.mapDimension(baseAxis.dim), function (ordinalNumber, dataIdx) {
var mappedValue = orderMapping(dataIdx);
mappedValue = mappedValue == null ? NaN : mappedValue;
info.push({
dataIndex: dataIdx,
mappedValue: mappedValue,
ordinalNumber: ordinalNumber
});
});
info.sort(function (a, b) {
// If NaN, it will be treated as min val.
return b.mappedValue - a.mappedValue;
});
return {
ordinalNumbers: map(info, function (item) {
return item.ordinalNumber;
})
};
};
BarView.prototype._isOrderChangedWithinSameData = function (data, orderMapping, baseAxis) {
var scale = baseAxis.scale;
var ordinalDataDim = data.mapDimension(baseAxis.dim);
var lastValue = Number.MAX_VALUE;
for (var tickNum = 0, len = scale.getOrdinalMeta().categories.length; tickNum < len; ++tickNum) {
var rawIdx = data.rawIndexOf(ordinalDataDim, scale.getRawOrdinalNumber(tickNum));
var value = rawIdx < 0
// If some tick have no bar, the tick will be treated as min.
? Number.MIN_VALUE
// PENDING: if dataZoom on baseAxis exits, is it a performance issue?
: orderMapping(data.indexOfRawIndex(rawIdx));
if (value > lastValue) {
return true;
}
lastValue = value;
}
return false;
};
/*
* Consider the case when A and B changed order, whose representing
* bars are both out of sight, we don't wish to trigger reorder action
* as long as the order in the view doesn't change.
*/
BarView.prototype._isOrderDifferentInView = function (orderInfo, baseAxis) {
var scale = baseAxis.scale;
var extent = scale.getExtent();
var tickNum = Math.max(0, extent[0]);
var tickMax = Math.min(extent[1], scale.getOrdinalMeta().categories.length - 1);
for (; tickNum <= tickMax; ++tickNum) {
if (orderInfo.ordinalNumbers[tickNum] !== scale.getRawOrdinalNumber(tickNum)) {
return true;
}
}
};
BarView.prototype._updateSortWithinSameData = function (data, orderMapping, baseAxis, api) {
if (!this._isOrderChangedWithinSameData(data, orderMapping, baseAxis)) {
return;
}
var sortInfo = this._dataSort(data, baseAxis, orderMapping);
if (this._isOrderDifferentInView(sortInfo, baseAxis)) {
this._removeOnRenderedListener(api);
api.dispatchAction({
type: 'changeAxisOrder',
componentType: baseAxis.dim + 'Axis',
axisId: baseAxis.index,
sortInfo: sortInfo
});
}
};
BarView.prototype._dispatchInitSort = function (data, realtimeSortCfg, api) {
var baseAxis = realtimeSortCfg.baseAxis;
var sortResult = this._dataSort(data, baseAxis, function (dataIdx) {
return data.get(data.mapDimension(realtimeSortCfg.otherAxis.dim), dataIdx);
});
api.dispatchAction({
type: 'changeAxisOrder',
componentType: baseAxis.dim + 'Axis',
isInitSort: true,
axisId: baseAxis.index,
sortInfo: sortResult
});
};
BarView.prototype.remove = function (ecModel, api) {
this._clear(this._model);
this._removeOnRenderedListener(api);
};
BarView.prototype.dispose = function (ecModel, api) {
this._removeOnRenderedListener(api);
};
BarView.prototype._removeOnRenderedListener = function (api) {
if (this._onRendered) {
api.getZr().off('rendered', this._onRendered);
this._onRendered = null;
}
};
BarView.prototype._clear = function (model) {
var group = this.group;
var data = this._data;
if (model && model.isAnimationEnabled() && data && !this._isLargeDraw) {
this._removeBackground();
this._backgroundEls = [];
data.eachItemGraphicEl(function (el) {
removeElementWithFadeOut(el, model, getECData(el).dataIndex);
});
} else {
group.removeAll();
}
this._data = null;
this._isFirstFrame = true;
};
BarView.prototype._removeBackground = function () {
this.group.remove(this._backgroundGroup);
this._backgroundGroup = null;
};
BarView.type = 'bar';
return BarView;
}(ChartView);
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 coordSysX2 = coordSysBoundingRect.x + coordSysBoundingRect.width;
var coordSysY2 = coordSysBoundingRect.y + coordSysBoundingRect.height;
var x = mathMax(layout.x, coordSysBoundingRect.x);
var x2 = mathMin(layout.x + layout.width, coordSysX2);
var y = mathMax(layout.y, coordSysBoundingRect.y);
var y2 = mathMin(layout.y + layout.height, coordSysY2);
var xClipped = x2 < x;
var yClipped = y2 < y;
// When xClipped or yClipped, the element will be marked as `ignore`.
// But we should also place the element at the edge of the coord sys bounding rect.
// Because if data changed and the bar shows again, its transition animation
// will begin at this place.
layout.x = xClipped && x > coordSysX2 ? x2 : x;
layout.y = yClipped && y > coordSysY2 ? y2 : y;
layout.width = xClipped ? 0 : x2 - x;
layout.height = yClipped ? 0 : y2 - y;
// 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 xClipped || yClipped;
},
polar: function (coordSysClipArea, layout) {
var signR = layout.r0 <= layout.r ? 1 : -1;
// Make sure r is larger than r0
if (signR < 0) {
var tmp = layout.r;
layout.r = layout.r0;
layout.r0 = tmp;
}
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 tmp = layout.r;
layout.r = layout.r0;
layout.r0 = tmp;
}
return clipped;
}
};
var elementCreator = {
cartesian2d: function (seriesModel, data, newIndex, layout, isHorizontal, animationModel, axisModel, isUpdate, roundCap) {
var rect = new Rect({
shape: extend({}, layout),
z2: 1
});
rect.__dataIndex = newIndex;
rect.name = 'item';
if (animationModel) {
var rectShape = rect.shape;
var animateProperty = isHorizontal ? 'height' : 'width';
rectShape[animateProperty] = 0;
}
return rect;
},
polar: function (seriesModel, data, newIndex, layout, isRadial, animationModel, axisModel, isUpdate, roundCap) {
var ShapeClass = !isRadial && roundCap ? Sausage : Sector;
var sector = new ShapeClass({
shape: layout,
z2: 1
});
sector.name = 'item';
var positionMap = createPolarPositionMapping(isRadial);
sector.calculateTextPosition = createSectorCalculateTextPosition(positionMap, {
isRoundCap: ShapeClass === Sausage
});
// Animation
if (animationModel) {
var sectorShape = sector.shape;
var animateProperty = isRadial ? 'r' : 'endAngle';
var animateTarget = {};
sectorShape[animateProperty] = isRadial ? layout.r0 : layout.startAngle;
animateTarget[animateProperty] = layout[animateProperty];
(isUpdate ? updateProps : initProps)(sector, {
shape: animateTarget
// __value: typeof dataValue === 'string' ? parseInt(dataValue, 10) : dataValue
}, animationModel);
}
return sector;
}
};
function shouldRealtimeSort(seriesModel, coordSys) {
var realtimeSortOption = seriesModel.get('realtimeSort', true);
var baseAxis = coordSys.getBaseAxis();
if (process.env.NODE_ENV !== 'production') {
if (realtimeSortOption) {
if (baseAxis.type !== 'category') {
warn('`realtimeSort` will not work because this bar series is not based on a category axis.');
}
if (coordSys.type !== 'cartesian2d') {
warn('`realtimeSort` will not work because this bar series is not on cartesian2d.');
}
}
}
if (realtimeSortOption && baseAxis.type === 'category' && coordSys.type === 'cartesian2d') {
return {
baseAxis: baseAxis,
otherAxis: coordSys.getOtherAxis(baseAxis)
};
}
}
function updateRealtimeAnimation(realtimeSortCfg, seriesAnimationModel, el, layout, newIndex, isHorizontal, isUpdate, isChangeOrder) {
var seriesTarget;
var axisTarget;
if (isHorizontal) {
axisTarget = {
x: layout.x,
width: layout.width
};
seriesTarget = {
y: layout.y,
height: layout.height
};
} else {
axisTarget = {
y: layout.y,
height: layout.height
};
seriesTarget = {
x: layout.x,
width: layout.width
};
}
if (!isChangeOrder) {
// Keep the original growth animation if only axis order changed.
// Not start a new animation.
(isUpdate ? updateProps : initProps)(el, {
shape: seriesTarget
}, seriesAnimationModel, newIndex, null);
}
var axisAnimationModel = seriesAnimationModel ? realtimeSortCfg.baseAxis.model : null;
(isUpdate ? updateProps : initProps)(el, {
shape: axisTarget
}, axisAnimationModel, newIndex);
}
function checkPropertiesNotValid(obj, props) {
for (var i = 0; i < props.length; i++) {
if (!isFinite(obj[props[i]])) {
return true;
}
}
return false;
}
var rectPropties = ['x', 'y', 'width', 'height'];
var polarPropties = ['cx', 'cy', 'r', 'startAngle', 'endAngle'];
var isValidLayout = {
cartesian2d: function (layout) {
return !checkPropertiesNotValid(layout, rectPropties);
},
polar: function (layout) {
return !checkPropertiesNotValid(layout, polarPropties);
}
};
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,
clockwise: layout.clockwise
};
}
};
function isZeroOnPolar(layout) {
return layout.startAngle != null && layout.endAngle != null && layout.startAngle === layout.endAngle;
}
function createPolarPositionMapping(isRadial) {
return function (isRadial) {
var arcOrAngle = isRadial ? 'Arc' : 'Angle';
return function (position) {
switch (position) {
case 'start':
case 'insideStart':
case 'end':
case 'insideEnd':
return position + arcOrAngle;
default:
return position;
}
};
}(isRadial);
}
function updateStyle(el, data, dataIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, isPolar) {
var style = data.getItemVisual(dataIndex, 'style');
if (!isPolar) {
var borderRadius = itemModel.get(['itemStyle', 'borderRadius']) || 0;
el.setShape('r', borderRadius);
} else if (!seriesModel.get('roundCap')) {
var sectorShape = el.shape;
var cornerRadius = getSectorCornerRadius(itemModel.getModel('itemStyle'), sectorShape, true);
extend(sectorShape, cornerRadius);
el.setShape(sectorShape);
}
el.useStyle(style);
var cursorStyle = itemModel.getShallow('cursor');
cursorStyle && el.attr('cursor', cursorStyle);
var labelPositionOutside = isPolar ? isHorizontalOrRadial ? layout.r >= layout.r0 ? 'endArc' : 'startArc' : layout.endAngle >= layout.startAngle ? 'endAngle' : 'startAngle' : isHorizontalOrRadial ? layout.height >= 0 ? 'bottom' : 'top' : layout.width >= 0 ? 'right' : 'left';
var labelStatesModels = getLabelStatesModels(itemModel);
setLabelStyle(el, labelStatesModels, {
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
inheritColor: style.fill,
defaultOpacity: style.opacity,
defaultOutsidePosition: labelPositionOutside
});
var label = el.getTextContent();
if (isPolar && label) {
var position = itemModel.get(['label', 'position']);
el.textConfig.inside = position === 'middle' ? true : null;
setSectorTextRotation(el, position === 'outside' ? labelPositionOutside : position, createPolarPositionMapping(isHorizontalOrRadial), itemModel.get(['label', 'rotate']));
}
setLabelValueAnimation(label, labelStatesModels, seriesModel.getRawValue(dataIndex), function (value) {
return getDefaultInterpolatedLabel(data, value);
});
var emphasisModel = itemModel.getModel(['emphasis']);
toggleHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
setStatesStylesFromModel(el, itemModel);
if (isZeroOnPolar(layout)) {
el.style.fill = 'none';
el.style.stroke = 'none';
each(el.states, function (state) {
if (state.style) {
state.style.fill = state.style.stroke = 'none';
}
});
}
}
// In case width or height are too small.
function getLineWidth(itemModel, rawLayout) {
// Has no border.
var borderColor = itemModel.get(['itemStyle', 'borderColor']);
if (!borderColor || borderColor === 'none') {
return 0;
}
var lineWidth = itemModel.get(['itemStyle', 'borderWidth']) || 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 LagePathShape = /** @class */function () {
function LagePathShape() {}
return LagePathShape;
}();
var LargePath = /** @class */function (_super) {
__extends(LargePath, _super);
function LargePath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'largeBar';
return _this;
}
LargePath.prototype.getDefaultShape = function () {
return new LagePathShape();
};
LargePath.prototype.buildPath = function (ctx, shape) {
// Drawing lines is more efficient than drawing
// a whole line or drawing rects.
var points = shape.points;
var baseDimIdx = this.baseDimIdx;
var valueDimIdx = 1 - this.baseDimIdx;
var startPoint = [];
var size = [];
var barWidth = this.barWidth;
for (var i = 0; i < points.length; i += 3) {
size[baseDimIdx] = barWidth;
size[valueDimIdx] = points[i + 2];
startPoint[baseDimIdx] = points[i + baseDimIdx];
startPoint[valueDimIdx] = points[i + valueDimIdx];
ctx.rect(startPoint[0], startPoint[1], size[0], size[1]);
}
};
return LargePath;
}(Path);
function createLarge(seriesModel, group, progressiveEls, incremental) {
// TODO support polar
var data = seriesModel.getData();
var baseDimIdx = data.getLayout('valueAxisHorizontal') ? 1 : 0;
var largeDataIndices = data.getLayout('largeDataIndices');
var barWidth = data.getLayout('size');
var backgroundModel = seriesModel.getModel('backgroundStyle');
var bgPoints = data.getLayout('largeBackgroundPoints');
if (bgPoints) {
var bgEl = new LargePath({
shape: {
points: bgPoints
},
incremental: !!incremental,
silent: true,
z2: 0
});
bgEl.baseDimIdx = baseDimIdx;
bgEl.largeDataIndices = largeDataIndices;
bgEl.barWidth = barWidth;
bgEl.useStyle(backgroundModel.getItemStyle());
group.add(bgEl);
progressiveEls && progressiveEls.push(bgEl);
}
var el = new LargePath({
shape: {
points: data.getLayout('largePoints')
},
incremental: !!incremental,
ignoreCoarsePointer: true,
z2: 1
});
el.baseDimIdx = baseDimIdx;
el.largeDataIndices = largeDataIndices;
el.barWidth = barWidth;
group.add(el);
el.useStyle(data.getVisual('style'));
// Stroke is rendered first to avoid overlapping with fill
el.style.stroke = null;
// Enable tooltip and user mouse/touch event handlers.
getECData(el).seriesIndex = seriesModel.seriesIndex;
if (!seriesModel.get('silent')) {
el.on('mousedown', largePathUpdateDataIndex);
el.on('mousemove', largePathUpdateDataIndex);
}
progressiveEls && progressiveEls.push(el);
}
// 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);
getECData(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 startPoint = [];
var size = [];
var barWidth = largePath.barWidth;
for (var i = 0, len = points.length / 3; i < len; i++) {
var ii = i * 3;
size[baseDimIdx] = barWidth;
size[valueDimIdx] = points[ii + 2];
startPoint[baseDimIdx] = points[ii + baseDimIdx];
startPoint[valueDimIdx] = points[ii + valueDimIdx];
if (size[valueDimIdx] < 0) {
startPoint[valueDimIdx] += size[valueDimIdx];
size[valueDimIdx] = -size[valueDimIdx];
}
if (x >= startPoint[0] && x <= startPoint[0] + size[0] && y >= startPoint[1] && y <= startPoint[1] + size[1]) {
return largeDataIndices[i];
}
}
return -1;
}
function createBackgroundShape(isHorizontalOrRadial, layout, coord) {
if (isCoordinateSystemType(coord, 'cartesian2d')) {
var rectShape = layout;
var coordLayout = coord.getArea();
return {
x: isHorizontalOrRadial ? rectShape.x : coordLayout.x,
y: isHorizontalOrRadial ? coordLayout.y : rectShape.y,
width: isHorizontalOrRadial ? rectShape.width : coordLayout.width,
height: isHorizontalOrRadial ? coordLayout.height : rectShape.height
};
} else {
var coordLayout = coord.getArea();
var sectorShape = layout;
return {
cx: coordLayout.cx,
cy: coordLayout.cy,
r0: isHorizontalOrRadial ? coordLayout.r0 : sectorShape.r0,
r: isHorizontalOrRadial ? coordLayout.r : sectorShape.r,
startAngle: isHorizontalOrRadial ? sectorShape.startAngle : 0,
endAngle: isHorizontalOrRadial ? sectorShape.endAngle : Math.PI * 2
};
}
}
function createBackgroundEl(coord, isHorizontalOrRadial, layout) {
var ElementClz = coord.type === 'polar' ? Sector : Rect;
return new ElementClz({
shape: createBackgroundShape(isHorizontalOrRadial, layout, coord),
silent: true,
z2: 0
});
}
export default BarView;

View File

@ -0,0 +1,159 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SeriesModel from '../../model/Series.js';
import createSeriesData from '../helper/createSeriesData.js';
import { each } from 'zrender/lib/core/util.js';
var BaseBarSeriesModel = /** @class */function (_super) {
__extends(BaseBarSeriesModel, _super);
function BaseBarSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = BaseBarSeriesModel.type;
return _this;
}
BaseBarSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesData(null, this, {
useEncodeDefaulter: true
});
};
BaseBarSeriesModel.prototype.getMarkerPosition = function (value, dims, startingAtTick) {
var coordSys = this.coordinateSystem;
if (coordSys && coordSys.clampData) {
// PENDING if clamp ?
var clampData_1 = coordSys.clampData(value);
var pt_1 = coordSys.dataToPoint(clampData_1);
if (startingAtTick) {
each(coordSys.getAxes(), function (axis, idx) {
// If axis type is category, use tick coords instead
if (axis.type === 'category' && dims != null) {
var tickCoords = axis.getTicksCoords();
var alignTicksWithLabel = axis.getTickModel().get('alignWithLabel');
var targetTickId = clampData_1[idx];
// The index of rightmost tick of markArea is 1 larger than x1/y1 index
var isEnd = dims[idx] === 'x1' || dims[idx] === 'y1';
if (isEnd && !alignTicksWithLabel) {
targetTickId += 1;
}
// The only contains one tick, tickCoords is
// like [{coord: 0, tickValue: 0}, {coord: 0}]
// to the length should always be larger than 1
if (tickCoords.length < 2) {
return;
} else if (tickCoords.length === 2) {
// The left value and right value of the axis are
// the same. coord is 0 in both items. Use the max
// value of the axis as the coord
pt_1[idx] = axis.toGlobalCoord(axis.getExtent()[isEnd ? 1 : 0]);
return;
}
var leftCoord = void 0;
var coord = void 0;
var stepTickValue = 1;
for (var i = 0; i < tickCoords.length; i++) {
var tickCoord = tickCoords[i].coord;
// The last item of tickCoords doesn't contain
// tickValue
var tickValue = i === tickCoords.length - 1 ? tickCoords[i - 1].tickValue + stepTickValue : tickCoords[i].tickValue;
if (tickValue === targetTickId) {
coord = tickCoord;
break;
} else if (tickValue < targetTickId) {
leftCoord = tickCoord;
} else if (leftCoord != null && tickValue > targetTickId) {
coord = (tickCoord + leftCoord) / 2;
break;
}
if (i === 1) {
// Here we assume the step of category axes is
// the same
stepTickValue = tickValue - tickCoords[0].tickValue;
}
}
if (coord == null) {
if (!leftCoord) {
// targetTickId is smaller than all tick ids in the
// visible area, use the leftmost tick coord
coord = tickCoords[0].coord;
} else if (leftCoord) {
// targetTickId is larger than all tick ids in the
// visible area, use the rightmost tick coord
coord = tickCoords[tickCoords.length - 1].coord;
}
}
pt_1[idx] = axis.toGlobalCoord(coord);
}
});
} else {
var data = this.getData();
var offset = data.getLayout('offset');
var size = data.getLayout('size');
var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
pt_1[offsetIndex] += offset + size / 2;
}
return pt_1;
}
return [NaN, NaN];
};
BaseBarSeriesModel.type = 'series.__base_bar__';
BaseBarSeriesModel.defaultOption = {
// zlevel: 0,
z: 2,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
// stack: null
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
barMinHeight: 0,
barMinAngle: 0,
// cursor: null,
large: false,
largeThreshold: 400,
progressive: 3e3,
progressiveChunkMode: 'mod'
};
return BaseBarSeriesModel;
}(SeriesModel);
SeriesModel.registerClass(BaseBarSeriesModel);
export default BaseBarSeriesModel;

View File

@ -0,0 +1,95 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import BaseBarSeriesModel from './BaseBarSeries.js';
import { inheritDefaultOption } from '../../util/component.js';
var PictorialBarSeriesModel = /** @class */function (_super) {
__extends(PictorialBarSeriesModel, _super);
function PictorialBarSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = PictorialBarSeriesModel.type;
_this.hasSymbolVisual = true;
_this.defaultSymbol = 'roundRect';
return _this;
}
PictorialBarSeriesModel.prototype.getInitialData = function (option) {
// Disable stack.
option.stack = null;
return _super.prototype.getInitialData.apply(this, arguments);
};
PictorialBarSeriesModel.type = 'series.pictorialBar';
PictorialBarSeriesModel.dependencies = ['grid'];
PictorialBarSeriesModel.defaultOption = inheritDefaultOption(BaseBarSeriesModel.defaultOption, {
symbol: 'circle',
symbolSize: null,
symbolRotate: null,
symbolPosition: null,
symbolOffset: null,
symbolMargin: null,
symbolRepeat: false,
symbolRepeatDirection: 'end',
symbolClip: false,
symbolBoundingData: null,
symbolPatternSize: 400,
barGap: '-100%',
// Pictorial bar do not clip by default because in many cases
// xAxis and yAxis are not displayed and it's expected not to clip
clip: false,
// z can be set in data item, which is z2 actually.
// Disable progressive
progressive: 0,
emphasis: {
// By default pictorialBar do not hover scale. Hover scale is not suitable
// for the case that both has foreground and background.
scale: false
},
select: {
itemStyle: {
borderColor: '#212121'
}
}
});
return PictorialBarSeriesModel;
}(BaseBarSeriesModel);
export default PictorialBarSeriesModel;

View File

@ -0,0 +1,632 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as zrUtil from 'zrender/lib/core/util.js';
import * as graphic from '../../util/graphic.js';
import { toggleHoverEmphasis } from '../../util/states.js';
import { createSymbol, normalizeSymbolOffset } from '../../util/symbol.js';
import { parsePercent, isNumeric } from '../../util/number.js';
import ChartView from '../../view/Chart.js';
import { getDefaultLabel } from '../helper/labelHelper.js';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
import ZRImage from 'zrender/lib/graphic/Image.js';
import { getECData } from '../../util/innerStore.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
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 PictorialBarView = /** @class */function (_super) {
__extends(PictorialBarView, _super);
function PictorialBarView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = PictorialBarView.type;
return _this;
}
PictorialBarView.prototype.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.master.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();
// Do clipping
var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
if (clipPath) {
group.setClipPath(clipPath);
} else {
group.removeClipPath();
}
this._data = data;
return this.group;
};
PictorialBarView.prototype.remove = function (ecModel, api) {
var group = this.group;
var data = this._data;
if (ecModel.get('animation')) {
if (data) {
data.eachItemGraphicEl(function (bar) {
removeBar(data, getECData(bar).dataIndex, ecModel, bar);
});
}
} else {
group.removeAll();
}
};
PictorialBarView.type = 'pictorialBar';
return PictorialBarView;
}(ChartView);
// 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',
style: data.getItemVisual(dataIndex, 'style'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverScale: isAnimationEnabled && itemModel.get(['emphasis', 'scale']),
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 = normalizeSymbolOffset(itemModel.get('symbolOffset'), symbolSize);
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, outputSymbolMeta) {
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];
}
outputSymbolMeta.boundingLength = boundingLength;
if (symbolRepeat) {
outputSymbolMeta.repeatCutLength = layout[valueDim.wh];
}
// if 'pxSign' means sign of pixel, it can't be zero, or symbolScale will be zero
// and when borderWidth be settled, the actual linewidth will be NaN
var isXAxis = valueDim.xy === 'x';
var isInverse = valueAxis.inverse;
outputSymbolMeta.pxSign = isXAxis && !isInverse || !isXAxis && isInverse ? boundingLength >= 0 ? 1 : -1 : boundingLength > 0 ? 1 : -1;
}
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, outputSymbolMeta) {
var valueDim = opt.valueDim;
var categoryDim = opt.categoryDim;
var categorySize = Math.abs(layout[categoryDim.wh]);
var symbolSize = data.getItemVisual(dataIndex, 'symbolSize');
var parsedSymbolSize;
if (zrUtil.isArray(symbolSize)) {
parsedSymbolSize = symbolSize.slice();
} else {
if (symbolSize == null) {
// will parse to number below
parsedSymbolSize = ['100%', '100%'];
} else {
parsedSymbolSize = [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.
parsedSymbolSize[categoryDim.index] = parsePercent(parsedSymbolSize[categoryDim.index], categorySize);
parsedSymbolSize[valueDim.index] = parsePercent(parsedSymbolSize[valueDim.index], symbolRepeat ? categorySize : Math.abs(boundingLength));
outputSymbolMeta.symbolSize = parsedSymbolSize;
// If x or y is less than zero, show reversed shape.
var symbolScale = outputSymbolMeta.symbolScale = [parsedSymbolSize[0] / symbolPatternSize, parsedSymbolSize[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, outputSymbolMeta) {
// 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({
scaleX: symbolScale[0],
scaleY: symbolScale[1],
rotation: rotation
});
pathForLineWidth.updateTransform();
valueLineWidth /= pathForLineWidth.getLineScale();
valueLineWidth *= symbolScale[opt.valueDim.index];
}
outputSymbolMeta.valueLineWidth = valueLineWidth || 0;
}
function prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, outputSymbolMeta) {
var categoryDim = opt.categoryDim;
var valueDim = opt.valueDim;
var pxSign = outputSymbolMeta.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);
}
var symbolMarginNumeric = parsePercent(symbolMargin, symbolSize[valueDim.index]);
var uLenWithMargin = Math.max(unitLength + symbolMarginNumeric * 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 : symbolMarginNumeric * 2;
// Both final repeatTimes and final symbolMarginNumeric 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;
symbolMarginNumeric = mDiff / 2 / (hasEndGap ? repeatTimes : Math.max(repeatTimes - 1, 1));
uLenWithMargin = unitLength + symbolMarginNumeric * 2;
endFix = hasEndGap ? 0 : symbolMarginNumeric * 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;
outputSymbolMeta.repeatTimes = repeatTimes;
outputSymbolMeta.symbolMargin = symbolMarginNumeric;
}
var sizeFix = pxSign * (pathLen / 2);
var pathPosition = outputSymbolMeta.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 = outputSymbolMeta.bundlePosition = [];
bundlePosition[categoryDim.index] = layout[categoryDim.xy];
bundlePosition[valueDim.index] = layout[valueDim.xy];
var barRectShape = outputSymbolMeta.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 = outputSymbolMeta.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);
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, {
scaleX: 0,
scaleY: 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, {
x: target.x,
y: target.y,
scaleX: 0,
scaleY: 0
}, {
scaleX: target.scaleX,
scaleY: target.scaleY,
rotation: target.rotation
}, symbolMeta, isUpdate);
}
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 {
x: position[0],
y: position[1],
scaleX: symbolMeta.symbolScale[0],
scaleY: symbolMeta.symbolScale[1],
rotation: symbolMeta.rotation
};
}
}
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, {
x: symbolMeta.pathPosition[0],
y: symbolMeta.pathPosition[1],
scaleX: 0,
scaleY: 0,
rotation: symbolMeta.rotation
}, {
scaleX: symbolMeta.symbolScale[0],
scaleY: symbolMeta.symbolScale[1]
}, symbolMeta, isUpdate);
} else {
updateAttr(mainPath, null, {
x: symbolMeta.pathPosition[0],
y: symbolMeta.pathPosition[1],
scaleX: symbolMeta.symbolScale[0],
scaleY: symbolMeta.symbolScale[1],
rotation: symbolMeta.rotation
}, symbolMeta, isUpdate);
}
}
// 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
}
});
barRect.disableMorphing = true;
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 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.x = symbolMeta.bundlePosition[0];
bundle.y = symbolMeta.bundlePosition[1];
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, {
x: symbolMeta.bundlePosition[0],
y: symbolMeta.bundlePosition[1]
}, 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.removeTextContent();
var paths = [];
eachPath(bar, function (path) {
paths.push(path);
});
bar.__pictorialMainPath && paths.push(bar.__pictorialMainPath);
// I do not find proper remove animation for clip yet.
bar.__pictorialClipPath && (animationModel = null);
zrUtil.each(paths, function (path) {
graphic.removeElement(path, {
scaleX: 0,
scaleY: 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 dataIndex = symbolMeta.dataIndex;
var itemModel = symbolMeta.itemModel;
// Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
var emphasisModel = itemModel.getModel('emphasis');
var emphasisStyle = emphasisModel.getModel('itemStyle').getItemStyle();
var blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
var selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
var cursorStyle = itemModel.getShallow('cursor');
var focus = emphasisModel.get('focus');
var blurScope = emphasisModel.get('blurScope');
var hoverScale = emphasisModel.get('scale');
eachPath(bar, function (path) {
if (path instanceof ZRImage) {
var pathStyle = path.style;
path.useStyle(zrUtil.extend({
// TODO other properties like dx, dy ?
image: pathStyle.image,
x: pathStyle.x,
y: pathStyle.y,
width: pathStyle.width,
height: pathStyle.height
}, symbolMeta.style));
} else {
path.useStyle(symbolMeta.style);
}
var emphasisState = path.ensureState('emphasis');
emphasisState.style = emphasisStyle;
if (hoverScale) {
// NOTE: Must after scale is set after updateAttr
emphasisState.scaleX = path.scaleX * 1.1;
emphasisState.scaleY = path.scaleY * 1.1;
}
path.ensureState('blur').style = blurStyle;
path.ensureState('select').style = selectStyle;
cursorStyle && (path.cursor = cursorStyle);
path.z2 = symbolMeta.z2;
});
var barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
var barRect = bar.__pictorialBarRect;
barRect.ignoreClip = true;
setLabelStyle(barRect, getLabelStatesModels(itemModel), {
labelFetcher: opt.seriesModel,
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(opt.seriesModel.getData(), dataIndex),
inheritColor: symbolMeta.style.fill,
defaultOpacity: symbolMeta.style.opacity,
defaultOutsidePosition: barPositionOutside
});
toggleHoverEmphasis(bar, focus, blurScope, emphasisModel.get('disabled'));
}
function toIntTimes(times) {
var roundedTimes = Math.round(times);
// Escapse accurate error
return Math.abs(times - roundedTimes) < 1e-4 ? roundedTimes : Math.ceil(times);
}
export default PictorialBarView;

81
frontend/node_modules/echarts/lib/chart/bar/install.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
import { layout, createProgressiveLayout } from '../../layout/barGrid.js';
import dataSample from '../../processor/dataSample.js';
import BarSeries from './BarSeries.js';
import BarView from './BarView.js';
export function install(registers) {
registers.registerChartView(BarView);
registers.registerSeriesModel(BarSeries);
registers.registerLayout(registers.PRIORITY.VISUAL.LAYOUT, zrUtil.curry(layout, 'bar'));
// Do layout after other overall layout, which can prepare some information.
registers.registerLayout(registers.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT, createProgressiveLayout('bar'));
// Down sample after filter
registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, dataSample('bar'));
/**
* @payload
* @property {string} [componentType=series]
* @property {number} [dx]
* @property {number} [dy]
* @property {number} [zoom]
* @property {number} [originX]
* @property {number} [originY]
*/
registers.registerAction({
type: 'changeAxisOrder',
event: 'changeAxisOrder',
update: 'update'
}, function (payload, ecModel) {
var componentType = payload.componentType || 'series';
ecModel.eachComponent({
mainType: componentType,
query: payload
}, function (componentModel) {
if (payload.sortInfo) {
componentModel.axis.setCategorySortInfo(payload.sortInfo);
}
});
});
}

View File

@ -0,0 +1,54 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import PictorialBarView from './PictorialBarView.js';
import PictorialBarSeriesModel from './PictorialBarSeries.js';
import { createProgressiveLayout, layout } from '../../layout/barGrid.js';
import { curry } from 'zrender/lib/core/util.js';
export function install(registers) {
registers.registerChartView(PictorialBarView);
registers.registerSeriesModel(PictorialBarSeriesModel);
registers.registerLayout(registers.PRIORITY.VISUAL.LAYOUT, curry(layout, 'pictorialBar'));
// Do layout after other overall layout, which can prepare some information.
registers.registerLayout(registers.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT, createProgressiveLayout('pictorialBar'));
}

46
frontend/node_modules/echarts/lib/chart/boxplot.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './boxplot/install.js';
use(install);

View File

@ -0,0 +1,108 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SeriesModel from '../../model/Series.js';
import { WhiskerBoxCommonMixin } from '../helper/whiskerBoxCommon.js';
import { mixin } from 'zrender/lib/core/util.js';
var BoxplotSeriesModel = /** @class */function (_super) {
__extends(BoxplotSeriesModel, _super);
function BoxplotSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = BoxplotSeriesModel.type;
// 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
*/
_this.defaultValueDimensions = [{
name: 'min',
defaultTooltip: true
}, {
name: 'Q1',
defaultTooltip: true
}, {
name: 'median',
defaultTooltip: true
}, {
name: 'Q3',
defaultTooltip: true
}, {
name: 'max',
defaultTooltip: true
}];
_this.visualDrawType = 'stroke';
return _this;
}
BoxplotSeriesModel.type = 'series.boxplot';
BoxplotSeriesModel.dependencies = ['xAxis', 'yAxis', 'grid'];
BoxplotSeriesModel.defaultOption = {
// zlevel: 0,
z: 2,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
layout: null,
boxWidth: [7, 50],
itemStyle: {
color: '#fff',
borderWidth: 1
},
emphasis: {
scale: true,
itemStyle: {
borderWidth: 2,
shadowBlur: 5,
shadowOffsetX: 1,
shadowOffsetY: 1,
shadowColor: 'rgba(0,0,0,0.2)'
}
},
animationDuration: 800
};
return BoxplotSeriesModel;
}(SeriesModel);
mixin(BoxplotSeriesModel, WhiskerBoxCommonMixin, true);
export default BoxplotSeriesModel;

View File

@ -0,0 +1,172 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as zrUtil from 'zrender/lib/core/util.js';
import ChartView from '../../view/Chart.js';
import * as graphic from '../../util/graphic.js';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
import Path from 'zrender/lib/graphic/Path.js';
import { saveOldStyle } from '../../animation/basicTransition.js';
var BoxplotView = /** @class */function (_super) {
__extends(BoxplotView, _super);
function BoxplotView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = BoxplotView.type;
return _this;
}
BoxplotView.prototype.render = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var group = this.group;
var oldData = this._data;
// There is no old data only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!this._data) {
group.removeAll();
}
var constDim = seriesModel.get('layout') === 'horizontal' ? 1 : 0;
data.diff(oldData).add(function (newIdx) {
if (data.hasValue(newIdx)) {
var itemLayout = data.getItemLayout(newIdx);
var symbolEl = createNormalBox(itemLayout, data, newIdx, constDim, true);
data.setItemGraphicEl(newIdx, symbolEl);
group.add(symbolEl);
}
}).update(function (newIdx, oldIdx) {
var symbolEl = oldData.getItemGraphicEl(oldIdx);
// Empty data
if (!data.hasValue(newIdx)) {
group.remove(symbolEl);
return;
}
var itemLayout = data.getItemLayout(newIdx);
if (!symbolEl) {
symbolEl = createNormalBox(itemLayout, data, newIdx, constDim);
} else {
saveOldStyle(symbolEl);
updateNormalBoxData(itemLayout, symbolEl, data, newIdx);
}
group.add(symbolEl);
data.setItemGraphicEl(newIdx, symbolEl);
}).remove(function (oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
el && group.remove(el);
}).execute();
this._data = data;
};
BoxplotView.prototype.remove = function (ecModel) {
var group = this.group;
var data = this._data;
this._data = null;
data && data.eachItemGraphicEl(function (el) {
el && group.remove(el);
});
};
BoxplotView.type = 'boxplot';
return BoxplotView;
}(ChartView);
var BoxPathShape = /** @class */function () {
function BoxPathShape() {}
return BoxPathShape;
}();
var BoxPath = /** @class */function (_super) {
__extends(BoxPath, _super);
function BoxPath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'boxplotBoxPath';
return _this;
}
BoxPath.prototype.getDefaultShape = function () {
return new BoxPathShape();
};
BoxPath.prototype.buildPath = function (ctx, shape) {
var ends = shape.points;
var i = 0;
ctx.moveTo(ends[i][0], ends[i][1]);
i++;
for (; i < 4; i++) {
ctx.lineTo(ends[i][0], ends[i][1]);
}
ctx.closePath();
for (; i < ends.length; i++) {
ctx.moveTo(ends[i][0], ends[i][1]);
i++;
ctx.lineTo(ends[i][0], ends[i][1]);
}
};
return BoxPath;
}(Path);
function createNormalBox(itemLayout, data, dataIndex, constDim, isInit) {
var ends = itemLayout.ends;
var el = new BoxPath({
shape: {
points: isInit ? transInit(ends, constDim, itemLayout) : ends
}
});
updateNormalBoxData(itemLayout, el, data, dataIndex, isInit);
return el;
}
function updateNormalBoxData(itemLayout, el, data, dataIndex, isInit) {
var seriesModel = data.hostModel;
var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
updateMethod(el, {
shape: {
points: itemLayout.ends
}
}, seriesModel, dataIndex);
el.useStyle(data.getItemVisual(dataIndex, 'style'));
el.style.strokeNoScale = true;
el.z2 = 100;
var itemModel = data.getItemModel(dataIndex);
var emphasisModel = itemModel.getModel('emphasis');
setStatesStylesFromModel(el, itemModel);
toggleHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
}
function transInit(points, dim, itemLayout) {
return zrUtil.map(points, function (point) {
point = point.slice();
point[dim] = itemLayout.initBaseline;
return point;
});
}
export default BoxplotView;

View File

@ -0,0 +1,181 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
import { parsePercent } from '../../util/number.js';
var each = zrUtil.each;
export default function boxplotLayout(ecModel) {
var groupResult = groupSeriesByAxis(ecModel);
each(groupResult, function (groupItem) {
var seriesModels = groupItem.seriesModels;
if (!seriesModels.length) {
return;
}
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);
});
return result;
}
/**
* Calculate offset and box width for each series.
*/
function calculateBase(groupItem) {
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
} else {
var maxDataCount_1 = 0;
each(seriesModels, function (seriesModel) {
maxDataCount_1 = Math.max(maxDataCount_1, seriesModel.getData().count());
});
var extent = baseAxis.getExtent();
bandWidth = Math.abs(extent[1] - extent[0]) / maxDataCount_1;
}
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 cDimIdx = seriesModel.get('layout') === 'horizontal' ? 0 : 1;
var vDimIdx = 1 - cDimIdx;
var coordDims = ['x', 'y'];
var cDim = data.mapDimension(coordDims[cDimIdx]);
var vDims = data.mapDimensionsAll(coordDims[vDimIdx]);
if (cDim == null || vDims.length < 5) {
return;
}
for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
var axisDimVal = data.get(cDim, dataIndex);
var median = getPoint(axisDimVal, vDims[2], dataIndex);
var end1 = getPoint(axisDimVal, vDims[0], dataIndex);
var end2 = getPoint(axisDimVal, vDims[1], dataIndex);
var end4 = getPoint(axisDimVal, vDims[3], dataIndex);
var end5 = getPoint(axisDimVal, vDims[4], dataIndex);
var ends = [];
addBodyEnd(ends, end2, false);
addBodyEnd(ends, end4, true);
ends.push(end1, end2, end5, end4);
layEndLine(ends, end1);
layEndLine(ends, end5);
layEndLine(ends, median);
data.setItemLayout(dataIndex, {
initBaseline: median[vDimIdx],
ends: ends
});
}
function getPoint(axisDimVal, dim, dataIndex) {
var val = data.get(dim, dataIndex);
var p = [];
p[cDimIdx] = axisDimVal;
p[vDimIdx] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
} else {
point = coordSys.dataToPoint(p);
point[cDimIdx] += offset;
}
return point;
}
function addBodyEnd(ends, point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[cDimIdx] += halfWidth;
point2[cDimIdx] -= halfWidth;
start ? ends.push(point1, point2) : ends.push(point2, point1);
}
function layEndLine(ends, endCenter) {
var from = endCenter.slice();
var to = endCenter.slice();
from[cDimIdx] -= halfWidth;
to[cDimIdx] += halfWidth;
ends.push(from, to);
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import prepareBoxplotData from './prepareBoxplotData.js';
import { throwError, makePrintable } from '../../util/log.js';
import { SOURCE_FORMAT_ARRAY_ROWS } from '../../util/types.js';
export var boxplotTransform = {
type: 'echarts:boxplot',
transform: function transform(params) {
var upstream = params.upstream;
if (upstream.sourceFormat !== SOURCE_FORMAT_ARRAY_ROWS) {
var errMsg = '';
if (process.env.NODE_ENV !== 'production') {
errMsg = makePrintable('source data is not applicable for this boxplot transform. Expect number[][].');
}
throwError(errMsg);
}
var result = prepareBoxplotData(upstream.getRawData(), params.config);
return [{
dimensions: ['ItemName', 'Low', 'Q1', 'Q2', 'Q3', 'High'],
data: result.boxData
}, {
data: result.outliers
}];
}
};

View File

@ -0,0 +1,53 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import BoxplotSeriesModel from './BoxplotSeries.js';
import BoxplotView from './BoxplotView.js';
import boxplotLayout from './boxplotLayout.js';
import { boxplotTransform } from './boxplotTransform.js';
export function install(registers) {
registers.registerSeriesModel(BoxplotSeriesModel);
registers.registerChartView(BoxplotView);
registers.registerLayout(boxplotLayout);
registers.registerTransform(boxplotTransform);
}

View File

@ -0,0 +1,96 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { quantile, asc } from '../../util/number.js';
import { isFunction, isString } from 'zrender/lib/core/util.js';
/**
* See:
* <https://en.wikipedia.org/wiki/Box_plot#cite_note-frigge_hoaglin_iglewicz-2>
* <http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html>
*
* Helper method for preparing data.
*
* @param rawData like
* [
* [12,232,443], (raw data set for the first box)
* [3843,5545,1232], (raw data set for the second box)
* ...
* ]
* @param opt.boundIQR=1.5 Data less than min bound is outlier.
* default 1.5, means Q1 - 1.5 * (Q3 - Q1).
* If 'none'/0 passed, min bound will not be used.
*/
export default function prepareBoxplotData(rawData, opt) {
opt = opt || {};
var boxData = [];
var outliers = [];
var boundIQR = opt.boundIQR;
var useExtreme = boundIQR === 'none' || boundIQR === 0;
for (var i = 0; i < rawData.length; i++) {
var ascList = asc(rawData[i].slice());
var Q1 = quantile(ascList, 0.25);
var Q2 = quantile(ascList, 0.5);
var Q3 = quantile(ascList, 0.75);
var min = ascList[0];
var max = ascList[ascList.length - 1];
var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1);
var low = useExtreme ? min : Math.max(min, Q1 - bound);
var high = useExtreme ? max : Math.min(max, Q3 + bound);
var itemNameFormatter = opt.itemNameFormatter;
var itemName = isFunction(itemNameFormatter) ? itemNameFormatter({
value: i
}) : isString(itemNameFormatter) ? itemNameFormatter.replace('{value}', i + '') : i + '';
boxData.push([itemName, low, Q1, Q2, Q3, high]);
for (var j = 0; j < ascList.length; j++) {
var dataItem = ascList[j];
if (dataItem < low || dataItem > high) {
var outlier = [itemName, dataItem];
outliers.push(outlier);
}
}
}
return {
boxData: boxData,
outliers: outliers
};
}

46
frontend/node_modules/echarts/lib/chart/candlestick.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './candlestick/install.js';
use(install);

View File

@ -0,0 +1,119 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SeriesModel from '../../model/Series.js';
import { WhiskerBoxCommonMixin } from '../helper/whiskerBoxCommon.js';
import { mixin } from 'zrender/lib/core/util.js';
var CandlestickSeriesModel = /** @class */function (_super) {
__extends(CandlestickSeriesModel, _super);
function CandlestickSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = CandlestickSeriesModel.type;
_this.defaultValueDimensions = [{
name: 'open',
defaultTooltip: true
}, {
name: 'close',
defaultTooltip: true
}, {
name: 'lowest',
defaultTooltip: true
}, {
name: 'highest',
defaultTooltip: true
}];
return _this;
}
/**
* Get dimension for shadow in dataZoom
* @return dimension name
*/
CandlestickSeriesModel.prototype.getShadowDim = function () {
return 'open';
};
CandlestickSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
var itemLayout = data.getItemLayout(dataIndex);
return itemLayout && selectors.rect(itemLayout.brushRect);
};
CandlestickSeriesModel.type = 'series.candlestick';
CandlestickSeriesModel.dependencies = ['xAxis', 'yAxis', 'grid'];
CandlestickSeriesModel.defaultOption = {
// zlevel: 0,
z: 2,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
// xAxisIndex: 0,
// yAxisIndex: 0,
layout: null,
clip: true,
itemStyle: {
color: '#eb5454',
color0: '#47b262',
borderColor: '#eb5454',
borderColor0: '#47b262',
borderColorDoji: null,
// borderColor: '#d24040',
// borderColor0: '#398f4f',
borderWidth: 1
},
emphasis: {
itemStyle: {
borderWidth: 2
}
},
barMaxWidth: null,
barMinWidth: null,
barWidth: null,
large: true,
largeThreshold: 600,
progressive: 3e3,
progressiveThreshold: 1e4,
progressiveChunkMode: 'mod',
animationEasing: 'linear',
animationDuration: 300
};
return CandlestickSeriesModel;
}(SeriesModel);
mixin(CandlestickSeriesModel, WhiskerBoxCommonMixin, true);
export default CandlestickSeriesModel;

View File

@ -0,0 +1,341 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as zrUtil from 'zrender/lib/core/util.js';
import ChartView from '../../view/Chart.js';
import * as graphic from '../../util/graphic.js';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
import Path from 'zrender/lib/graphic/Path.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import { saveOldStyle } from '../../animation/basicTransition.js';
import { getBorderColor, getColor } from './candlestickVisual.js';
var SKIP_PROPS = ['color', 'borderColor'];
var CandlestickView = /** @class */function (_super) {
__extends(CandlestickView, _super);
function CandlestickView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = CandlestickView.type;
return _this;
}
CandlestickView.prototype.render = function (seriesModel, ecModel, api) {
// If there is clipPath created in large mode. Remove it.
this.group.removeClipPath();
// Clear previously rendered progressive elements.
this._progressiveEls = null;
this._updateDrawMode(seriesModel);
this._isLargeDraw ? this._renderLarge(seriesModel) : this._renderNormal(seriesModel);
};
CandlestickView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
this._clear();
this._updateDrawMode(seriesModel);
};
CandlestickView.prototype.incrementalRender = function (params, seriesModel, ecModel, api) {
this._progressiveEls = [];
this._isLargeDraw ? this._incrementalRenderLarge(params, seriesModel) : this._incrementalRenderNormal(params, seriesModel);
};
CandlestickView.prototype.eachRendered = function (cb) {
graphic.traverseElements(this._progressiveEls || this.group, cb);
};
CandlestickView.prototype._updateDrawMode = function (seriesModel) {
var isLargeDraw = seriesModel.pipelineContext.large;
if (this._isLargeDraw == null || isLargeDraw !== this._isLargeDraw) {
this._isLargeDraw = isLargeDraw;
this._clear();
}
};
CandlestickView.prototype._renderNormal = function (seriesModel) {
var data = seriesModel.getData();
var oldData = this._data;
var group = this.group;
var isSimpleBox = data.getLayout('isSimpleBox');
var needsClip = seriesModel.get('clip', true);
var coord = seriesModel.coordinateSystem;
var clipArea = coord.getArea && coord.getArea();
// There is no old data only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!this._data) {
group.removeAll();
}
data.diff(oldData).add(function (newIdx) {
if (data.hasValue(newIdx)) {
var itemLayout = data.getItemLayout(newIdx);
if (needsClip && isNormalBoxClipped(clipArea, itemLayout)) {
return;
}
var el = createNormalBox(itemLayout, newIdx, true);
graphic.initProps(el, {
shape: {
points: itemLayout.ends
}
}, seriesModel, newIdx);
setBoxCommon(el, data, newIdx, isSimpleBox);
group.add(el);
data.setItemGraphicEl(newIdx, el);
}
}).update(function (newIdx, oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
// Empty data
if (!data.hasValue(newIdx)) {
group.remove(el);
return;
}
var itemLayout = data.getItemLayout(newIdx);
if (needsClip && isNormalBoxClipped(clipArea, itemLayout)) {
group.remove(el);
return;
}
if (!el) {
el = createNormalBox(itemLayout, newIdx);
} else {
graphic.updateProps(el, {
shape: {
points: itemLayout.ends
}
}, seriesModel, newIdx);
saveOldStyle(el);
}
setBoxCommon(el, data, newIdx, isSimpleBox);
group.add(el);
data.setItemGraphicEl(newIdx, el);
}).remove(function (oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
el && group.remove(el);
}).execute();
this._data = data;
};
CandlestickView.prototype._renderLarge = function (seriesModel) {
this._clear();
createLarge(seriesModel, this.group);
var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
if (clipPath) {
this.group.setClipPath(clipPath);
} else {
this.group.removeClipPath();
}
};
CandlestickView.prototype._incrementalRenderNormal = function (params, seriesModel) {
var data = seriesModel.getData();
var isSimpleBox = data.getLayout('isSimpleBox');
var dataIndex;
while ((dataIndex = params.next()) != null) {
var itemLayout = data.getItemLayout(dataIndex);
var el = createNormalBox(itemLayout, dataIndex);
setBoxCommon(el, data, dataIndex, isSimpleBox);
el.incremental = true;
this.group.add(el);
this._progressiveEls.push(el);
}
};
CandlestickView.prototype._incrementalRenderLarge = function (params, seriesModel) {
createLarge(seriesModel, this.group, this._progressiveEls, true);
};
CandlestickView.prototype.remove = function (ecModel) {
this._clear();
};
CandlestickView.prototype._clear = function () {
this.group.removeAll();
this._data = null;
};
CandlestickView.type = 'candlestick';
return CandlestickView;
}(ChartView);
var NormalBoxPathShape = /** @class */function () {
function NormalBoxPathShape() {}
return NormalBoxPathShape;
}();
var NormalBoxPath = /** @class */function (_super) {
__extends(NormalBoxPath, _super);
function NormalBoxPath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'normalCandlestickBox';
return _this;
}
NormalBoxPath.prototype.getDefaultShape = function () {
return new NormalBoxPathShape();
};
NormalBoxPath.prototype.buildPath = function (ctx, shape) {
var ends = shape.points;
if (this.__simpleBox) {
ctx.moveTo(ends[4][0], ends[4][1]);
ctx.lineTo(ends[6][0], ends[6][1]);
} else {
ctx.moveTo(ends[0][0], ends[0][1]);
ctx.lineTo(ends[1][0], ends[1][1]);
ctx.lineTo(ends[2][0], ends[2][1]);
ctx.lineTo(ends[3][0], ends[3][1]);
ctx.closePath();
ctx.moveTo(ends[4][0], ends[4][1]);
ctx.lineTo(ends[5][0], ends[5][1]);
ctx.moveTo(ends[6][0], ends[6][1]);
ctx.lineTo(ends[7][0], ends[7][1]);
}
};
return NormalBoxPath;
}(Path);
function createNormalBox(itemLayout, dataIndex, isInit) {
var ends = itemLayout.ends;
return new NormalBoxPath({
shape: {
points: isInit ? transInit(ends, itemLayout) : ends
},
z2: 100
});
}
function isNormalBoxClipped(clipArea, itemLayout) {
var clipped = true;
for (var i = 0; i < itemLayout.ends.length; i++) {
// If any point are in the region.
if (clipArea.contain(itemLayout.ends[i][0], itemLayout.ends[i][1])) {
clipped = false;
break;
}
}
return clipped;
}
function setBoxCommon(el, data, dataIndex, isSimpleBox) {
var itemModel = data.getItemModel(dataIndex);
el.useStyle(data.getItemVisual(dataIndex, 'style'));
el.style.strokeNoScale = true;
el.__simpleBox = isSimpleBox;
setStatesStylesFromModel(el, itemModel);
var sign = data.getItemLayout(dataIndex).sign;
zrUtil.each(el.states, function (state, stateName) {
var stateModel = itemModel.getModel(stateName);
var color = getColor(sign, stateModel);
var borderColor = getBorderColor(sign, stateModel) || color;
var stateStyle = state.style || (state.style = {});
color && (stateStyle.fill = color);
borderColor && (stateStyle.stroke = borderColor);
});
var emphasisModel = itemModel.getModel('emphasis');
toggleHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
}
function transInit(points, itemLayout) {
return zrUtil.map(points, function (point) {
point = point.slice();
point[1] = itemLayout.initBaseline;
return point;
});
}
var LargeBoxPathShape = /** @class */function () {
function LargeBoxPathShape() {}
return LargeBoxPathShape;
}();
var LargeBoxPath = /** @class */function (_super) {
__extends(LargeBoxPath, _super);
function LargeBoxPath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'largeCandlestickBox';
return _this;
}
LargeBoxPath.prototype.getDefaultShape = function () {
return new LargeBoxPathShape();
};
LargeBoxPath.prototype.buildPath = function (ctx, shape) {
// Drawing lines is more efficient than drawing
// a whole line or drawing rects.
var points = shape.points;
for (var i = 0; i < points.length;) {
if (this.__sign === points[i++]) {
var x = points[i++];
ctx.moveTo(x, points[i++]);
ctx.lineTo(x, points[i++]);
} else {
i += 3;
}
}
};
return LargeBoxPath;
}(Path);
function createLarge(seriesModel, group, progressiveEls, incremental) {
var data = seriesModel.getData();
var largePoints = data.getLayout('largePoints');
var elP = new LargeBoxPath({
shape: {
points: largePoints
},
__sign: 1,
ignoreCoarsePointer: true
});
group.add(elP);
var elN = new LargeBoxPath({
shape: {
points: largePoints
},
__sign: -1,
ignoreCoarsePointer: true
});
group.add(elN);
var elDoji = new LargeBoxPath({
shape: {
points: largePoints
},
__sign: 0,
ignoreCoarsePointer: true
});
group.add(elDoji);
setLargeStyle(1, elP, seriesModel, data);
setLargeStyle(-1, elN, seriesModel, data);
setLargeStyle(0, elDoji, seriesModel, data);
if (incremental) {
elP.incremental = true;
elN.incremental = true;
}
if (progressiveEls) {
progressiveEls.push(elP, elN);
}
}
function setLargeStyle(sign, el, seriesModel, data) {
// TODO put in visual?
var borderColor = getBorderColor(sign, seriesModel)
// Use color for border color by default.
|| getColor(sign, seriesModel);
// Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
var itemStyle = seriesModel.getModel('itemStyle').getItemStyle(SKIP_PROPS);
el.useStyle(itemStyle);
el.style.fill = null;
el.style.stroke = borderColor;
}
export default CandlestickView;

View File

@ -0,0 +1,204 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { subPixelOptimize } from '../../util/graphic.js';
import createRenderPlanner from '../helper/createRenderPlanner.js';
import { parsePercent } from '../../util/number.js';
import { map, retrieve2 } from 'zrender/lib/core/util.js';
import { createFloat32Array } from '../../util/vendor.js';
var candlestickLayout = {
seriesType: 'candlestick',
plan: createRenderPlanner(),
reset: function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var candleWidth = calculateCandleWidth(seriesModel, data);
var cDimIdx = 0;
var vDimIdx = 1;
var coordDims = ['x', 'y'];
var cDimI = data.getDimensionIndex(data.mapDimension(coordDims[cDimIdx]));
var vDimsI = map(data.mapDimensionsAll(coordDims[vDimIdx]), data.getDimensionIndex, data);
var openDimI = vDimsI[0];
var closeDimI = vDimsI[1];
var lowestDimI = vDimsI[2];
var highestDimI = vDimsI[3];
data.setLayout({
candleWidth: candleWidth,
// The value is experimented visually.
isSimpleBox: candleWidth <= 1.3
});
if (cDimI < 0 || vDimsI.length < 4) {
return;
}
return {
progress: seriesModel.pipelineContext.large ? largeProgress : normalProgress
};
function normalProgress(params, data) {
var dataIndex;
var store = data.getStore();
while ((dataIndex = params.next()) != null) {
var axisDimVal = store.get(cDimI, dataIndex);
var openVal = store.get(openDimI, dataIndex);
var closeVal = store.get(closeDimI, dataIndex);
var lowestVal = store.get(lowestDimI, dataIndex);
var highestVal = store.get(highestDimI, dataIndex);
var ocLow = Math.min(openVal, closeVal);
var ocHigh = Math.max(openVal, closeVal);
var ocLowPoint = getPoint(ocLow, axisDimVal);
var ocHighPoint = getPoint(ocHigh, axisDimVal);
var lowestPoint = getPoint(lowestVal, axisDimVal);
var highestPoint = getPoint(highestVal, axisDimVal);
var ends = [];
addBodyEnd(ends, ocHighPoint, 0);
addBodyEnd(ends, ocLowPoint, 1);
ends.push(subPixelOptimizePoint(highestPoint), subPixelOptimizePoint(ocHighPoint), subPixelOptimizePoint(lowestPoint), subPixelOptimizePoint(ocLowPoint));
var itemModel = data.getItemModel(dataIndex);
var hasDojiColor = !!itemModel.get(['itemStyle', 'borderColorDoji']);
data.setItemLayout(dataIndex, {
sign: getSign(store, dataIndex, openVal, closeVal, closeDimI, hasDojiColor),
initBaseline: openVal > closeVal ? ocHighPoint[vDimIdx] : ocLowPoint[vDimIdx],
ends: ends,
brushRect: makeBrushRect(lowestVal, highestVal, axisDimVal)
});
}
function getPoint(val, axisDimVal) {
var p = [];
p[cDimIdx] = axisDimVal;
p[vDimIdx] = val;
return isNaN(axisDimVal) || isNaN(val) ? [NaN, NaN] : coordSys.dataToPoint(p);
}
function addBodyEnd(ends, point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[cDimIdx] = subPixelOptimize(point1[cDimIdx] + candleWidth / 2, 1, false);
point2[cDimIdx] = subPixelOptimize(point2[cDimIdx] - candleWidth / 2, 1, true);
start ? ends.push(point1, point2) : ends.push(point2, point1);
}
function makeBrushRect(lowestVal, highestVal, axisDimVal) {
var pmin = getPoint(lowestVal, axisDimVal);
var pmax = getPoint(highestVal, axisDimVal);
pmin[cDimIdx] -= candleWidth / 2;
pmax[cDimIdx] -= candleWidth / 2;
return {
x: pmin[0],
y: pmin[1],
width: vDimIdx ? candleWidth : pmax[0] - pmin[0],
height: vDimIdx ? pmax[1] - pmin[1] : candleWidth
};
}
function subPixelOptimizePoint(point) {
point[cDimIdx] = subPixelOptimize(point[cDimIdx], 1);
return point;
}
}
function largeProgress(params, data) {
// Structure: [sign, x, yhigh, ylow, sign, x, yhigh, ylow, ...]
var points = createFloat32Array(params.count * 4);
var offset = 0;
var point;
var tmpIn = [];
var tmpOut = [];
var dataIndex;
var store = data.getStore();
var hasDojiColor = !!seriesModel.get(['itemStyle', 'borderColorDoji']);
while ((dataIndex = params.next()) != null) {
var axisDimVal = store.get(cDimI, dataIndex);
var openVal = store.get(openDimI, dataIndex);
var closeVal = store.get(closeDimI, dataIndex);
var lowestVal = store.get(lowestDimI, dataIndex);
var highestVal = store.get(highestDimI, dataIndex);
if (isNaN(axisDimVal) || isNaN(lowestVal) || isNaN(highestVal)) {
points[offset++] = NaN;
offset += 3;
continue;
}
points[offset++] = getSign(store, dataIndex, openVal, closeVal, closeDimI, hasDojiColor);
tmpIn[cDimIdx] = axisDimVal;
tmpIn[vDimIdx] = lowestVal;
point = coordSys.dataToPoint(tmpIn, null, tmpOut);
points[offset++] = point ? point[0] : NaN;
points[offset++] = point ? point[1] : NaN;
tmpIn[vDimIdx] = highestVal;
point = coordSys.dataToPoint(tmpIn, null, tmpOut);
points[offset++] = point ? point[1] : NaN;
}
data.setLayout('largePoints', points);
}
}
};
/**
* Get the sign of a single data.
*
* @returns 0 for doji with hasDojiColor: true,
* 1 for positive,
* -1 for negative.
*/
function getSign(store, dataIndex, openVal, closeVal, closeDimI, hasDojiColor) {
var sign;
if (openVal > closeVal) {
sign = -1;
} else if (openVal < closeVal) {
sign = 1;
} else {
sign = hasDojiColor
// When doji color is set, use it instead of color/color0.
? 0 : dataIndex > 0
// If close === open, compare with close of last record
? store.get(closeDimI, dataIndex - 1) <= closeVal ? 1 : -1
// No record of previous, set to be positive
: 1;
}
return sign;
}
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(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);
}
export default candlestickLayout;

View File

@ -0,0 +1,84 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import createRenderPlanner from '../helper/createRenderPlanner.js';
import { extend } from 'zrender/lib/core/util.js';
var positiveBorderColorQuery = ['itemStyle', 'borderColor'];
var negativeBorderColorQuery = ['itemStyle', 'borderColor0'];
var dojiBorderColorQuery = ['itemStyle', 'borderColorDoji'];
var positiveColorQuery = ['itemStyle', 'color'];
var negativeColorQuery = ['itemStyle', 'color0'];
export function getColor(sign, model) {
return model.get(sign > 0 ? positiveColorQuery : negativeColorQuery);
}
export function getBorderColor(sign, model) {
return model.get(sign === 0 ? dojiBorderColorQuery : sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery);
}
var candlestickVisual = {
seriesType: 'candlestick',
plan: createRenderPlanner(),
// For legend.
performRawSeries: true,
reset: function (seriesModel, ecModel) {
// Only visible series has each data be visual encoded
if (ecModel.isSeriesFiltered(seriesModel)) {
return;
}
var isLargeRender = seriesModel.pipelineContext.large;
return !isLargeRender && {
progress: function (params, data) {
var dataIndex;
while ((dataIndex = params.next()) != null) {
var itemModel = data.getItemModel(dataIndex);
var sign = data.getItemLayout(dataIndex).sign;
var style = itemModel.getItemStyle();
style.fill = getColor(sign, itemModel);
style.stroke = getBorderColor(sign, itemModel) || style.fill;
var existsStyle = data.ensureUniqueItemVisual(dataIndex, 'style');
extend(existsStyle, style);
}
}
};
}
};
export default candlestickVisual;

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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import CandlestickView from './CandlestickView.js';
import CandlestickSeriesModel from './CandlestickSeries.js';
import preprocessor from './preprocessor.js';
import candlestickVisual from './candlestickVisual.js';
import candlestickLayout from './candlestickLayout.js';
export function install(registers) {
registers.registerChartView(CandlestickView);
registers.registerSeriesModel(CandlestickSeriesModel);
registers.registerPreprocessor(preprocessor);
registers.registerVisual(candlestickVisual);
registers.registerLayout(candlestickLayout);
}

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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
export default function candlestickPreprocessor(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';
}
});
}

46
frontend/node_modules/echarts/lib/chart/custom.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './custom/install.js';
use(install);

View File

@ -0,0 +1,105 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import createSeriesData from '../helper/createSeriesData.js';
import { makeInner } from '../../util/model.js';
import SeriesModel from '../../model/Series.js';
// Also compat with ec4, where
// `visual('color') visual('borderColor')` is supported.
export var STYLE_VISUAL_TYPE = {
color: 'fill',
borderColor: 'stroke'
};
export var NON_STYLE_VISUAL_PROPS = {
symbol: 1,
symbolSize: 1,
symbolKeepAspect: 1,
legendIcon: 1,
visualMeta: 1,
liftZ: 1,
decal: 1
};
;
export var customInnerStore = makeInner();
var CustomSeriesModel = /** @class */function (_super) {
__extends(CustomSeriesModel, _super);
function CustomSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = CustomSeriesModel.type;
return _this;
}
CustomSeriesModel.prototype.optionUpdated = function () {
this.currentZLevel = this.get('zlevel', true);
this.currentZ = this.get('z', true);
};
CustomSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesData(null, this);
};
CustomSeriesModel.prototype.getDataParams = function (dataIndex, dataType, el) {
var params = _super.prototype.getDataParams.call(this, dataIndex, dataType);
el && (params.info = customInnerStore(el).info);
return params;
};
CustomSeriesModel.type = 'series.custom';
CustomSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
CustomSeriesModel.defaultOption = {
coordinateSystem: 'cartesian2d',
// zlevel: 0,
z: 2,
legendHoverLink: true,
// Custom series will not clip by default.
// Some case will use custom series to draw label
// For example https://echarts.apache.org/examples/en/editor.html?c=custom-gantt-flight
clip: false
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// Polar coordinate system
// polarIndex: 0,
// Geo coordinate system
// geoIndex: 0,
};
return CustomSeriesModel;
}(SeriesModel);
export default CustomSeriesModel;

View File

@ -0,0 +1,923 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import { hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, indexOf } from 'zrender/lib/core/util.js';
import * as graphicUtil from '../../util/graphic.js';
import { setDefaultStateProxy, toggleHoverEmphasis } from '../../util/states.js';
import * as labelStyleHelper from '../../label/labelStyle.js';
import { getDefaultLabel } from '../helper/labelHelper.js';
import { getLayoutOnAxis } from '../../layout/barGrid.js';
import DataDiffer from '../../data/DataDiffer.js';
import ChartView from '../../view/Chart.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import prepareCartesian2d from '../../coord/cartesian/prepareCustom.js';
import prepareGeo from '../../coord/geo/prepareCustom.js';
import prepareSingleAxis from '../../coord/single/prepareCustom.js';
import preparePolar from '../../coord/polar/prepareCustom.js';
import prepareCalendar from '../../coord/calendar/prepareCustom.js';
import Displayable from 'zrender/lib/graphic/Displayable.js';
import { convertToEC4StyleForCustomSerise, isEC4CompatibleStyle, convertFromEC4CompatibleStyle, warnDeprecated } from '../../util/styleCompat.js';
import { throwError } from '../../util/log.js';
import { createOrUpdatePatternFromDecal } from '../../util/decal.js';
import { STYLE_VISUAL_TYPE, NON_STYLE_VISUAL_PROPS, customInnerStore } from './CustomSeries.js';
import { applyLeaveTransition, applyUpdateTransition } from '../../animation/customGraphicTransition.js';
import { applyKeyframeAnimation, stopPreviousKeyframeAnimationAndRestore } from '../../animation/customGraphicKeyframeAnimation.js';
var EMPHASIS = 'emphasis';
var NORMAL = 'normal';
var BLUR = 'blur';
var SELECT = 'select';
var STATES = [NORMAL, EMPHASIS, BLUR, SELECT];
var PATH_ITEM_STYLE = {
normal: ['itemStyle'],
emphasis: [EMPHASIS, 'itemStyle'],
blur: [BLUR, 'itemStyle'],
select: [SELECT, 'itemStyle']
};
var PATH_LABEL = {
normal: ['label'],
emphasis: [EMPHASIS, 'label'],
blur: [BLUR, 'label'],
select: [SELECT, 'label']
};
var DEFAULT_TRANSITION = ['x', 'y'];
// Use prefix to avoid index to be the same as el.name,
// which will cause weird update animation.
var GROUP_DIFF_PREFIX = 'e\0\0';
var attachedTxInfoTmp = {
normal: {},
emphasis: {},
blur: {},
select: {}
};
/**
* To reduce total package size of each coordinate systems, the modules `prepareCustom`
* of each coordinate systems are not required by each coordinate systems directly, but
* required by the module `custom`.
*
* prepareInfoForCustomSeries {Function}: optional
* @return {Object} {coordSys: {...}, api: {
* coord: function (data, clamp) {}, // return point in global.
* size: function (dataSize, dataItem) {} // return size of each axis in coordSys.
* }}
*/
var prepareCustoms = {
cartesian2d: prepareCartesian2d,
geo: prepareGeo,
single: prepareSingleAxis,
polar: preparePolar,
calendar: prepareCalendar
};
function isPath(el) {
return el instanceof graphicUtil.Path;
}
function isDisplayable(el) {
return el instanceof Displayable;
}
function copyElement(sourceEl, targetEl) {
targetEl.copyTransform(sourceEl);
if (isDisplayable(targetEl) && isDisplayable(sourceEl)) {
targetEl.setStyle(sourceEl.style);
targetEl.z = sourceEl.z;
targetEl.z2 = sourceEl.z2;
targetEl.zlevel = sourceEl.zlevel;
targetEl.invisible = sourceEl.invisible;
targetEl.ignore = sourceEl.ignore;
if (isPath(targetEl) && isPath(sourceEl)) {
targetEl.setShape(sourceEl.shape);
}
}
}
var CustomChartView = /** @class */function (_super) {
__extends(CustomChartView, _super);
function CustomChartView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = CustomChartView.type;
return _this;
}
CustomChartView.prototype.render = function (customSeries, ecModel, api, payload) {
// Clear previously rendered progressive elements.
this._progressiveEls = null;
var oldData = this._data;
var data = customSeries.getData();
var group = this.group;
var renderItem = makeRenderItem(customSeries, data, ecModel, api);
if (!oldData) {
// Previous render is incremental render or first render.
// Needs remove the incremental rendered elements.
group.removeAll();
}
data.diff(oldData).add(function (newIdx) {
createOrUpdateItem(api, null, newIdx, renderItem(newIdx, payload), customSeries, group, data);
}).remove(function (oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
el && applyLeaveTransition(el, customInnerStore(el).option, customSeries);
}).update(function (newIdx, oldIdx) {
var oldEl = oldData.getItemGraphicEl(oldIdx);
createOrUpdateItem(api, oldEl, newIdx, renderItem(newIdx, payload), customSeries, group, data);
}).execute();
// Do clipping
var clipPath = customSeries.get('clip', true) ? createClipPath(customSeries.coordinateSystem, false, customSeries) : null;
if (clipPath) {
group.setClipPath(clipPath);
} else {
group.removeClipPath();
}
this._data = data;
};
CustomChartView.prototype.incrementalPrepareRender = function (customSeries, ecModel, api) {
this.group.removeAll();
this._data = null;
};
CustomChartView.prototype.incrementalRender = function (params, customSeries, ecModel, api, payload) {
var data = customSeries.getData();
var renderItem = makeRenderItem(customSeries, data, ecModel, api);
var progressiveEls = this._progressiveEls = [];
function setIncrementalAndHoverLayer(el) {
if (!el.isGroup) {
el.incremental = true;
el.ensureState('emphasis').hoverLayer = true;
}
}
for (var idx = params.start; idx < params.end; idx++) {
var el = createOrUpdateItem(null, null, idx, renderItem(idx, payload), customSeries, this.group, data);
if (el) {
el.traverse(setIncrementalAndHoverLayer);
progressiveEls.push(el);
}
}
};
CustomChartView.prototype.eachRendered = function (cb) {
graphicUtil.traverseElements(this._progressiveEls || this.group, cb);
};
CustomChartView.prototype.filterForExposedEvent = function (eventType, query, targetEl, packedEvent) {
var elementName = query.element;
if (elementName == null || targetEl.name === elementName) {
return true;
}
// Enable to give a name on a group made by `renderItem`, and listen
// events that are triggered by its descendents.
while ((targetEl = targetEl.__hostTarget || targetEl.parent) && targetEl !== this.group) {
if (targetEl.name === elementName) {
return true;
}
}
return false;
};
CustomChartView.type = 'custom';
return CustomChartView;
}(ChartView);
export default CustomChartView;
function createEl(elOption) {
var graphicType = elOption.type;
var el;
// Those graphic elements are not shapes. They should not be
// overwritten by users, so do them first.
if (graphicType === 'path') {
var shape = elOption.shape;
// Using pathRect brings convenience to users sacle svg path.
var pathRect = shape.width != null && shape.height != null ? {
x: shape.x || 0,
y: shape.y || 0,
width: shape.width,
height: shape.height
} : null;
var pathData = getPathData(shape);
// Path is also used for icon, so layout 'center' by default.
el = graphicUtil.makePath(pathData, null, pathRect, shape.layout || 'center');
customInnerStore(el).customPathData = pathData;
} else if (graphicType === 'image') {
el = new graphicUtil.Image({});
customInnerStore(el).customImagePath = elOption.style.image;
} else if (graphicType === 'text') {
el = new graphicUtil.Text({});
// customInnerStore(el).customText = (elOption.style as TextStyleProps).text;
} else if (graphicType === 'group') {
el = new graphicUtil.Group();
} else if (graphicType === 'compoundPath') {
throw new Error('"compoundPath" is not supported yet.');
} else {
var Clz = graphicUtil.getShapeClass(graphicType);
if (!Clz) {
var errMsg = '';
if (process.env.NODE_ENV !== 'production') {
errMsg = 'graphic type "' + graphicType + '" can not be found.';
}
throwError(errMsg);
}
el = new Clz();
}
customInnerStore(el).customGraphicType = graphicType;
el.name = elOption.name;
// Compat ec4: the default z2 lift is 1. If changing the number,
// some cases probably be broken: hierarchy layout along z, like circle packing,
// where emphasis only intending to modify color/border rather than lift z2.
el.z2EmphasisLift = 1;
el.z2SelectLift = 1;
return el;
}
function updateElNormal(
// Can be null/undefined
api, el, dataIndex, elOption, attachedTxInfo, seriesModel, isInit) {
// Stop and restore before update any other attributes.
stopPreviousKeyframeAnimationAndRestore(el);
var txCfgOpt = attachedTxInfo && attachedTxInfo.normal.cfg;
if (txCfgOpt) {
// PENDING: whether use user object directly rather than clone?
// TODO:5.0 textConfig transition animation?
el.setTextConfig(txCfgOpt);
}
// Default transition ['x', 'y']
if (elOption && elOption.transition == null) {
elOption.transition = DEFAULT_TRANSITION;
}
// Do some normalization on style.
var styleOpt = elOption && elOption.style;
if (styleOpt) {
if (el.type === 'text') {
var textOptionStyle = styleOpt;
// Compatible with ec4: if `textFill` or `textStroke` exists use them.
hasOwn(textOptionStyle, 'textFill') && (textOptionStyle.fill = textOptionStyle.textFill);
hasOwn(textOptionStyle, 'textStroke') && (textOptionStyle.stroke = textOptionStyle.textStroke);
}
var decalPattern = void 0;
var decalObj = isPath(el) ? styleOpt.decal : null;
if (api && decalObj) {
decalObj.dirty = true;
decalPattern = createOrUpdatePatternFromDecal(decalObj, api);
}
// Always overwrite in case user specify this prop.
styleOpt.__decalPattern = decalPattern;
}
if (isDisplayable(el)) {
if (styleOpt) {
var decalPattern = styleOpt.__decalPattern;
if (decalPattern) {
styleOpt.decal = decalPattern;
}
}
}
applyUpdateTransition(el, elOption, seriesModel, {
dataIndex: dataIndex,
isInit: isInit,
clearStyle: true
});
applyKeyframeAnimation(el, elOption.keyframeAnimation, seriesModel);
}
function updateElOnState(state, el, elStateOpt, styleOpt, attachedTxInfo) {
var elDisplayable = el.isGroup ? null : el;
var txCfgOpt = attachedTxInfo && attachedTxInfo[state].cfg;
// PENDING:5.0 support customize scale change and transition animation?
if (elDisplayable) {
// By default support auto lift color when hover whether `emphasis` specified.
var stateObj = elDisplayable.ensureState(state);
if (styleOpt === false) {
var existingEmphasisState = elDisplayable.getState(state);
if (existingEmphasisState) {
existingEmphasisState.style = null;
}
} else {
// style is needed to enable default emphasis.
stateObj.style = styleOpt || null;
}
// If `elOption.styleEmphasis` or `elOption.emphasis.style` is `false`,
// remove hover style.
// If `elOption.textConfig` or `elOption.emphasis.textConfig` is null/undefined, it does not
// make sense. So for simplicity, we do not ditinguish `hasOwnProperty` and null/undefined.
if (txCfgOpt) {
stateObj.textConfig = txCfgOpt;
}
setDefaultStateProxy(elDisplayable);
}
}
function updateZ(el, elOption, seriesModel) {
// Group not support textContent and not support z yet.
if (el.isGroup) {
return;
}
var elDisplayable = el;
var currentZ = seriesModel.currentZ;
var currentZLevel = seriesModel.currentZLevel;
// Always erase.
elDisplayable.z = currentZ;
elDisplayable.zlevel = currentZLevel;
// z2 must not be null/undefined, otherwise sort error may occur.
var optZ2 = elOption.z2;
optZ2 != null && (elDisplayable.z2 = optZ2 || 0);
for (var i = 0; i < STATES.length; i++) {
updateZForEachState(elDisplayable, elOption, STATES[i]);
}
}
function updateZForEachState(elDisplayable, elOption, state) {
var isNormal = state === NORMAL;
var elStateOpt = isNormal ? elOption : retrieveStateOption(elOption, state);
var optZ2 = elStateOpt ? elStateOpt.z2 : null;
var stateObj;
if (optZ2 != null) {
// Do not `ensureState` until required.
stateObj = isNormal ? elDisplayable : elDisplayable.ensureState(state);
stateObj.z2 = optZ2 || 0;
}
}
function makeRenderItem(customSeries, data, ecModel, api) {
var renderItem = customSeries.get('renderItem');
var coordSys = customSeries.coordinateSystem;
var prepareResult = {};
if (coordSys) {
if (process.env.NODE_ENV !== 'production') {
assert(renderItem, 'series.render is required.');
assert(coordSys.prepareCustoms || prepareCustoms[coordSys.type], 'This coordSys does not support custom series.');
}
// `coordSys.prepareCustoms` is used for external coord sys like bmap.
prepareResult = coordSys.prepareCustoms ? coordSys.prepareCustoms(coordSys) : prepareCustoms[coordSys.type](coordSys);
}
var userAPI = defaults({
getWidth: api.getWidth,
getHeight: api.getHeight,
getZr: api.getZr,
getDevicePixelRatio: api.getDevicePixelRatio,
value: value,
style: style,
ordinalRawValue: ordinalRawValue,
styleEmphasis: styleEmphasis,
visual: visual,
barLayout: barLayout,
currentSeriesIndices: currentSeriesIndices,
font: font
}, prepareResult.api || {});
var userParams = {
// The life cycle of context: current round of rendering.
// The global life cycle is probably not necessary, because
// user can store global status by themselves.
context: {},
seriesId: customSeries.id,
seriesName: customSeries.name,
seriesIndex: customSeries.seriesIndex,
coordSys: prepareResult.coordSys,
dataInsideLength: data.count(),
encode: wrapEncodeDef(customSeries.getData())
};
// If someday intending to refactor them to a class, should consider do not
// break change: currently these attribute member are encapsulated in a closure
// so that do not need to force user to call these method with a scope.
// Do not support call `api` asynchronously without dataIndexInside input.
var currDataIndexInside;
var currItemModel;
var currItemStyleModels = {};
var currLabelModels = {};
var seriesItemStyleModels = {};
var seriesLabelModels = {};
for (var i = 0; i < STATES.length; i++) {
var stateName = STATES[i];
seriesItemStyleModels[stateName] = customSeries.getModel(PATH_ITEM_STYLE[stateName]);
seriesLabelModels[stateName] = customSeries.getModel(PATH_LABEL[stateName]);
}
function getItemModel(dataIndexInside) {
return dataIndexInside === currDataIndexInside ? currItemModel || (currItemModel = data.getItemModel(dataIndexInside)) : data.getItemModel(dataIndexInside);
}
function getItemStyleModel(dataIndexInside, state) {
return !data.hasItemOption ? seriesItemStyleModels[state] : dataIndexInside === currDataIndexInside ? currItemStyleModels[state] || (currItemStyleModels[state] = getItemModel(dataIndexInside).getModel(PATH_ITEM_STYLE[state])) : getItemModel(dataIndexInside).getModel(PATH_ITEM_STYLE[state]);
}
function getLabelModel(dataIndexInside, state) {
return !data.hasItemOption ? seriesLabelModels[state] : dataIndexInside === currDataIndexInside ? currLabelModels[state] || (currLabelModels[state] = getItemModel(dataIndexInside).getModel(PATH_LABEL[state])) : getItemModel(dataIndexInside).getModel(PATH_LABEL[state]);
}
return function (dataIndexInside, payload) {
currDataIndexInside = dataIndexInside;
currItemModel = null;
currItemStyleModels = {};
currLabelModels = {};
return renderItem && renderItem(defaults({
dataIndexInside: dataIndexInside,
dataIndex: data.getRawIndex(dataIndexInside),
// Can be used for optimization when zoom or roam.
actionType: payload ? payload.type : null
}, userParams), userAPI);
};
/**
* @public
* @param dim by default 0.
* @param dataIndexInside by default `currDataIndexInside`.
*/
function value(dim, dataIndexInside) {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
return data.getStore().get(data.getDimensionIndex(dim || 0), dataIndexInside);
}
/**
* @public
* @param dim by default 0.
* @param dataIndexInside by default `currDataIndexInside`.
*/
function ordinalRawValue(dim, dataIndexInside) {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
dim = dim || 0;
var dimInfo = data.getDimensionInfo(dim);
if (!dimInfo) {
var dimIndex = data.getDimensionIndex(dim);
return dimIndex >= 0 ? data.getStore().get(dimIndex, dataIndexInside) : undefined;
}
var val = data.get(dimInfo.name, dataIndexInside);
var ordinalMeta = dimInfo && dimInfo.ordinalMeta;
return ordinalMeta ? ordinalMeta.categories[val] : val;
}
/**
* @deprecated The original intention of `api.style` is enable to set itemStyle
* like other series. But it is not necessary and not easy to give a strict definition
* of what it returns. And since echarts5 it needs to be make compat work. So
* deprecates it since echarts5.
*
* By default, `visual` is applied to style (to support visualMap).
* `visual.color` is applied at `fill`. If user want apply visual.color on `stroke`,
* it can be implemented as:
* `api.style({stroke: api.visual('color'), fill: null})`;
*
* [Compat]: since ec5, RectText has been separated from its hosts el.
* so `api.style()` will only return the style from `itemStyle` but not handle `label`
* any more. But `series.label` config is never published in doc.
* We still compat it in `api.style()`. But not encourage to use it and will still not
* to pulish it to doc.
* @public
* @param dataIndexInside by default `currDataIndexInside`.
*/
function style(userProps, dataIndexInside) {
if (process.env.NODE_ENV !== 'production') {
warnDeprecated('api.style', 'Please write literal style directly instead.');
}
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
var style = data.getItemVisual(dataIndexInside, 'style');
var visualColor = style && style.fill;
var opacity = style && style.opacity;
var itemStyle = getItemStyleModel(dataIndexInside, NORMAL).getItemStyle();
visualColor != null && (itemStyle.fill = visualColor);
opacity != null && (itemStyle.opacity = opacity);
var opt = {
inheritColor: isString(visualColor) ? visualColor : '#000'
};
var labelModel = getLabelModel(dataIndexInside, NORMAL);
// Now that the feature of "auto adjust text fill/stroke" has been migrated to zrender
// since ec5, we should set `isAttached` as `false` here and make compat in
// `convertToEC4StyleForCustomSerise`.
var textStyle = labelStyleHelper.createTextStyle(labelModel, null, opt, false, true);
textStyle.text = labelModel.getShallow('show') ? retrieve2(customSeries.getFormattedLabel(dataIndexInside, NORMAL), getDefaultLabel(data, dataIndexInside)) : null;
var textConfig = labelStyleHelper.createTextConfig(labelModel, opt, false);
preFetchFromExtra(userProps, itemStyle);
itemStyle = convertToEC4StyleForCustomSerise(itemStyle, textStyle, textConfig);
userProps && applyUserPropsAfter(itemStyle, userProps);
itemStyle.legacy = true;
return itemStyle;
}
/**
* @deprecated The reason see `api.style()`
* @public
* @param dataIndexInside by default `currDataIndexInside`.
*/
function styleEmphasis(userProps, dataIndexInside) {
if (process.env.NODE_ENV !== 'production') {
warnDeprecated('api.styleEmphasis', 'Please write literal style directly instead.');
}
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
var itemStyle = getItemStyleModel(dataIndexInside, EMPHASIS).getItemStyle();
var labelModel = getLabelModel(dataIndexInside, EMPHASIS);
var textStyle = labelStyleHelper.createTextStyle(labelModel, null, null, true, true);
textStyle.text = labelModel.getShallow('show') ? retrieve3(customSeries.getFormattedLabel(dataIndexInside, EMPHASIS), customSeries.getFormattedLabel(dataIndexInside, NORMAL), getDefaultLabel(data, dataIndexInside)) : null;
var textConfig = labelStyleHelper.createTextConfig(labelModel, null, true);
preFetchFromExtra(userProps, itemStyle);
itemStyle = convertToEC4StyleForCustomSerise(itemStyle, textStyle, textConfig);
userProps && applyUserPropsAfter(itemStyle, userProps);
itemStyle.legacy = true;
return itemStyle;
}
function applyUserPropsAfter(itemStyle, extra) {
for (var key in extra) {
if (hasOwn(extra, key)) {
itemStyle[key] = extra[key];
}
}
}
function preFetchFromExtra(extra, itemStyle) {
// A trick to retrieve those props firstly, which are used to
// apply auto inside fill/stroke in `convertToEC4StyleForCustomSerise`.
// (It's not reasonable but only for a degree of compat)
if (extra) {
extra.textFill && (itemStyle.textFill = extra.textFill);
extra.textPosition && (itemStyle.textPosition = extra.textPosition);
}
}
/**
* @public
* @param dataIndexInside by default `currDataIndexInside`.
*/
function visual(visualType, dataIndexInside) {
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
if (hasOwn(STYLE_VISUAL_TYPE, visualType)) {
var style_1 = data.getItemVisual(dataIndexInside, 'style');
return style_1 ? style_1[STYLE_VISUAL_TYPE[visualType]] : null;
}
// Only support these visuals. Other visual might be inner tricky
// for performance (like `style`), do not expose to users.
if (hasOwn(NON_STYLE_VISUAL_PROPS, visualType)) {
return data.getItemVisual(dataIndexInside, visualType);
}
}
/**
* @public
* @return If not support, return undefined.
*/
function barLayout(opt) {
if (coordSys.type === 'cartesian2d') {
var baseAxis = coordSys.getBaseAxis();
return getLayoutOnAxis(defaults({
axis: baseAxis
}, opt));
}
}
/**
* @public
*/
function currentSeriesIndices() {
return ecModel.getCurrentSeriesIndices();
}
/**
* @public
* @return font string
*/
function font(opt) {
return labelStyleHelper.getFont(opt, ecModel);
}
}
function wrapEncodeDef(data) {
var encodeDef = {};
each(data.dimensions, function (dimName) {
var dimInfo = data.getDimensionInfo(dimName);
if (!dimInfo.isExtraCoord) {
var coordDim = dimInfo.coordDim;
var dataDims = encodeDef[coordDim] = encodeDef[coordDim] || [];
dataDims[dimInfo.coordDimIndex] = data.getDimensionIndex(dimName);
}
});
return encodeDef;
}
function createOrUpdateItem(api, existsEl, dataIndex, elOption, seriesModel, group, data) {
// [Rule]
// If `renderItem` returns `null`/`undefined`/`false`, remove the previous el if existing.
// (It seems that violate the "merge" principle, but most of users probably intuitively
// regard "return;" as "show nothing element whatever", so make a exception to meet the
// most cases.)
// The rule or "merge" see [STRATEGY_MERGE].
// If `elOption` is `null`/`undefined`/`false` (when `renderItem` returns nothing).
if (!elOption) {
group.remove(existsEl);
return;
}
var el = doCreateOrUpdateEl(api, existsEl, dataIndex, elOption, seriesModel, group);
el && data.setItemGraphicEl(dataIndex, el);
el && toggleHoverEmphasis(el, elOption.focus, elOption.blurScope, elOption.emphasisDisabled);
return el;
}
function doCreateOrUpdateEl(api, existsEl, dataIndex, elOption, seriesModel, group) {
if (process.env.NODE_ENV !== 'production') {
assert(elOption, 'should not have an null/undefined element setting');
}
var toBeReplacedIdx = -1;
var oldEl = existsEl;
if (existsEl && doesElNeedRecreate(existsEl, elOption, seriesModel)
// || (
// // PENDING: even in one-to-one mapping case, if el is marked as morph,
// // do not sure whether the el will be mapped to another el with different
// // hierarchy in Group tree. So always recreate el rather than reuse the el.
// morphHelper && morphHelper.isOneToOneFrom(el)
// )
) {
// Should keep at the original index, otherwise "merge by index" will be incorrect.
toBeReplacedIdx = indexOf(group.childrenRef(), existsEl);
existsEl = null;
}
var isInit = !existsEl;
var el = existsEl;
if (!el) {
el = createEl(elOption);
if (oldEl) {
copyElement(oldEl, el);
}
} else {
// FIMXE:NEXT unified clearState?
// If in some case the performance issue arised, consider
// do not clearState but update cached normal state directly.
el.clearStates();
}
// Need to set morph: false explictly to disable automatically morphing.
if (elOption.morph === false) {
el.disableMorphing = true;
} else if (el.disableMorphing) {
el.disableMorphing = false;
}
attachedTxInfoTmp.normal.cfg = attachedTxInfoTmp.normal.conOpt = attachedTxInfoTmp.emphasis.cfg = attachedTxInfoTmp.emphasis.conOpt = attachedTxInfoTmp.blur.cfg = attachedTxInfoTmp.blur.conOpt = attachedTxInfoTmp.select.cfg = attachedTxInfoTmp.select.conOpt = null;
attachedTxInfoTmp.isLegacy = false;
doCreateOrUpdateAttachedTx(el, dataIndex, elOption, seriesModel, isInit, attachedTxInfoTmp);
doCreateOrUpdateClipPath(el, dataIndex, elOption, seriesModel, isInit);
updateElNormal(api, el, dataIndex, elOption, attachedTxInfoTmp, seriesModel, isInit);
// `elOption.info` enables user to mount some info on
// elements and use them in event handlers.
// Update them only when user specified, otherwise, remain.
hasOwn(elOption, 'info') && (customInnerStore(el).info = elOption.info);
for (var i = 0; i < STATES.length; i++) {
var stateName = STATES[i];
if (stateName !== NORMAL) {
var otherStateOpt = retrieveStateOption(elOption, stateName);
var otherStyleOpt = retrieveStyleOptionOnState(elOption, otherStateOpt, stateName);
updateElOnState(stateName, el, otherStateOpt, otherStyleOpt, attachedTxInfoTmp);
}
}
updateZ(el, elOption, seriesModel);
if (elOption.type === 'group') {
mergeChildren(api, el, dataIndex, elOption, seriesModel);
}
if (toBeReplacedIdx >= 0) {
group.replaceAt(el, toBeReplacedIdx);
} else {
group.add(el);
}
return el;
}
// `el` must not be null/undefined.
function doesElNeedRecreate(el, elOption, seriesModel) {
var elInner = customInnerStore(el);
var elOptionType = elOption.type;
var elOptionShape = elOption.shape;
var elOptionStyle = elOption.style;
return (
// Always create new if universal transition is enabled.
// Because we do transition after render. It needs to know what old element is. Replacement will loose it.
seriesModel.isUniversalTransitionEnabled()
// If `elOptionType` is `null`, follow the merge principle.
|| elOptionType != null && elOptionType !== elInner.customGraphicType || elOptionType === 'path' && hasOwnPathData(elOptionShape) && getPathData(elOptionShape) !== elInner.customPathData || elOptionType === 'image' && hasOwn(elOptionStyle, 'image') && elOptionStyle.image !== elInner.customImagePath
// // FIXME test and remove this restriction?
// || (elOptionType === 'text'
// && hasOwn(elOptionStyle, 'text')
// && (elOptionStyle as TextStyleProps).text !== elInner.customText
// )
);
}
function doCreateOrUpdateClipPath(el, dataIndex, elOption, seriesModel, isInit) {
// Based on the "merge" principle, if no clipPath provided,
// do nothing. The exists clip will be totally removed only if
// `el.clipPath` is `false`. Otherwise it will be merged/replaced.
var clipPathOpt = elOption.clipPath;
if (clipPathOpt === false) {
if (el && el.getClipPath()) {
el.removeClipPath();
}
} else if (clipPathOpt) {
var clipPath = el.getClipPath();
if (clipPath && doesElNeedRecreate(clipPath, clipPathOpt, seriesModel)) {
clipPath = null;
}
if (!clipPath) {
clipPath = createEl(clipPathOpt);
if (process.env.NODE_ENV !== 'production') {
assert(isPath(clipPath), 'Only any type of `path` can be used in `clipPath`, rather than ' + clipPath.type + '.');
}
el.setClipPath(clipPath);
}
updateElNormal(null, clipPath, dataIndex, clipPathOpt, null, seriesModel, isInit);
}
// If not define `clipPath` in option, do nothing unnecessary.
}
function doCreateOrUpdateAttachedTx(el, dataIndex, elOption, seriesModel, isInit, attachedTxInfo) {
// Group does not support textContent temporarily until necessary.
if (el.isGroup) {
return;
}
// Normal must be called before emphasis, for `isLegacy` detection.
processTxInfo(elOption, null, attachedTxInfo);
processTxInfo(elOption, EMPHASIS, attachedTxInfo);
// If `elOption.textConfig` or `elOption.textContent` is null/undefined, it does not make sense.
// So for simplicity, if "elOption hasOwnProperty of them but be null/undefined", we do not
// trade them as set to null to el.
// Especially:
// `elOption.textContent: false` means remove textContent.
// `elOption.textContent.emphasis.style: false` means remove the style from emphasis state.
var txConOptNormal = attachedTxInfo.normal.conOpt;
var txConOptEmphasis = attachedTxInfo.emphasis.conOpt;
var txConOptBlur = attachedTxInfo.blur.conOpt;
var txConOptSelect = attachedTxInfo.select.conOpt;
if (txConOptNormal != null || txConOptEmphasis != null || txConOptSelect != null || txConOptBlur != null) {
var textContent = el.getTextContent();
if (txConOptNormal === false) {
textContent && el.removeTextContent();
} else {
txConOptNormal = attachedTxInfo.normal.conOpt = txConOptNormal || {
type: 'text'
};
if (!textContent) {
textContent = createEl(txConOptNormal);
el.setTextContent(textContent);
} else {
// If in some case the performance issue arised, consider
// do not clearState but update cached normal state directly.
textContent.clearStates();
}
updateElNormal(null, textContent, dataIndex, txConOptNormal, null, seriesModel, isInit);
var txConStlOptNormal = txConOptNormal && txConOptNormal.style;
for (var i = 0; i < STATES.length; i++) {
var stateName = STATES[i];
if (stateName !== NORMAL) {
var txConOptOtherState = attachedTxInfo[stateName].conOpt;
updateElOnState(stateName, textContent, txConOptOtherState, retrieveStyleOptionOnState(txConOptNormal, txConOptOtherState, stateName), null);
}
}
txConStlOptNormal ? textContent.dirty() : textContent.markRedraw();
}
}
}
function processTxInfo(elOption, state, attachedTxInfo) {
var stateOpt = !state ? elOption : retrieveStateOption(elOption, state);
var styleOpt = !state ? elOption.style : retrieveStyleOptionOnState(elOption, stateOpt, EMPHASIS);
var elType = elOption.type;
var txCfg = stateOpt ? stateOpt.textConfig : null;
var txConOptNormal = elOption.textContent;
var txConOpt = !txConOptNormal ? null : !state ? txConOptNormal : retrieveStateOption(txConOptNormal, state);
if (styleOpt && (
// Because emphasis style has little info to detect legacy,
// if normal is legacy, emphasis is trade as legacy.
attachedTxInfo.isLegacy || isEC4CompatibleStyle(styleOpt, elType, !!txCfg, !!txConOpt))) {
attachedTxInfo.isLegacy = true;
var convertResult = convertFromEC4CompatibleStyle(styleOpt, elType, !state);
// Explicitly specified `textConfig` and `textContent` has higher priority than
// the ones generated by legacy style. Otherwise if users use them and `api.style`
// at the same time, they not both work and hardly to known why.
if (!txCfg && convertResult.textConfig) {
txCfg = convertResult.textConfig;
}
if (!txConOpt && convertResult.textContent) {
txConOpt = convertResult.textContent;
}
}
if (!state && txConOpt) {
var txConOptNormal_1 = txConOpt;
// `textContent: {type: 'text'}`, the "type" is easy to be missing. So we tolerate it.
!txConOptNormal_1.type && (txConOptNormal_1.type = 'text');
if (process.env.NODE_ENV !== 'production') {
// Do not tolerate incorrcet type for forward compat.
assert(txConOptNormal_1.type === 'text', 'textContent.type must be "text"');
}
}
var info = !state ? attachedTxInfo.normal : attachedTxInfo[state];
info.cfg = txCfg;
info.conOpt = txConOpt;
}
function retrieveStateOption(elOption, state) {
return !state ? elOption : elOption ? elOption[state] : null;
}
function retrieveStyleOptionOnState(stateOptionNormal, stateOption, state) {
var style = stateOption && stateOption.style;
if (style == null && state === EMPHASIS && stateOptionNormal) {
style = stateOptionNormal.styleEmphasis;
}
return style;
}
// Usage:
// (1) By default, `elOption.$mergeChildren` is `'byIndex'`, which indicates
// that the existing children will not be removed, and enables the feature
// that update some of the props of some of the children simply by construct
// the returned children of `renderItem` like:
// `var children = group.children = []; children[3] = {opacity: 0.5};`
// (2) If `elOption.$mergeChildren` is `'byName'`, add/update/remove children
// by child.name. But that might be lower performance.
// (3) If `elOption.$mergeChildren` is `false`, the existing children will be
// replaced totally.
// (4) If `!elOption.children`, following the "merge" principle, nothing will
// happen.
// (5) If `elOption.$mergeChildren` is not `false` neither `'byName'` and the
// `el` is a group, and if any of the new child is null, it means to remove
// the element at the same index, if exists. On the other hand, if the new
// child is and empty object `{}`, it means to keep the element not changed.
//
// For implementation simpleness, do not provide a direct way to remove single
// child (otherwise the total indices of the children array have to be modified).
// User can remove a single child by setting its `ignore` to `true`.
function mergeChildren(api, el, dataIndex, elOption, seriesModel) {
var newChildren = elOption.children;
var newLen = newChildren ? newChildren.length : 0;
var mergeChildren = elOption.$mergeChildren;
// `diffChildrenByName` has been deprecated.
var byName = mergeChildren === 'byName' || elOption.diffChildrenByName;
var notMerge = mergeChildren === false;
// For better performance on roam update, only enter if necessary.
if (!newLen && !byName && !notMerge) {
return;
}
if (byName) {
diffGroupChildren({
api: api,
oldChildren: el.children() || [],
newChildren: newChildren || [],
dataIndex: dataIndex,
seriesModel: seriesModel,
group: el
});
return;
}
notMerge && el.removeAll();
// Mapping children of a group simply by index, which
// might be better performance.
var index = 0;
for (; index < newLen; index++) {
var newChild = newChildren[index];
var oldChild = el.childAt(index);
if (newChild) {
if (newChild.ignore == null) {
// The old child is set to be ignored if null (see comments
// below). So we need to set ignore to be false back.
newChild.ignore = false;
}
doCreateOrUpdateEl(api, oldChild, dataIndex, newChild, seriesModel, el);
} else {
if (process.env.NODE_ENV !== 'production') {
assert(oldChild, 'renderItem should not return a group containing elements' + ' as null/undefined/{} if they do not exist before.');
}
// If the new element option is null, it means to remove the old
// element. But we cannot really remove the element from the group
// directly, because the element order may not be stable when this
// element is added back. So we set the element to be ignored.
oldChild.ignore = true;
}
}
for (var i = el.childCount() - 1; i >= index; i--) {
var child = el.childAt(i);
removeChildFromGroup(el, child, seriesModel);
}
}
function removeChildFromGroup(group, child, seriesModel) {
// Do not support leave elements that are not mentioned in the latest
// `renderItem` return. Otherwise users may not have a clear and simple
// concept that how to control all of the elements.
child && applyLeaveTransition(child, customInnerStore(group).option, seriesModel);
}
function diffGroupChildren(context) {
new DataDiffer(context.oldChildren, context.newChildren, getKey, getKey, context).add(processAddUpdate).update(processAddUpdate).remove(processRemove).execute();
}
function getKey(item, idx) {
var name = item && item.name;
return name != null ? name : GROUP_DIFF_PREFIX + idx;
}
function processAddUpdate(newIndex, oldIndex) {
var context = this.context;
var childOption = newIndex != null ? context.newChildren[newIndex] : null;
var child = oldIndex != null ? context.oldChildren[oldIndex] : null;
doCreateOrUpdateEl(context.api, child, context.dataIndex, childOption, context.seriesModel, context.group);
}
function processRemove(oldIndex) {
var context = this.context;
var child = context.oldChildren[oldIndex];
child && applyLeaveTransition(child, customInnerStore(child).option, context.seriesModel);
}
/**
* @return SVG Path data.
*/
function getPathData(shape) {
// "d" follows the SVG convention.
return shape && (shape.pathData || shape.d);
}
function hasOwnPathData(shape) {
return shape && (hasOwn(shape, 'pathData') || hasOwn(shape, 'd'));
}

View File

@ -0,0 +1,49 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import CustomSeriesModel from './CustomSeries.js';
import CustomChartView from './CustomView.js';
export function install(registers) {
registers.registerChartView(CustomChartView);
registers.registerSeriesModel(CustomSeriesModel);
}

View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './effectScatter/install.js';
use(install);

View File

@ -0,0 +1,104 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import createSeriesData from '../helper/createSeriesData.js';
import SeriesModel from '../../model/Series.js';
var EffectScatterSeriesModel = /** @class */function (_super) {
__extends(EffectScatterSeriesModel, _super);
function EffectScatterSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = EffectScatterSeriesModel.type;
_this.hasSymbolVisual = true;
return _this;
}
EffectScatterSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesData(null, this, {
useEncodeDefaulter: true
});
};
EffectScatterSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
return selectors.point(data.getItemLayout(dataIndex));
};
EffectScatterSeriesModel.type = 'series.effectScatter';
EffectScatterSeriesModel.dependencies = ['grid', 'polar'];
EffectScatterSeriesModel.defaultOption = {
coordinateSystem: 'cartesian2d',
// zlevel: 0,
z: 2,
legendHoverLink: true,
effectType: 'ripple',
progressive: 0,
// When to show the effect, option: 'render'|'emphasis'
showEffectOn: 'render',
clip: true,
// Ripple effect config
rippleEffect: {
period: 4,
// Scale of ripple
scale: 2.5,
// Brush type can be fill or stroke
brushType: 'fill',
// Ripple number
number: 3
},
universalTransition: {
divideShape: 'clone'
},
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// Polar coordinate system
// polarIndex: 0,
// Geo coordinate system
// geoIndex: 0,
// symbol: null, // 图形类型
symbolSize: 10 // 图形大小半宽半径参数当图形为方向或菱形则总宽度为symbolSize * 2
// symbolRotate: null, // 图形旋转控制
// itemStyle: {
// opacity: 1
// }
};
return EffectScatterSeriesModel;
}(SeriesModel);
export default EffectScatterSeriesModel;

View File

@ -0,0 +1,99 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SymbolDraw from '../helper/SymbolDraw.js';
import EffectSymbol from '../helper/EffectSymbol.js';
import * as matrix from 'zrender/lib/core/matrix.js';
import pointsLayout from '../../layout/points.js';
import ChartView from '../../view/Chart.js';
var EffectScatterView = /** @class */function (_super) {
__extends(EffectScatterView, _super);
function EffectScatterView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = EffectScatterView.type;
return _this;
}
EffectScatterView.prototype.init = function () {
this._symbolDraw = new SymbolDraw(EffectSymbol);
};
EffectScatterView.prototype.render = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var effectSymbolDraw = this._symbolDraw;
effectSymbolDraw.updateData(data, {
clipShape: this._getClipShape(seriesModel)
});
this.group.add(effectSymbolDraw.group);
};
EffectScatterView.prototype._getClipShape = function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var clipArea = coordSys && coordSys.getArea && coordSys.getArea();
return seriesModel.get('clip', true) ? clipArea : null;
};
EffectScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
this.group.dirty();
var res = pointsLayout('').reset(seriesModel, ecModel, api);
if (res.progress) {
res.progress({
start: 0,
end: data.count(),
count: data.count()
}, data);
}
this._symbolDraw.updateLayout();
};
EffectScatterView.prototype._updateGroupTransform = function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && coordSys.getRoamTransform) {
this.group.transform = matrix.clone(coordSys.getRoamTransform());
this.group.decomposeTransform();
}
};
EffectScatterView.prototype.remove = function (ecModel, api) {
this._symbolDraw && this._symbolDraw.remove(true);
};
EffectScatterView.type = 'effectScatter';
return EffectScatterView;
}(ChartView);
export default EffectScatterView;

View File

@ -0,0 +1,51 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import EffectScatterView from './EffectScatterView.js';
import EffectScatterSeriesModel from './EffectScatterSeries.js';
import layoutPoints from '../../layout/points.js';
export function install(registers) {
registers.registerChartView(EffectScatterView);
registers.registerSeriesModel(EffectScatterSeriesModel);
registers.registerLayout(layoutPoints('effectScatter'));
}

46
frontend/node_modules/echarts/lib/chart/funnel.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './funnel/install.js';
use(install);

View File

@ -0,0 +1,144 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as zrUtil from 'zrender/lib/core/util.js';
import createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
import { defaultEmphasis } from '../../util/model.js';
import { makeSeriesEncodeForNameBased } from '../../data/helper/sourceHelper.js';
import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
import SeriesModel from '../../model/Series.js';
var FunnelSeriesModel = /** @class */function (_super) {
__extends(FunnelSeriesModel, _super);
function FunnelSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = FunnelSeriesModel.type;
return _this;
}
FunnelSeriesModel.prototype.init = function (option) {
_super.prototype.init.apply(this, arguments);
// Enable legend selection for each data item
// Use a function instead of direct access because data reference may changed
this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
// Extend labelLine emphasis
this._defaultLabelLine(option);
};
FunnelSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesDataSimply(this, {
coordDimensions: ['value'],
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
});
};
FunnelSeriesModel.prototype._defaultLabelLine = function (option) {
// Extend labelLine emphasis
defaultEmphasis(option, 'labelLine', ['show']);
var labelLineNormalOpt = option.labelLine;
var labelLineEmphasisOpt = option.emphasis.labelLine;
// Not show label line if `label.normal.show = false`
labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
};
// Overwrite
FunnelSeriesModel.prototype.getDataParams = function (dataIndex) {
var data = this.getData();
var params = _super.prototype.getDataParams.call(this, dataIndex);
var valueDim = data.mapDimension('value');
var sum = data.getSum(valueDim);
// Percent is 0 if sum is 0
params.percent = !sum ? 0 : +(data.get(valueDim, dataIndex) / sum * 100).toFixed(2);
params.$vars.push('percent');
return params;
};
FunnelSeriesModel.type = 'series.funnel';
FunnelSeriesModel.defaultOption = {
// zlevel: 0, // 一级层叠
z: 2,
legendHoverLink: true,
colorBy: 'data',
left: 80,
top: 60,
right: 80,
bottom: 60,
// width: {totalWidth} - left - right,
// height: {totalHeight} - top - bottom,
// 默认取数据最小最大值
// min: 0,
// max: 100,
minSize: '0%',
maxSize: '100%',
sort: 'descending',
orient: 'vertical',
gap: 0,
funnelAlign: 'center',
label: {
show: true,
position: 'outer'
// formatter: 标签文本格式器同Tooltip.formatter不支持异步回调
},
labelLine: {
show: true,
length: 20,
lineStyle: {
// color: 各异,
width: 1
}
},
itemStyle: {
// color: 各异,
borderColor: '#fff',
borderWidth: 1
},
emphasis: {
label: {
show: true
}
},
select: {
itemStyle: {
borderColor: '#212121'
}
}
};
return FunnelSeriesModel;
}(SeriesModel);
export default FunnelSeriesModel;

View File

@ -0,0 +1,198 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
import ChartView from '../../view/Chart.js';
import { setLabelLineStyle, getLabelLineStatesModels } from '../../label/labelGuideHelper.js';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
import { saveOldStyle } from '../../animation/basicTransition.js';
var opacityAccessPath = ['itemStyle', 'opacity'];
/**
* Piece of pie including Sector, Label, LabelLine
*/
var FunnelPiece = /** @class */function (_super) {
__extends(FunnelPiece, _super);
function FunnelPiece(data, idx) {
var _this = _super.call(this) || this;
var polygon = _this;
var labelLine = new graphic.Polyline();
var text = new graphic.Text();
polygon.setTextContent(text);
_this.setTextGuideLine(labelLine);
_this.updateData(data, idx, true);
return _this;
}
FunnelPiece.prototype.updateData = function (data, idx, firstCreate) {
var polygon = this;
var seriesModel = data.hostModel;
var itemModel = data.getItemModel(idx);
var layout = data.getItemLayout(idx);
var emphasisModel = itemModel.getModel('emphasis');
var opacity = itemModel.get(opacityAccessPath);
opacity = opacity == null ? 1 : opacity;
if (!firstCreate) {
saveOldStyle(polygon);
}
// Update common style
polygon.useStyle(data.getItemVisual(idx, 'style'));
polygon.style.lineJoin = 'round';
if (firstCreate) {
polygon.setShape({
points: layout.points
});
polygon.style.opacity = 0;
graphic.initProps(polygon, {
style: {
opacity: opacity
}
}, seriesModel, idx);
} else {
graphic.updateProps(polygon, {
style: {
opacity: opacity
},
shape: {
points: layout.points
}
}, seriesModel, idx);
}
setStatesStylesFromModel(polygon, itemModel);
this._updateLabel(data, idx);
toggleHoverEmphasis(this, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
};
FunnelPiece.prototype._updateLabel = function (data, idx) {
var polygon = this;
var labelLine = this.getTextGuideLine();
var labelText = polygon.getTextContent();
var seriesModel = data.hostModel;
var itemModel = data.getItemModel(idx);
var layout = data.getItemLayout(idx);
var labelLayout = layout.label;
var style = data.getItemVisual(idx, 'style');
var visualColor = style.fill;
setLabelStyle(
// position will not be used in setLabelStyle
labelText, getLabelStatesModels(itemModel), {
labelFetcher: data.hostModel,
labelDataIndex: idx,
defaultOpacity: style.opacity,
defaultText: data.getName(idx)
}, {
normal: {
align: labelLayout.textAlign,
verticalAlign: labelLayout.verticalAlign
}
});
polygon.setTextConfig({
local: true,
inside: !!labelLayout.inside,
insideStroke: visualColor,
// insideFill: 'auto',
outsideFill: visualColor
});
var linePoints = labelLayout.linePoints;
labelLine.setShape({
points: linePoints
});
polygon.textGuideLineConfig = {
anchor: linePoints ? new graphic.Point(linePoints[0][0], linePoints[0][1]) : null
};
// Make sure update style on labelText after setLabelStyle.
// Because setLabelStyle will replace a new style on it.
graphic.updateProps(labelText, {
style: {
x: labelLayout.x,
y: labelLayout.y
}
}, seriesModel, idx);
labelText.attr({
rotation: labelLayout.rotation,
originX: labelLayout.x,
originY: labelLayout.y,
z2: 10
});
setLabelLineStyle(polygon, getLabelLineStatesModels(itemModel), {
// Default use item visual color
stroke: visualColor
});
};
return FunnelPiece;
}(graphic.Polygon);
var FunnelView = /** @class */function (_super) {
__extends(FunnelView, _super);
function FunnelView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = FunnelView.type;
_this.ignoreLabelLineUpdate = true;
return _this;
}
FunnelView.prototype.render = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var oldData = this._data;
var group = this.group;
data.diff(oldData).add(function (idx) {
var funnelPiece = new FunnelPiece(data, idx);
data.setItemGraphicEl(idx, funnelPiece);
group.add(funnelPiece);
}).update(function (newIdx, oldIdx) {
var piece = oldData.getItemGraphicEl(oldIdx);
piece.updateData(data, newIdx);
group.add(piece);
data.setItemGraphicEl(newIdx, piece);
}).remove(function (idx) {
var piece = oldData.getItemGraphicEl(idx);
graphic.removeElementWithFadeOut(piece, seriesModel, idx);
}).execute();
this._data = data;
};
FunnelView.prototype.remove = function () {
this.group.removeAll();
this._data = null;
};
FunnelView.prototype.dispose = function () {};
FunnelView.type = 'funnel';
return FunnelView;
}(ChartView);
export default FunnelView;

View File

@ -0,0 +1,344 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as layout from '../../util/layout.js';
import { parsePercent, linearMap } from '../../util/number.js';
import { isFunction } from 'zrender/lib/core/util.js';
function getViewRect(seriesModel, api) {
return layout.getLayoutRect(seriesModel.getBoxLayoutParams(), {
width: api.getWidth(),
height: api.getHeight()
});
}
function getSortedIndices(data, sort) {
var valueDim = data.mapDimension('value');
var valueArr = data.mapArray(valueDim, function (val) {
return val;
});
var indices = [];
var isAscending = sort === 'ascending';
for (var i = 0, len = data.count(); i < len; i++) {
indices[i] = i;
}
// Add custom sortable function & none sortable opetion by "options.sort"
if (isFunction(sort)) {
indices.sort(sort);
} else if (sort !== 'none') {
indices.sort(function (a, b) {
return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
});
}
return indices;
}
function labelLayout(data) {
var seriesModel = data.hostModel;
var orient = seriesModel.get('orient');
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
var labelModel = itemModel.getModel('label');
var labelPosition = labelModel.get('position');
var labelLineModel = itemModel.getModel('labelLine');
var layout = data.getItemLayout(idx);
var points = layout.points;
var isLabelInside = labelPosition === 'inner' || labelPosition === 'inside' || labelPosition === 'center' || labelPosition === 'insideLeft' || labelPosition === 'insideRight';
var textAlign;
var textX;
var textY;
var linePoints;
if (isLabelInside) {
if (labelPosition === 'insideLeft') {
textX = (points[0][0] + points[3][0]) / 2 + 5;
textY = (points[0][1] + points[3][1]) / 2;
textAlign = 'left';
} else if (labelPosition === 'insideRight') {
textX = (points[1][0] + points[2][0]) / 2 - 5;
textY = (points[1][1] + points[2][1]) / 2;
textAlign = 'right';
} else {
textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
textAlign = 'center';
}
linePoints = [[textX, textY], [textX, textY]];
} else {
var x1 = void 0;
var y1 = void 0;
var x2 = void 0;
var y2 = void 0;
var labelLineLen = labelLineModel.get('length');
if (process.env.NODE_ENV !== 'production') {
if (orient === 'vertical' && ['top', 'bottom'].indexOf(labelPosition) > -1) {
labelPosition = 'left';
console.warn('Position error: Funnel chart on vertical orient dose not support top and bottom.');
}
if (orient === 'horizontal' && ['left', 'right'].indexOf(labelPosition) > -1) {
labelPosition = 'bottom';
console.warn('Position error: Funnel chart on horizontal orient dose not support left and right.');
}
}
if (labelPosition === 'left') {
// Left side
x1 = (points[3][0] + points[0][0]) / 2;
y1 = (points[3][1] + points[0][1]) / 2;
x2 = x1 - labelLineLen;
textX = x2 - 5;
textAlign = 'right';
} else if (labelPosition === 'right') {
// Right side
x1 = (points[1][0] + points[2][0]) / 2;
y1 = (points[1][1] + points[2][1]) / 2;
x2 = x1 + labelLineLen;
textX = x2 + 5;
textAlign = 'left';
} else if (labelPosition === 'top') {
// Top side
x1 = (points[3][0] + points[0][0]) / 2;
y1 = (points[3][1] + points[0][1]) / 2;
y2 = y1 - labelLineLen;
textY = y2 - 5;
textAlign = 'center';
} else if (labelPosition === 'bottom') {
// Bottom side
x1 = (points[1][0] + points[2][0]) / 2;
y1 = (points[1][1] + points[2][1]) / 2;
y2 = y1 + labelLineLen;
textY = y2 + 5;
textAlign = 'center';
} else if (labelPosition === 'rightTop') {
// RightTop side
x1 = orient === 'horizontal' ? points[3][0] : points[1][0];
y1 = orient === 'horizontal' ? points[3][1] : points[1][1];
if (orient === 'horizontal') {
y2 = y1 - labelLineLen;
textY = y2 - 5;
textAlign = 'center';
} else {
x2 = x1 + labelLineLen;
textX = x2 + 5;
textAlign = 'top';
}
} else if (labelPosition === 'rightBottom') {
// RightBottom side
x1 = points[2][0];
y1 = points[2][1];
if (orient === 'horizontal') {
y2 = y1 + labelLineLen;
textY = y2 + 5;
textAlign = 'center';
} else {
x2 = x1 + labelLineLen;
textX = x2 + 5;
textAlign = 'bottom';
}
} else if (labelPosition === 'leftTop') {
// LeftTop side
x1 = points[0][0];
y1 = orient === 'horizontal' ? points[0][1] : points[1][1];
if (orient === 'horizontal') {
y2 = y1 - labelLineLen;
textY = y2 - 5;
textAlign = 'center';
} else {
x2 = x1 - labelLineLen;
textX = x2 - 5;
textAlign = 'right';
}
} else if (labelPosition === 'leftBottom') {
// LeftBottom side
x1 = orient === 'horizontal' ? points[1][0] : points[3][0];
y1 = orient === 'horizontal' ? points[1][1] : points[2][1];
if (orient === 'horizontal') {
y2 = y1 + labelLineLen;
textY = y2 + 5;
textAlign = 'center';
} else {
x2 = x1 - labelLineLen;
textX = x2 - 5;
textAlign = 'right';
}
} else {
// Right side or Bottom side
x1 = (points[1][0] + points[2][0]) / 2;
y1 = (points[1][1] + points[2][1]) / 2;
if (orient === 'horizontal') {
y2 = y1 + labelLineLen;
textY = y2 + 5;
textAlign = 'center';
} else {
x2 = x1 + labelLineLen;
textX = x2 + 5;
textAlign = 'left';
}
}
if (orient === 'horizontal') {
x2 = x1;
textX = x2;
} else {
y2 = y1;
textY = y2;
}
linePoints = [[x1, y1], [x2, y2]];
}
layout.label = {
linePoints: linePoints,
x: textX,
y: textY,
verticalAlign: 'middle',
textAlign: textAlign,
inside: isLabelInside
};
});
}
export default function funnelLayout(ecModel, api) {
ecModel.eachSeriesByType('funnel', function (seriesModel) {
var data = seriesModel.getData();
var valueDim = data.mapDimension('value');
var sort = seriesModel.get('sort');
var viewRect = getViewRect(seriesModel, api);
var orient = seriesModel.get('orient');
var viewWidth = viewRect.width;
var viewHeight = viewRect.height;
var indices = getSortedIndices(data, sort);
var x = viewRect.x;
var y = viewRect.y;
var sizeExtent = orient === 'horizontal' ? [parsePercent(seriesModel.get('minSize'), viewHeight), parsePercent(seriesModel.get('maxSize'), viewHeight)] : [parsePercent(seriesModel.get('minSize'), viewWidth), parsePercent(seriesModel.get('maxSize'), viewWidth)];
var dataExtent = data.getDataExtent(valueDim);
var min = seriesModel.get('min');
var max = seriesModel.get('max');
if (min == null) {
min = Math.min(dataExtent[0], 0);
}
if (max == null) {
max = dataExtent[1];
}
var funnelAlign = seriesModel.get('funnelAlign');
var gap = seriesModel.get('gap');
var viewSize = orient === 'horizontal' ? viewWidth : viewHeight;
var itemSize = (viewSize - gap * (data.count() - 1)) / data.count();
var getLinePoints = function (idx, offset) {
// End point index is data.count() and we assign it 0
if (orient === 'horizontal') {
var val_1 = data.get(valueDim, idx) || 0;
var itemHeight = linearMap(val_1, [min, max], sizeExtent, true);
var y0 = void 0;
switch (funnelAlign) {
case 'top':
y0 = y;
break;
case 'center':
y0 = y + (viewHeight - itemHeight) / 2;
break;
case 'bottom':
y0 = y + (viewHeight - itemHeight);
break;
}
return [[offset, y0], [offset, y0 + itemHeight]];
}
var val = data.get(valueDim, idx) || 0;
var itemWidth = linearMap(val, [min, max], sizeExtent, true);
var x0;
switch (funnelAlign) {
case 'left':
x0 = x;
break;
case 'center':
x0 = x + (viewWidth - itemWidth) / 2;
break;
case 'right':
x0 = x + viewWidth - itemWidth;
break;
}
return [[x0, offset], [x0 + itemWidth, offset]];
};
if (sort === 'ascending') {
// From bottom to top
itemSize = -itemSize;
gap = -gap;
if (orient === 'horizontal') {
x += viewWidth;
} else {
y += viewHeight;
}
indices = indices.reverse();
}
for (var i = 0; i < indices.length; i++) {
var idx = indices[i];
var nextIdx = indices[i + 1];
var itemModel = data.getItemModel(idx);
if (orient === 'horizontal') {
var width = itemModel.get(['itemStyle', 'width']);
if (width == null) {
width = itemSize;
} else {
width = parsePercent(width, viewWidth);
if (sort === 'ascending') {
width = -width;
}
}
var start = getLinePoints(idx, x);
var end = getLinePoints(nextIdx, x + width);
x += width + gap;
data.setItemLayout(idx, {
points: start.concat(end.slice().reverse())
});
} else {
var height = itemModel.get(['itemStyle', 'height']);
if (height == null) {
height = itemSize;
} else {
height = parsePercent(height, viewHeight);
if (sort === 'ascending') {
height = -height;
}
}
var start = getLinePoints(idx, y);
var end = getLinePoints(nextIdx, y + height);
y += height + gap;
data.setItemLayout(idx, {
points: start.concat(end.slice().reverse())
});
}
}
labelLayout(data);
});
}

View File

@ -0,0 +1,53 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import FunnelView from './FunnelView.js';
import FunnelSeriesModel from './FunnelSeries.js';
import funnelLayout from './funnelLayout.js';
import dataFilter from '../../processor/dataFilter.js';
export function install(registers) {
registers.registerChartView(FunnelView);
registers.registerSeriesModel(FunnelSeriesModel);
registers.registerLayout(funnelLayout);
registers.registerProcessor(dataFilter('funnel'));
}

46
frontend/node_modules/echarts/lib/chart/gauge.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './gauge/install.js';
use(install);

View File

@ -0,0 +1,185 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
import SeriesModel from '../../model/Series.js';
var GaugeSeriesModel = /** @class */function (_super) {
__extends(GaugeSeriesModel, _super);
function GaugeSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = GaugeSeriesModel.type;
_this.visualStyleAccessPath = 'itemStyle';
return _this;
}
GaugeSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesDataSimply(this, ['value']);
};
GaugeSeriesModel.type = 'series.gauge';
GaugeSeriesModel.defaultOption = {
// zlevel: 0,
z: 2,
colorBy: 'data',
// 默认全局居中
center: ['50%', '50%'],
legendHoverLink: true,
radius: '75%',
startAngle: 225,
endAngle: -45,
clockwise: true,
// 最小值
min: 0,
// 最大值
max: 100,
// 分割段数默认为10
splitNumber: 10,
// 坐标轴线
axisLine: {
// 默认显示属性show控制显示与否
show: true,
roundCap: false,
lineStyle: {
color: [[1, '#E6EBF8']],
width: 10
}
},
// 坐标轴线
progress: {
// 默认显示属性show控制显示与否
show: false,
overlap: true,
width: 10,
roundCap: false,
clip: true
},
// 分隔线
splitLine: {
// 默认显示属性show控制显示与否
show: true,
// 属性length控制线长
length: 10,
distance: 10,
// 属性lineStyle详见lineStyle控制线条样式
lineStyle: {
color: '#63677A',
width: 3,
type: 'solid'
}
},
// 坐标轴小标记
axisTick: {
// 属性show控制显示与否默认不显示
show: true,
// 每份split细分多少段
splitNumber: 5,
// 属性length控制线长
length: 6,
distance: 10,
// 属性lineStyle控制线条样式
lineStyle: {
color: '#63677A',
width: 1,
type: 'solid'
}
},
axisLabel: {
show: true,
distance: 15,
// formatter: null,
color: '#464646',
fontSize: 12,
rotate: 0
},
pointer: {
icon: null,
offsetCenter: [0, 0],
show: true,
showAbove: true,
length: '60%',
width: 6,
keepAspect: false
},
anchor: {
show: false,
showAbove: false,
size: 6,
icon: 'circle',
offsetCenter: [0, 0],
keepAspect: false,
itemStyle: {
color: '#fff',
borderWidth: 0,
borderColor: '#5470c6'
}
},
title: {
show: true,
// x, y单位px
offsetCenter: [0, '20%'],
// 其余属性默认使用全局文本样式详见TEXTSTYLE
color: '#464646',
fontSize: 16,
valueAnimation: false
},
detail: {
show: true,
backgroundColor: 'rgba(0,0,0,0)',
borderWidth: 0,
borderColor: '#ccc',
width: 100,
height: null,
padding: [5, 10],
// x, y单位px
offsetCenter: [0, '40%'],
// formatter: null,
// 其余属性默认使用全局文本样式详见TEXTSTYLE
color: '#464646',
fontSize: 30,
fontWeight: 'bold',
lineHeight: 30,
valueAnimation: false
}
};
return GaugeSeriesModel;
}(SeriesModel);
export default GaugeSeriesModel;

View File

@ -0,0 +1,560 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import PointerPath from './PointerPath.js';
import * as graphic from '../../util/graphic.js';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
import { createTextStyle, setLabelValueAnimation, animateLabelValue } from '../../label/labelStyle.js';
import ChartView from '../../view/Chart.js';
import { parsePercent, round, linearMap } from '../../util/number.js';
import Sausage from '../../util/shape/sausage.js';
import { createSymbol } from '../../util/symbol.js';
import ZRImage from 'zrender/lib/graphic/Image.js';
import { extend, isFunction, isString, isNumber, each } from 'zrender/lib/core/util.js';
import { setCommonECData } from '../../util/innerStore.js';
import { normalizeArcAngles } from 'zrender/lib/core/PathProxy.js';
function parsePosition(seriesModel, api) {
var center = seriesModel.get('center');
var width = api.getWidth();
var height = api.getHeight();
var size = Math.min(width, height);
var cx = parsePercent(center[0], api.getWidth());
var cy = parsePercent(center[1], api.getHeight());
var r = parsePercent(seriesModel.get('radius'), size / 2);
return {
cx: cx,
cy: cy,
r: r
};
}
function formatLabel(value, labelFormatter) {
var label = value == null ? '' : value + '';
if (labelFormatter) {
if (isString(labelFormatter)) {
label = labelFormatter.replace('{value}', label);
} else if (isFunction(labelFormatter)) {
label = labelFormatter(value);
}
}
return label;
}
var GaugeView = /** @class */function (_super) {
__extends(GaugeView, _super);
function GaugeView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = GaugeView.type;
return _this;
}
GaugeView.prototype.render = function (seriesModel, ecModel, api) {
this.group.removeAll();
var colorList = seriesModel.get(['axisLine', 'lineStyle', 'color']);
var posInfo = parsePosition(seriesModel, api);
this._renderMain(seriesModel, ecModel, api, colorList, posInfo);
this._data = seriesModel.getData();
};
GaugeView.prototype.dispose = function () {};
GaugeView.prototype._renderMain = function (seriesModel, ecModel, api, colorList, posInfo) {
var group = this.group;
var clockwise = seriesModel.get('clockwise');
var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
var axisLineModel = seriesModel.getModel('axisLine');
var roundCap = axisLineModel.get('roundCap');
var MainPath = roundCap ? Sausage : graphic.Sector;
var showAxis = axisLineModel.get('show');
var lineStyleModel = axisLineModel.getModel('lineStyle');
var axisLineWidth = lineStyleModel.get('width');
var angles = [startAngle, endAngle];
normalizeArcAngles(angles, !clockwise);
startAngle = angles[0];
endAngle = angles[1];
var angleRangeSpan = endAngle - startAngle;
var prevEndAngle = startAngle;
var sectors = [];
for (var i = 0; showAxis && i < colorList.length; i++) {
// Clamp
var percent = Math.min(Math.max(colorList[i][0], 0), 1);
endAngle = startAngle + angleRangeSpan * percent;
var sector = new MainPath({
shape: {
startAngle: prevEndAngle,
endAngle: endAngle,
cx: posInfo.cx,
cy: posInfo.cy,
clockwise: clockwise,
r0: posInfo.r - axisLineWidth,
r: posInfo.r
},
silent: true
});
sector.setStyle({
fill: colorList[i][1]
});
sector.setStyle(lineStyleModel.getLineStyle(
// Because we use sector to simulate arc
// so the properties for stroking are useless
['color', 'width']));
sectors.push(sector);
prevEndAngle = endAngle;
}
sectors.reverse();
each(sectors, function (sector) {
return group.add(sector);
});
var getColor = function (percent) {
// Less than 0
if (percent <= 0) {
return colorList[0][1];
}
var i;
for (i = 0; i < colorList.length; i++) {
if (colorList[i][0] >= percent && (i === 0 ? 0 : colorList[i - 1][0]) < percent) {
return colorList[i][1];
}
}
// More than 1
return colorList[i - 1][1];
};
this._renderTicks(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
this._renderTitleAndDetail(seriesModel, ecModel, api, getColor, posInfo);
this._renderAnchor(seriesModel, posInfo);
this._renderPointer(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
};
GaugeView.prototype._renderTicks = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
var group = this.group;
var cx = posInfo.cx;
var cy = posInfo.cy;
var r = posInfo.r;
var minVal = +seriesModel.get('min');
var maxVal = +seriesModel.get('max');
var splitLineModel = seriesModel.getModel('splitLine');
var tickModel = seriesModel.getModel('axisTick');
var labelModel = seriesModel.getModel('axisLabel');
var splitNumber = seriesModel.get('splitNumber');
var subSplitNumber = tickModel.get('splitNumber');
var splitLineLen = parsePercent(splitLineModel.get('length'), r);
var tickLen = parsePercent(tickModel.get('length'), r);
var angle = startAngle;
var step = (endAngle - startAngle) / splitNumber;
var subStep = step / subSplitNumber;
var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
var splitLineDistance = splitLineModel.get('distance');
var unitX;
var unitY;
for (var i = 0; i <= splitNumber; i++) {
unitX = Math.cos(angle);
unitY = Math.sin(angle);
// Split line
if (splitLineModel.get('show')) {
var distance = splitLineDistance ? splitLineDistance + axisLineWidth : axisLineWidth;
var splitLine = new graphic.Line({
shape: {
x1: unitX * (r - distance) + cx,
y1: unitY * (r - distance) + cy,
x2: unitX * (r - splitLineLen - distance) + cx,
y2: unitY * (r - splitLineLen - distance) + cy
},
style: splitLineStyle,
silent: true
});
if (splitLineStyle.stroke === 'auto') {
splitLine.setStyle({
stroke: getColor(i / splitNumber)
});
}
group.add(splitLine);
}
// Label
if (labelModel.get('show')) {
var distance = labelModel.get('distance') + splitLineDistance;
var label = formatLabel(round(i / splitNumber * (maxVal - minVal) + minVal), labelModel.get('formatter'));
var autoColor = getColor(i / splitNumber);
var textStyleX = unitX * (r - splitLineLen - distance) + cx;
var textStyleY = unitY * (r - splitLineLen - distance) + cy;
var rotateType = labelModel.get('rotate');
var rotate = 0;
if (rotateType === 'radial') {
rotate = -angle + 2 * Math.PI;
if (rotate > Math.PI / 2) {
rotate += Math.PI;
}
} else if (rotateType === 'tangential') {
rotate = -angle - Math.PI / 2;
} else if (isNumber(rotateType)) {
rotate = rotateType * Math.PI / 180;
}
if (rotate === 0) {
group.add(new graphic.Text({
style: createTextStyle(labelModel, {
text: label,
x: textStyleX,
y: textStyleY,
verticalAlign: unitY < -0.8 ? 'top' : unitY > 0.8 ? 'bottom' : 'middle',
align: unitX < -0.4 ? 'left' : unitX > 0.4 ? 'right' : 'center'
}, {
inheritColor: autoColor
}),
silent: true
}));
} else {
group.add(new graphic.Text({
style: createTextStyle(labelModel, {
text: label,
x: textStyleX,
y: textStyleY,
verticalAlign: 'middle',
align: 'center'
}, {
inheritColor: autoColor
}),
silent: true,
originX: textStyleX,
originY: textStyleY,
rotation: rotate
}));
}
}
// Axis tick
if (tickModel.get('show') && i !== splitNumber) {
var distance = tickModel.get('distance');
distance = distance ? distance + axisLineWidth : axisLineWidth;
for (var j = 0; j <= subSplitNumber; j++) {
unitX = Math.cos(angle);
unitY = Math.sin(angle);
var tickLine = new graphic.Line({
shape: {
x1: unitX * (r - distance) + cx,
y1: unitY * (r - distance) + cy,
x2: unitX * (r - tickLen - distance) + cx,
y2: unitY * (r - tickLen - distance) + cy
},
silent: true,
style: tickLineStyle
});
if (tickLineStyle.stroke === 'auto') {
tickLine.setStyle({
stroke: getColor((i + j / subSplitNumber) / splitNumber)
});
}
group.add(tickLine);
angle += subStep;
}
angle -= subStep;
} else {
angle += step;
}
}
};
GaugeView.prototype._renderPointer = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
var group = this.group;
var oldData = this._data;
var oldProgressData = this._progressEls;
var progressList = [];
var showPointer = seriesModel.get(['pointer', 'show']);
var progressModel = seriesModel.getModel('progress');
var showProgress = progressModel.get('show');
var data = seriesModel.getData();
var valueDim = data.mapDimension('value');
var minVal = +seriesModel.get('min');
var maxVal = +seriesModel.get('max');
var valueExtent = [minVal, maxVal];
var angleExtent = [startAngle, endAngle];
function createPointer(idx, angle) {
var itemModel = data.getItemModel(idx);
var pointerModel = itemModel.getModel('pointer');
var pointerWidth = parsePercent(pointerModel.get('width'), posInfo.r);
var pointerLength = parsePercent(pointerModel.get('length'), posInfo.r);
var pointerStr = seriesModel.get(['pointer', 'icon']);
var pointerOffset = pointerModel.get('offsetCenter');
var pointerOffsetX = parsePercent(pointerOffset[0], posInfo.r);
var pointerOffsetY = parsePercent(pointerOffset[1], posInfo.r);
var pointerKeepAspect = pointerModel.get('keepAspect');
var pointer;
// not exist icon type will be set 'rect'
if (pointerStr) {
pointer = createSymbol(pointerStr, pointerOffsetX - pointerWidth / 2, pointerOffsetY - pointerLength, pointerWidth, pointerLength, null, pointerKeepAspect);
} else {
pointer = new PointerPath({
shape: {
angle: -Math.PI / 2,
width: pointerWidth,
r: pointerLength,
x: pointerOffsetX,
y: pointerOffsetY
}
});
}
pointer.rotation = -(angle + Math.PI / 2);
pointer.x = posInfo.cx;
pointer.y = posInfo.cy;
return pointer;
}
function createProgress(idx, endAngle) {
var roundCap = progressModel.get('roundCap');
var ProgressPath = roundCap ? Sausage : graphic.Sector;
var isOverlap = progressModel.get('overlap');
var progressWidth = isOverlap ? progressModel.get('width') : axisLineWidth / data.count();
var r0 = isOverlap ? posInfo.r - progressWidth : posInfo.r - (idx + 1) * progressWidth;
var r = isOverlap ? posInfo.r : posInfo.r - idx * progressWidth;
var progress = new ProgressPath({
shape: {
startAngle: startAngle,
endAngle: endAngle,
cx: posInfo.cx,
cy: posInfo.cy,
clockwise: clockwise,
r0: r0,
r: r
}
});
isOverlap && (progress.z2 = linearMap(data.get(valueDim, idx), [minVal, maxVal], [100, 0], true));
return progress;
}
if (showProgress || showPointer) {
data.diff(oldData).add(function (idx) {
var val = data.get(valueDim, idx);
if (showPointer) {
var pointer = createPointer(idx, startAngle);
// TODO hide pointer on NaN value?
graphic.initProps(pointer, {
rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
}, seriesModel);
group.add(pointer);
data.setItemGraphicEl(idx, pointer);
}
if (showProgress) {
var progress = createProgress(idx, startAngle);
var isClip = progressModel.get('clip');
graphic.initProps(progress, {
shape: {
endAngle: linearMap(val, valueExtent, angleExtent, isClip)
}
}, seriesModel);
group.add(progress);
// Add data index and series index for indexing the data by element
// Useful in tooltip
setCommonECData(seriesModel.seriesIndex, data.dataType, idx, progress);
progressList[idx] = progress;
}
}).update(function (newIdx, oldIdx) {
var val = data.get(valueDim, newIdx);
if (showPointer) {
var previousPointer = oldData.getItemGraphicEl(oldIdx);
var previousRotate = previousPointer ? previousPointer.rotation : startAngle;
var pointer = createPointer(newIdx, previousRotate);
pointer.rotation = previousRotate;
graphic.updateProps(pointer, {
rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
}, seriesModel);
group.add(pointer);
data.setItemGraphicEl(newIdx, pointer);
}
if (showProgress) {
var previousProgress = oldProgressData[oldIdx];
var previousEndAngle = previousProgress ? previousProgress.shape.endAngle : startAngle;
var progress = createProgress(newIdx, previousEndAngle);
var isClip = progressModel.get('clip');
graphic.updateProps(progress, {
shape: {
endAngle: linearMap(val, valueExtent, angleExtent, isClip)
}
}, seriesModel);
group.add(progress);
// Add data index and series index for indexing the data by element
// Useful in tooltip
setCommonECData(seriesModel.seriesIndex, data.dataType, newIdx, progress);
progressList[newIdx] = progress;
}
}).execute();
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
var emphasisModel = itemModel.getModel('emphasis');
var focus = emphasisModel.get('focus');
var blurScope = emphasisModel.get('blurScope');
var emphasisDisabled = emphasisModel.get('disabled');
if (showPointer) {
var pointer = data.getItemGraphicEl(idx);
var symbolStyle = data.getItemVisual(idx, 'style');
var visualColor = symbolStyle.fill;
if (pointer instanceof ZRImage) {
var pathStyle = pointer.style;
pointer.useStyle(extend({
image: pathStyle.image,
x: pathStyle.x,
y: pathStyle.y,
width: pathStyle.width,
height: pathStyle.height
}, symbolStyle));
} else {
pointer.useStyle(symbolStyle);
pointer.type !== 'pointer' && pointer.setColor(visualColor);
}
pointer.setStyle(itemModel.getModel(['pointer', 'itemStyle']).getItemStyle());
if (pointer.style.fill === 'auto') {
pointer.setStyle('fill', getColor(linearMap(data.get(valueDim, idx), valueExtent, [0, 1], true)));
}
pointer.z2EmphasisLift = 0;
setStatesStylesFromModel(pointer, itemModel);
toggleHoverEmphasis(pointer, focus, blurScope, emphasisDisabled);
}
if (showProgress) {
var progress = progressList[idx];
progress.useStyle(data.getItemVisual(idx, 'style'));
progress.setStyle(itemModel.getModel(['progress', 'itemStyle']).getItemStyle());
progress.z2EmphasisLift = 0;
setStatesStylesFromModel(progress, itemModel);
toggleHoverEmphasis(progress, focus, blurScope, emphasisDisabled);
}
});
this._progressEls = progressList;
}
};
GaugeView.prototype._renderAnchor = function (seriesModel, posInfo) {
var anchorModel = seriesModel.getModel('anchor');
var showAnchor = anchorModel.get('show');
if (showAnchor) {
var anchorSize = anchorModel.get('size');
var anchorType = anchorModel.get('icon');
var offsetCenter = anchorModel.get('offsetCenter');
var anchorKeepAspect = anchorModel.get('keepAspect');
var anchor = createSymbol(anchorType, posInfo.cx - anchorSize / 2 + parsePercent(offsetCenter[0], posInfo.r), posInfo.cy - anchorSize / 2 + parsePercent(offsetCenter[1], posInfo.r), anchorSize, anchorSize, null, anchorKeepAspect);
anchor.z2 = anchorModel.get('showAbove') ? 1 : 0;
anchor.setStyle(anchorModel.getModel('itemStyle').getItemStyle());
this.group.add(anchor);
}
};
GaugeView.prototype._renderTitleAndDetail = function (seriesModel, ecModel, api, getColor, posInfo) {
var _this = this;
var data = seriesModel.getData();
var valueDim = data.mapDimension('value');
var minVal = +seriesModel.get('min');
var maxVal = +seriesModel.get('max');
var contentGroup = new graphic.Group();
var newTitleEls = [];
var newDetailEls = [];
var hasAnimation = seriesModel.isAnimationEnabled();
var showPointerAbove = seriesModel.get(['pointer', 'showAbove']);
data.diff(this._data).add(function (idx) {
newTitleEls[idx] = new graphic.Text({
silent: true
});
newDetailEls[idx] = new graphic.Text({
silent: true
});
}).update(function (idx, oldIdx) {
newTitleEls[idx] = _this._titleEls[oldIdx];
newDetailEls[idx] = _this._detailEls[oldIdx];
}).execute();
data.each(function (idx) {
var itemModel = data.getItemModel(idx);
var value = data.get(valueDim, idx);
var itemGroup = new graphic.Group();
var autoColor = getColor(linearMap(value, [minVal, maxVal], [0, 1], true));
var itemTitleModel = itemModel.getModel('title');
if (itemTitleModel.get('show')) {
var titleOffsetCenter = itemTitleModel.get('offsetCenter');
var titleX = posInfo.cx + parsePercent(titleOffsetCenter[0], posInfo.r);
var titleY = posInfo.cy + parsePercent(titleOffsetCenter[1], posInfo.r);
var labelEl = newTitleEls[idx];
labelEl.attr({
z2: showPointerAbove ? 0 : 2,
style: createTextStyle(itemTitleModel, {
x: titleX,
y: titleY,
text: data.getName(idx),
align: 'center',
verticalAlign: 'middle'
}, {
inheritColor: autoColor
})
});
itemGroup.add(labelEl);
}
var itemDetailModel = itemModel.getModel('detail');
if (itemDetailModel.get('show')) {
var detailOffsetCenter = itemDetailModel.get('offsetCenter');
var detailX = posInfo.cx + parsePercent(detailOffsetCenter[0], posInfo.r);
var detailY = posInfo.cy + parsePercent(detailOffsetCenter[1], posInfo.r);
var width = parsePercent(itemDetailModel.get('width'), posInfo.r);
var height = parsePercent(itemDetailModel.get('height'), posInfo.r);
var detailColor = seriesModel.get(['progress', 'show']) ? data.getItemVisual(idx, 'style').fill : autoColor;
var labelEl = newDetailEls[idx];
var formatter_1 = itemDetailModel.get('formatter');
labelEl.attr({
z2: showPointerAbove ? 0 : 2,
style: createTextStyle(itemDetailModel, {
x: detailX,
y: detailY,
text: formatLabel(value, formatter_1),
width: isNaN(width) ? null : width,
height: isNaN(height) ? null : height,
align: 'center',
verticalAlign: 'middle'
}, {
inheritColor: detailColor
})
});
setLabelValueAnimation(labelEl, {
normal: itemDetailModel
}, value, function (value) {
return formatLabel(value, formatter_1);
});
hasAnimation && animateLabelValue(labelEl, idx, data, seriesModel, {
getFormattedLabel: function (labelDataIndex, status, dataType, labelDimIndex, fmt, extendParams) {
return formatLabel(extendParams ? extendParams.interpolatedValue : value, formatter_1);
}
});
itemGroup.add(labelEl);
}
contentGroup.add(itemGroup);
});
this.group.add(contentGroup);
this._titleEls = newTitleEls;
this._detailEls = newDetailEls;
};
GaugeView.type = 'gauge';
return GaugeView;
}(ChartView);
export default GaugeView;

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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import Path from 'zrender/lib/graphic/Path.js';
var PointerShape = /** @class */function () {
function PointerShape() {
this.angle = 0;
this.width = 10;
this.r = 10;
this.x = 0;
this.y = 0;
}
return PointerShape;
}();
var PointerPath = /** @class */function (_super) {
__extends(PointerPath, _super);
function PointerPath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'pointer';
return _this;
}
PointerPath.prototype.getDefaultShape = function () {
return new PointerShape();
};
PointerPath.prototype.buildPath = function (ctx, shape) {
var mathCos = Math.cos;
var mathSin = Math.sin;
var r = shape.r;
var width = shape.width;
var angle = shape.angle;
var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
angle = shape.angle - Math.PI / 2;
ctx.moveTo(x, y);
ctx.lineTo(shape.x + mathCos(angle) * width, shape.y + mathSin(angle) * width);
ctx.lineTo(shape.x + mathCos(shape.angle) * r, shape.y + mathSin(shape.angle) * r);
ctx.lineTo(shape.x - mathCos(angle) * width, shape.y - mathSin(angle) * width);
ctx.lineTo(x, y);
};
return PointerPath;
}(Path);
export default PointerPath;

View File

@ -0,0 +1,49 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import GaugeView from './GaugeView.js';
import GaugeSeriesModel from './GaugeSeries.js';
export function install(registers) {
registers.registerChartView(GaugeView);
registers.registerSeriesModel(GaugeSeriesModel);
}

46
frontend/node_modules/echarts/lib/chart/graph.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './graph/install.js';
use(install);

View File

@ -0,0 +1,275 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SeriesData from '../../data/SeriesData.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { defaultEmphasis } from '../../util/model.js';
import Model from '../../model/Model.js';
import createGraphFromNodeEdge from '../helper/createGraphFromNodeEdge.js';
import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
import SeriesModel from '../../model/Series.js';
import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup.js';
import { defaultSeriesFormatTooltip } from '../../component/tooltip/seriesFormatTooltip.js';
import { initCurvenessList, createEdgeMapForCurveness } from '../helper/multipleGraphEdgeHelper.js';
var GraphSeriesModel = /** @class */function (_super) {
__extends(GraphSeriesModel, _super);
function GraphSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = GraphSeriesModel.type;
_this.hasSymbolVisual = true;
return _this;
}
GraphSeriesModel.prototype.init = function (option) {
_super.prototype.init.apply(this, arguments);
var self = this;
function getCategoriesData() {
return self._categoriesData;
}
// Provide data for legend select
this.legendVisualProvider = new LegendVisualProvider(getCategoriesData, getCategoriesData);
this.fillDataTextStyle(option.edges || option.links);
this._updateCategoriesData();
};
GraphSeriesModel.prototype.mergeOption = function (option) {
_super.prototype.mergeOption.apply(this, arguments);
this.fillDataTextStyle(option.edges || option.links);
this._updateCategoriesData();
};
GraphSeriesModel.prototype.mergeDefaultAndTheme = function (option) {
_super.prototype.mergeDefaultAndTheme.apply(this, arguments);
defaultEmphasis(option, 'edgeLabel', ['show']);
};
GraphSeriesModel.prototype.getInitialData = function (option, ecModel) {
var edges = option.edges || option.links || [];
var nodes = option.data || option.nodes || [];
var self = this;
if (nodes && edges) {
// auto curveness
initCurvenessList(this);
var graph = createGraphFromNodeEdge(nodes, edges, this, true, beforeLink);
zrUtil.each(graph.edges, function (edge) {
createEdgeMapForCurveness(edge.node1, edge.node2, this, edge.dataIndex);
}, this);
return graph.data;
}
function beforeLink(nodeData, edgeData) {
// Overwrite nodeData.getItemModel to
nodeData.wrapMethod('getItemModel', function (model) {
var categoriesModels = self._categoriesModels;
var categoryIdx = model.getShallow('category');
var categoryModel = categoriesModels[categoryIdx];
if (categoryModel) {
categoryModel.parentModel = model.parentModel;
model.parentModel = categoryModel;
}
return model;
});
// TODO Inherit resolveParentPath by default in Model#getModel?
var oldGetModel = Model.prototype.getModel;
function newGetModel(path, parentModel) {
var model = oldGetModel.call(this, path, parentModel);
model.resolveParentPath = resolveParentPath;
return model;
}
edgeData.wrapMethod('getItemModel', function (model) {
model.resolveParentPath = resolveParentPath;
model.getModel = newGetModel;
return model;
});
function resolveParentPath(pathArr) {
if (pathArr && (pathArr[0] === 'label' || pathArr[1] === 'label')) {
var newPathArr = pathArr.slice();
if (pathArr[0] === 'label') {
newPathArr[0] = 'edgeLabel';
} else if (pathArr[1] === 'label') {
newPathArr[1] = 'edgeLabel';
}
return newPathArr;
}
return pathArr;
}
}
};
GraphSeriesModel.prototype.getGraph = function () {
return this.getData().graph;
};
GraphSeriesModel.prototype.getEdgeData = function () {
return this.getGraph().edgeData;
};
GraphSeriesModel.prototype.getCategoriesData = function () {
return this._categoriesData;
};
GraphSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
if (dataType === 'edge') {
var nodeData = this.getData();
var params = this.getDataParams(dataIndex, dataType);
var edge = nodeData.graph.getEdgeByIndex(dataIndex);
var sourceName = nodeData.getName(edge.node1.dataIndex);
var targetName = nodeData.getName(edge.node2.dataIndex);
var nameArr = [];
sourceName != null && nameArr.push(sourceName);
targetName != null && nameArr.push(targetName);
return createTooltipMarkup('nameValue', {
name: nameArr.join(' > '),
value: params.value,
noValue: params.value == null
});
}
// dataType === 'node' or empty
var nodeMarkup = defaultSeriesFormatTooltip({
series: this,
dataIndex: dataIndex,
multipleSeries: multipleSeries
});
return nodeMarkup;
};
GraphSeriesModel.prototype._updateCategoriesData = function () {
var categories = zrUtil.map(this.option.categories || [], function (category) {
// Data must has value
return category.value != null ? category : zrUtil.extend({
value: 0
}, category);
});
var categoriesData = new SeriesData(['value'], this);
categoriesData.initData(categories);
this._categoriesData = categoriesData;
this._categoriesModels = categoriesData.mapArray(function (idx) {
return categoriesData.getItemModel(idx);
});
};
GraphSeriesModel.prototype.setZoom = function (zoom) {
this.option.zoom = zoom;
};
GraphSeriesModel.prototype.setCenter = function (center) {
this.option.center = center;
};
GraphSeriesModel.prototype.isAnimationEnabled = function () {
return _super.prototype.isAnimationEnabled.call(this)
// Not enable animation when do force layout
&& !(this.get('layout') === 'force' && this.get(['force', 'layoutAnimation']));
};
GraphSeriesModel.type = 'series.graph';
GraphSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
GraphSeriesModel.defaultOption = {
// zlevel: 0,
z: 2,
coordinateSystem: 'view',
// Default option for all coordinate systems
// xAxisIndex: 0,
// yAxisIndex: 0,
// polarIndex: 0,
// geoIndex: 0,
legendHoverLink: true,
layout: null,
// Configuration of circular layout
circular: {
rotateLabel: false
},
// Configuration of force directed layout
force: {
initLayout: null,
// Node repulsion. Can be an array to represent range.
repulsion: [0, 50],
gravity: 0.1,
// Initial friction
friction: 0.6,
// Edge length. Can be an array to represent range.
edgeLength: 30,
layoutAnimation: true
},
left: 'center',
top: 'center',
// right: null,
// bottom: null,
// width: '80%',
// height: '80%',
symbol: 'circle',
symbolSize: 10,
edgeSymbol: ['none', 'none'],
edgeSymbolSize: 10,
edgeLabel: {
position: 'middle',
distance: 5
},
draggable: false,
roam: false,
// Default on center of graph
center: null,
zoom: 1,
// Symbol size scale ratio in roam
nodeScaleRatio: 0.6,
// cursor: null,
// categories: [],
// data: []
// Or
// nodes: []
//
// links: []
// Or
// edges: []
label: {
show: false,
formatter: '{b}'
},
itemStyle: {},
lineStyle: {
color: '#aaa',
width: 1,
opacity: 0.5
},
emphasis: {
scale: true,
label: {
show: true
}
},
select: {
itemStyle: {
borderColor: '#212121'
}
}
};
return GraphSeriesModel;
}(SeriesModel);
export default GraphSeriesModel;

View File

@ -0,0 +1,266 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SymbolDraw from '../helper/SymbolDraw.js';
import LineDraw from '../helper/LineDraw.js';
import RoamController from '../../component/helper/RoamController.js';
import * as roamHelper from '../../component/helper/roamHelper.js';
import { onIrrelevantElement } from '../../component/helper/cursorHelper.js';
import * as graphic from '../../util/graphic.js';
import adjustEdge from './adjustEdge.js';
import { getNodeGlobalScale } from './graphHelper.js';
import ChartView from '../../view/Chart.js';
import { getECData } from '../../util/innerStore.js';
import { simpleLayoutEdge } from './simpleLayoutHelper.js';
import { circularLayout, rotateNodeLabel } from './circularLayoutHelper.js';
function isViewCoordSys(coordSys) {
return coordSys.type === 'view';
}
var GraphView = /** @class */function (_super) {
__extends(GraphView, _super);
function GraphView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = GraphView.type;
return _this;
}
GraphView.prototype.init = function (ecModel, api) {
var symbolDraw = new SymbolDraw();
var lineDraw = new LineDraw();
var group = this.group;
this._controller = new RoamController(api.getZr());
this._controllerHost = {
target: group
};
group.add(symbolDraw.group);
group.add(lineDraw.group);
this._symbolDraw = symbolDraw;
this._lineDraw = lineDraw;
this._firstRender = true;
};
GraphView.prototype.render = function (seriesModel, ecModel, api) {
var _this = this;
var coordSys = seriesModel.coordinateSystem;
this._model = seriesModel;
var symbolDraw = this._symbolDraw;
var lineDraw = this._lineDraw;
var group = this.group;
if (isViewCoordSys(coordSys)) {
var groupNewProp = {
x: coordSys.x,
y: coordSys.y,
scaleX: coordSys.scaleX,
scaleY: coordSys.scaleY
};
if (this._firstRender) {
group.attr(groupNewProp);
} else {
graphic.updateProps(group, groupNewProp, seriesModel);
}
}
// Fix edge contact point with node
adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
var data = seriesModel.getData();
symbolDraw.updateData(data);
var edgeData = seriesModel.getEdgeData();
// TODO: TYPE
lineDraw.updateData(edgeData);
this._updateNodeAndLinkScale();
this._updateController(seriesModel, ecModel, api);
clearTimeout(this._layoutTimeout);
var forceLayout = seriesModel.forceLayout;
var layoutAnimation = seriesModel.get(['force', 'layoutAnimation']);
if (forceLayout) {
this._startForceLayoutIteration(forceLayout, layoutAnimation);
}
var layout = seriesModel.get('layout');
data.graph.eachNode(function (node) {
var idx = node.dataIndex;
var el = node.getGraphicEl();
var itemModel = node.getModel();
if (!el) {
return;
}
// Update draggable
el.off('drag').off('dragend');
var draggable = itemModel.get('draggable');
if (draggable) {
el.on('drag', function (e) {
switch (layout) {
case 'force':
forceLayout.warmUp();
!_this._layouting && _this._startForceLayoutIteration(forceLayout, layoutAnimation);
forceLayout.setFixed(idx);
// Write position back to layout
data.setItemLayout(idx, [el.x, el.y]);
break;
case 'circular':
data.setItemLayout(idx, [el.x, el.y]);
// mark node fixed
node.setLayout({
fixed: true
}, true);
// recalculate circular layout
circularLayout(seriesModel, 'symbolSize', node, [e.offsetX, e.offsetY]);
_this.updateLayout(seriesModel);
break;
case 'none':
default:
data.setItemLayout(idx, [el.x, el.y]);
// update edge
simpleLayoutEdge(seriesModel.getGraph(), seriesModel);
_this.updateLayout(seriesModel);
break;
}
}).on('dragend', function () {
if (forceLayout) {
forceLayout.setUnfixed(idx);
}
});
}
el.setDraggable(draggable, !!itemModel.get('cursor'));
var focus = itemModel.get(['emphasis', 'focus']);
if (focus === 'adjacency') {
getECData(el).focus = node.getAdjacentDataIndices();
}
});
data.graph.eachEdge(function (edge) {
var el = edge.getGraphicEl();
var focus = edge.getModel().get(['emphasis', 'focus']);
if (!el) {
return;
}
if (focus === 'adjacency') {
getECData(el).focus = {
edge: [edge.dataIndex],
node: [edge.node1.dataIndex, edge.node2.dataIndex]
};
}
});
var circularRotateLabel = seriesModel.get('layout') === 'circular' && seriesModel.get(['circular', 'rotateLabel']);
var cx = data.getLayout('cx');
var cy = data.getLayout('cy');
data.graph.eachNode(function (node) {
rotateNodeLabel(node, circularRotateLabel, cx, cy);
});
this._firstRender = false;
};
GraphView.prototype.dispose = function () {
this.remove();
this._controller && this._controller.dispose();
this._controllerHost = null;
};
GraphView.prototype._startForceLayoutIteration = function (forceLayout, layoutAnimation) {
var self = this;
(function step() {
forceLayout.step(function (stopped) {
self.updateLayout(self._model);
(self._layouting = !stopped) && (layoutAnimation ? self._layoutTimeout = setTimeout(step, 16) : step());
});
})();
};
GraphView.prototype._updateController = function (seriesModel, ecModel, api) {
var _this = this;
var controller = this._controller;
var controllerHost = this._controllerHost;
var group = this.group;
controller.setPointerChecker(function (e, x, y) {
var rect = group.getBoundingRect();
rect.applyTransform(group.transform);
return rect.contain(x, y) && !onIrrelevantElement(e, api, seriesModel);
});
if (!isViewCoordSys(seriesModel.coordinateSystem)) {
controller.disable();
return;
}
controller.enable(seriesModel.get('roam'));
controllerHost.zoomLimit = seriesModel.get('scaleLimit');
controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
controller.off('pan').off('zoom').on('pan', function (e) {
roamHelper.updateViewOnPan(controllerHost, e.dx, e.dy);
api.dispatchAction({
seriesId: seriesModel.id,
type: 'graphRoam',
dx: e.dx,
dy: e.dy
});
}).on('zoom', function (e) {
roamHelper.updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
api.dispatchAction({
seriesId: seriesModel.id,
type: 'graphRoam',
zoom: e.scale,
originX: e.originX,
originY: e.originY
});
_this._updateNodeAndLinkScale();
adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
_this._lineDraw.updateLayout();
// Only update label layout on zoom
api.updateLabelLayout();
});
};
GraphView.prototype._updateNodeAndLinkScale = function () {
var seriesModel = this._model;
var data = seriesModel.getData();
var nodeScale = getNodeGlobalScale(seriesModel);
data.eachItemGraphicEl(function (el, idx) {
el && el.setSymbolScale(nodeScale);
});
};
GraphView.prototype.updateLayout = function (seriesModel) {
adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
this._symbolDraw.updateLayout();
this._lineDraw.updateLayout();
};
GraphView.prototype.remove = function () {
clearTimeout(this._layoutTimeout);
this._layouting = false;
this._layoutTimeout = null;
this._symbolDraw && this._symbolDraw.remove();
this._lineDraw && this._lineDraw.remove();
};
GraphView.type = 'graph';
return GraphView;
}(ChartView);
export default GraphView;

View File

@ -0,0 +1,173 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as curveTool from 'zrender/lib/core/curve.js';
import * as vec2 from 'zrender/lib/core/vector.js';
import { getSymbolSize } from './graphHelper.js';
var v1 = [];
var v2 = [];
var v3 = [];
var quadraticAt = curveTool.quadraticAt;
var v2DistSquare = vec2.distSquare;
var mathAbs = Math.abs;
function intersectCurveCircle(curvePoints, center, radius) {
var p0 = curvePoints[0];
var p1 = curvePoints[1];
var p2 = curvePoints[2];
var d = Infinity;
var t;
var radiusSquare = radius * radius;
var interval = 0.1;
for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
if (diff < d) {
d = diff;
t = _t;
}
}
// Assume the segment is monotoneFind root through Bisection method
// At most 32 iteration
for (var i = 0; i < 32; i++) {
// let prev = t - interval;
var next = t + interval;
// v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
// v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
var diff = v2DistSquare(v2, center) - radiusSquare;
if (mathAbs(diff) < 1e-2) {
break;
}
// let prevDiff = v2DistSquare(v1, center) - radiusSquare;
var nextDiff = v2DistSquare(v3, center) - radiusSquare;
interval /= 2;
if (diff < 0) {
if (nextDiff >= 0) {
t = t + interval;
} else {
t = t - interval;
}
} else {
if (nextDiff >= 0) {
t = t - interval;
} else {
t = t + interval;
}
}
}
return t;
}
// Adjust edge to avoid
export default function adjustEdge(graph, scale) {
var tmp0 = [];
var quadraticSubdivide = curveTool.quadraticSubdivide;
var pts = [[], [], []];
var pts2 = [[], []];
var v = [];
scale /= 2;
graph.eachEdge(function (edge, idx) {
var linePoints = edge.getLayout();
var fromSymbol = edge.getVisual('fromSymbol');
var toSymbol = edge.getVisual('toSymbol');
if (!linePoints.__original) {
linePoints.__original = [vec2.clone(linePoints[0]), vec2.clone(linePoints[1])];
if (linePoints[2]) {
linePoints.__original.push(vec2.clone(linePoints[2]));
}
}
var originalPoints = linePoints.__original;
// Quadratic curve
if (linePoints[2] != null) {
vec2.copy(pts[0], originalPoints[0]);
vec2.copy(pts[1], originalPoints[2]);
vec2.copy(pts[2], originalPoints[1]);
if (fromSymbol && fromSymbol !== 'none') {
var symbolSize = getSymbolSize(edge.node1);
var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale);
// Subdivide and get the second
quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
pts[0][0] = tmp0[3];
pts[1][0] = tmp0[4];
quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
pts[0][1] = tmp0[3];
pts[1][1] = tmp0[4];
}
if (toSymbol && toSymbol !== 'none') {
var symbolSize = getSymbolSize(edge.node2);
var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale);
// Subdivide and get the first
quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
pts[1][0] = tmp0[1];
pts[2][0] = tmp0[2];
quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
pts[1][1] = tmp0[1];
pts[2][1] = tmp0[2];
}
// Copy back to layout
vec2.copy(linePoints[0], pts[0]);
vec2.copy(linePoints[1], pts[2]);
vec2.copy(linePoints[2], pts[1]);
}
// Line
else {
vec2.copy(pts2[0], originalPoints[0]);
vec2.copy(pts2[1], originalPoints[1]);
vec2.sub(v, pts2[1], pts2[0]);
vec2.normalize(v, v);
if (fromSymbol && fromSymbol !== 'none') {
var symbolSize = getSymbolSize(edge.node1);
vec2.scaleAndAdd(pts2[0], pts2[0], v, symbolSize * scale);
}
if (toSymbol && toSymbol !== 'none') {
var symbolSize = getSymbolSize(edge.node2);
vec2.scaleAndAdd(pts2[1], pts2[1], v, -symbolSize * scale);
}
vec2.copy(linePoints[0], pts2[0]);
vec2.copy(linePoints[1], pts2[1]);
}
});
}

View File

@ -0,0 +1,74 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { isNumber } from 'zrender/lib/core/util.js';
export default function categoryFilter(ecModel) {
var legendModels = ecModel.findComponents({
mainType: 'legend'
});
if (!legendModels || !legendModels.length) {
return;
}
ecModel.eachSeriesByType('graph', function (graphSeries) {
var categoriesData = graphSeries.getCategoriesData();
var graph = graphSeries.getGraph();
var data = graph.data;
var categoryNames = categoriesData.mapArray(categoriesData.getName);
data.filterSelf(function (idx) {
var model = data.getItemModel(idx);
var category = model.getShallow('category');
if (category != null) {
if (isNumber(category)) {
category = categoryNames[category];
}
// If in any legend component the status is not selected.
for (var i = 0; i < legendModels.length; i++) {
if (!legendModels[i].isSelected(category)) {
return false;
}
}
}
return true;
});
});
}

View File

@ -0,0 +1,90 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { extend, isString } from 'zrender/lib/core/util.js';
export default function categoryVisual(ecModel) {
var paletteScope = {};
ecModel.eachSeriesByType('graph', function (seriesModel) {
var categoriesData = seriesModel.getCategoriesData();
var data = seriesModel.getData();
var categoryNameIdxMap = {};
categoriesData.each(function (idx) {
var name = categoriesData.getName(idx);
// Add prefix to avoid conflict with Object.prototype.
categoryNameIdxMap['ec-' + name] = idx;
var itemModel = categoriesData.getItemModel(idx);
var style = itemModel.getModel('itemStyle').getItemStyle();
if (!style.fill) {
// Get color from palette.
style.fill = seriesModel.getColorFromPalette(name, paletteScope);
}
categoriesData.setItemVisual(idx, 'style', style);
var symbolVisualList = ['symbol', 'symbolSize', 'symbolKeepAspect'];
for (var i = 0; i < symbolVisualList.length; i++) {
var symbolVisual = itemModel.getShallow(symbolVisualList[i], true);
if (symbolVisual != null) {
categoriesData.setItemVisual(idx, symbolVisualList[i], symbolVisual);
}
}
});
// Assign category color to visual
if (categoriesData.count()) {
data.each(function (idx) {
var model = data.getItemModel(idx);
var categoryIdx = model.getShallow('category');
if (categoryIdx != null) {
if (isString(categoryIdx)) {
categoryIdx = categoryNameIdxMap['ec-' + categoryIdx];
}
var categoryStyle = categoriesData.getItemVisual(categoryIdx, 'style');
var style = data.ensureUniqueItemVisual(idx, 'style');
extend(style, categoryStyle);
var visualList = ['symbol', 'symbolSize', 'symbolKeepAspect'];
for (var i = 0; i < visualList.length; i++) {
data.setItemVisual(idx, visualList[i], categoriesData.getItemVisual(categoryIdx, visualList[i]));
}
}
});
}
});
}

View File

@ -0,0 +1,51 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { circularLayout } from './circularLayoutHelper.js';
export default function graphCircularLayout(ecModel) {
ecModel.eachSeriesByType('graph', function (seriesModel) {
if (seriesModel.get('layout') === 'circular') {
circularLayout(seriesModel, 'symbolSize');
}
});
}

View File

@ -0,0 +1,191 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as vec2 from 'zrender/lib/core/vector.js';
import { getSymbolSize, getNodeGlobalScale } from './graphHelper.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { getCurvenessForEdge } from '../helper/multipleGraphEdgeHelper.js';
var PI = Math.PI;
var _symbolRadiansHalf = [];
/**
* `basedOn` can be:
* 'value':
* This layout is not accurate and have same bad case. For example,
* if the min value is very smaller than the max value, the nodes
* with the min value probably overlap even though there is enough
* space to layout them. So we only use this approach in the as the
* init layout of the force layout.
* FIXME
* Probably we do not need this method any more but use
* `basedOn: 'symbolSize'` in force layout if
* delay its init operations to GraphView.
* 'symbolSize':
* This approach work only if all of the symbol size calculated.
* That is, the progressive rendering is not applied to graph.
* FIXME
* If progressive rendering is applied to graph some day,
* probably we have to use `basedOn: 'value'`.
*/
export function circularLayout(seriesModel, basedOn, draggingNode, pointer) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && coordSys.type !== 'view') {
return;
}
var rect = coordSys.getBoundingRect();
var nodeData = seriesModel.getData();
var graph = nodeData.graph;
var cx = rect.width / 2 + rect.x;
var cy = rect.height / 2 + rect.y;
var r = Math.min(rect.width, rect.height) / 2;
var count = nodeData.count();
nodeData.setLayout({
cx: cx,
cy: cy
});
if (!count) {
return;
}
if (draggingNode) {
var _a = coordSys.pointToData(pointer),
tempX = _a[0],
tempY = _a[1];
var v = [tempX - cx, tempY - cy];
vec2.normalize(v, v);
vec2.scale(v, v, r);
draggingNode.setLayout([cx + v[0], cy + v[1]], true);
var circularRotateLabel = seriesModel.get(['circular', 'rotateLabel']);
rotateNodeLabel(draggingNode, circularRotateLabel, cx, cy);
}
_layoutNodesBasedOn[basedOn](seriesModel, graph, nodeData, r, cx, cy, count);
graph.eachEdge(function (edge, index) {
var curveness = zrUtil.retrieve3(edge.getModel().get(['lineStyle', 'curveness']), getCurvenessForEdge(edge, seriesModel, index), 0);
var p1 = vec2.clone(edge.node1.getLayout());
var p2 = vec2.clone(edge.node2.getLayout());
var cp1;
var x12 = (p1[0] + p2[0]) / 2;
var y12 = (p1[1] + p2[1]) / 2;
if (+curveness) {
curveness *= 3;
cp1 = [cx * curveness + x12 * (1 - curveness), cy * curveness + y12 * (1 - curveness)];
}
edge.setLayout([p1, p2, cp1]);
});
}
var _layoutNodesBasedOn = {
value: function (seriesModel, graph, nodeData, r, cx, cy, count) {
var angle = 0;
var sum = nodeData.getSum('value');
var unitAngle = Math.PI * 2 / (sum || count);
graph.eachNode(function (node) {
var value = node.getValue('value');
var radianHalf = unitAngle * (sum ? value : 1) / 2;
angle += radianHalf;
node.setLayout([r * Math.cos(angle) + cx, r * Math.sin(angle) + cy]);
angle += radianHalf;
});
},
symbolSize: function (seriesModel, graph, nodeData, r, cx, cy, count) {
var sumRadian = 0;
_symbolRadiansHalf.length = count;
var nodeScale = getNodeGlobalScale(seriesModel);
graph.eachNode(function (node) {
var symbolSize = getSymbolSize(node);
// Normally this case will not happen, but we still add
// some the defensive code (2px is an arbitrary value).
isNaN(symbolSize) && (symbolSize = 2);
symbolSize < 0 && (symbolSize = 0);
symbolSize *= nodeScale;
var symbolRadianHalf = Math.asin(symbolSize / 2 / r);
// when `symbolSize / 2` is bigger than `r`.
isNaN(symbolRadianHalf) && (symbolRadianHalf = PI / 2);
_symbolRadiansHalf[node.dataIndex] = symbolRadianHalf;
sumRadian += symbolRadianHalf * 2;
});
var halfRemainRadian = (2 * PI - sumRadian) / count / 2;
var angle = 0;
graph.eachNode(function (node) {
var radianHalf = halfRemainRadian + _symbolRadiansHalf[node.dataIndex];
angle += radianHalf;
// init circular layout for
// 1. layout undefined node
// 2. not fixed node
(!node.getLayout() || !node.getLayout().fixed) && node.setLayout([r * Math.cos(angle) + cx, r * Math.sin(angle) + cy]);
angle += radianHalf;
});
}
};
export function rotateNodeLabel(node, circularRotateLabel, cx, cy) {
var el = node.getGraphicEl();
// need to check if el exists. '-' value may not create node element.
if (!el) {
return;
}
var nodeModel = node.getModel();
var labelRotate = nodeModel.get(['label', 'rotate']) || 0;
var symbolPath = el.getSymbolPath();
if (circularRotateLabel) {
var pos = node.getLayout();
var rad = Math.atan2(pos[1] - cy, pos[0] - cx);
if (rad < 0) {
rad = Math.PI * 2 + rad;
}
var isLeft = pos[0] < cx;
if (isLeft) {
rad = rad - Math.PI;
}
var textPosition = isLeft ? 'left' : 'right';
symbolPath.setTextConfig({
rotation: -rad,
position: textPosition,
origin: 'center'
});
var emphasisState = symbolPath.ensureState('emphasis');
zrUtil.extend(emphasisState.textConfig || (emphasisState.textConfig = {}), {
position: textPosition
});
} else {
symbolPath.setTextConfig({
rotation: labelRotate *= Math.PI / 180
});
}
}

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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
// FIXME Where to create the simple view coordinate system
import View from '../../coord/View.js';
import { getLayoutRect } from '../../util/layout.js';
import * as bbox from 'zrender/lib/core/bbox.js';
import { extend } from 'zrender/lib/core/util.js';
function getViewRect(seriesModel, api, aspect) {
var option = extend(seriesModel.getBoxLayoutParams(), {
aspect: aspect
});
return getLayoutRect(option, {
width: api.getWidth(),
height: api.getHeight()
});
}
export default function createViewCoordSys(ecModel, api) {
var viewList = [];
ecModel.eachSeriesByType('graph', function (seriesModel) {
var coordSysType = seriesModel.get('coordinateSystem');
if (!coordSysType || coordSysType === 'view') {
var data_1 = seriesModel.getData();
var positions = data_1.mapArray(function (idx) {
var itemModel = data_1.getItemModel(idx);
return [+itemModel.get('x'), +itemModel.get('y')];
});
var min = [];
var max = [];
bbox.fromPoints(positions, min, max);
// If width or height is 0
if (max[0] - min[0] === 0) {
max[0] += 1;
min[0] -= 1;
}
if (max[1] - min[1] === 0) {
max[1] += 1;
min[1] -= 1;
}
var aspect = (max[0] - min[0]) / (max[1] - min[1]);
// FIXME If get view rect after data processed?
var viewRect = getViewRect(seriesModel, api, aspect);
// Position may be NaN, use view rect instead
if (isNaN(aspect)) {
min = [viewRect.x, viewRect.y];
max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
}
var bbWidth = max[0] - min[0];
var bbHeight = max[1] - min[1];
var viewWidth = viewRect.width;
var viewHeight = viewRect.height;
var viewCoordSys = seriesModel.coordinateSystem = new View();
viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
viewCoordSys.setBoundingRect(min[0], min[1], bbWidth, bbHeight);
viewCoordSys.setViewRect(viewRect.x, viewRect.y, viewWidth, viewHeight);
// Update roam info
viewCoordSys.setCenter(seriesModel.get('center'), api);
viewCoordSys.setZoom(seriesModel.get('zoom'));
viewList.push(viewCoordSys);
}
});
return viewList;
}

View File

@ -0,0 +1,93 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { extend } from 'zrender/lib/core/util.js';
function normalize(a) {
if (!(a instanceof Array)) {
a = [a, a];
}
return a;
}
export default function graphEdgeVisual(ecModel) {
ecModel.eachSeriesByType('graph', function (seriesModel) {
var graph = seriesModel.getGraph();
var edgeData = seriesModel.getEdgeData();
var symbolType = normalize(seriesModel.get('edgeSymbol'));
var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
// const colorQuery = ['lineStyle', 'color'] as const;
// const opacityQuery = ['lineStyle', 'opacity'] as const;
edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
edgeData.setVisual('style', seriesModel.getModel('lineStyle').getLineStyle());
edgeData.each(function (idx) {
var itemModel = edgeData.getItemModel(idx);
var edge = graph.getEdgeByIndex(idx);
var symbolType = normalize(itemModel.getShallow('symbol', true));
var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
// Edge visual must after node visual
var style = itemModel.getModel('lineStyle').getLineStyle();
var existsStyle = edgeData.ensureUniqueItemVisual(idx, 'style');
extend(existsStyle, style);
switch (existsStyle.stroke) {
case 'source':
{
var nodeStyle = edge.node1.getVisual('style');
existsStyle.stroke = nodeStyle && nodeStyle.fill;
break;
}
case 'target':
{
var nodeStyle = edge.node2.getVisual('style');
existsStyle.stroke = nodeStyle && nodeStyle.fill;
break;
}
}
symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
});
});
}

View File

@ -0,0 +1,185 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
/*
* A third-party license is embedded for some of the code in this file:
* Some formulas were originally copied from "d3.js" with some
* modifications made for this project.
* (See more details in the comment of the method "step" below.)
* The use of the source code of this file is also subject to the terms
* and consitions of the license of "d3.js" (BSD-3Clause, see
* </licenses/LICENSE-d3>).
*/
import * as vec2 from 'zrender/lib/core/vector.js';
var scaleAndAdd = vec2.scaleAndAdd;
// function adjacentNode(n, e) {
// return e.n1 === n ? e.n2 : e.n1;
// }
export function forceLayout(inNodes, inEdges, opts) {
var nodes = inNodes;
var edges = inEdges;
var rect = opts.rect;
var width = rect.width;
var height = rect.height;
var center = [rect.x + width / 2, rect.y + height / 2];
// let scale = opts.scale || 1;
var gravity = opts.gravity == null ? 0.1 : opts.gravity;
// for (let i = 0; i < edges.length; i++) {
// let e = edges[i];
// let n1 = e.n1;
// let n2 = e.n2;
// n1.edges = n1.edges || [];
// n2.edges = n2.edges || [];
// n1.edges.push(e);
// n2.edges.push(e);
// }
// Init position
for (var i = 0; i < nodes.length; i++) {
var n = nodes[i];
if (!n.p) {
n.p = vec2.create(width * (Math.random() - 0.5) + center[0], height * (Math.random() - 0.5) + center[1]);
}
n.pp = vec2.clone(n.p);
n.edges = null;
}
// Formula in 'Graph Drawing by Force-directed Placement'
// let k = scale * Math.sqrt(width * height / nodes.length);
// let k2 = k * k;
var initialFriction = opts.friction == null ? 0.6 : opts.friction;
var friction = initialFriction;
var beforeStepCallback;
var afterStepCallback;
return {
warmUp: function () {
friction = initialFriction * 0.8;
},
setFixed: function (idx) {
nodes[idx].fixed = true;
},
setUnfixed: function (idx) {
nodes[idx].fixed = false;
},
/**
* Before step hook
*/
beforeStep: function (cb) {
beforeStepCallback = cb;
},
/**
* After step hook
*/
afterStep: function (cb) {
afterStepCallback = cb;
},
/**
* Some formulas were originally copied from "d3.js"
* https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/layout/force.js
* with some modifications made for this project.
* See the license statement at the head of this file.
*/
step: function (cb) {
beforeStepCallback && beforeStepCallback(nodes, edges);
var v12 = [];
var nLen = nodes.length;
for (var i = 0; i < edges.length; i++) {
var e = edges[i];
if (e.ignoreForceLayout) {
continue;
}
var n1 = e.n1;
var n2 = e.n2;
vec2.sub(v12, n2.p, n1.p);
var d = vec2.len(v12) - e.d;
var w = n2.w / (n1.w + n2.w);
if (isNaN(w)) {
w = 0;
}
vec2.normalize(v12, v12);
!n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
!n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
}
// Gravity
for (var i = 0; i < nLen; i++) {
var n = nodes[i];
if (!n.fixed) {
vec2.sub(v12, center, n.p);
// let d = vec2.len(v12);
// vec2.scale(v12, v12, 1 / d);
// let gravityFactor = gravity;
scaleAndAdd(n.p, n.p, v12, gravity * friction);
}
}
// Repulsive
// PENDING
for (var i = 0; i < nLen; i++) {
var n1 = nodes[i];
for (var j = i + 1; j < nLen; j++) {
var n2 = nodes[j];
vec2.sub(v12, n2.p, n1.p);
var d = vec2.len(v12);
if (d === 0) {
// Random repulse
vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
d = 1;
}
var repFact = (n1.rep + n2.rep) / d / d;
!n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
!n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
}
}
var v = [];
for (var i = 0; i < nLen; i++) {
var n = nodes[i];
if (!n.fixed) {
vec2.sub(v, n.p, n.pp);
scaleAndAdd(n.p, n.p, v, friction);
vec2.copy(n.pp, n.p);
}
}
friction = friction * 0.992;
var finished = friction < 0.01;
afterStepCallback && afterStepCallback(nodes, edges, finished);
cb && cb(finished);
}
};
}

View File

@ -0,0 +1,160 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { forceLayout } from './forceHelper.js';
import { simpleLayout } from './simpleLayoutHelper.js';
import { circularLayout } from './circularLayoutHelper.js';
import { linearMap } from '../../util/number.js';
import * as vec2 from 'zrender/lib/core/vector.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { getCurvenessForEdge } from '../helper/multipleGraphEdgeHelper.js';
export default function graphForceLayout(ecModel) {
ecModel.eachSeriesByType('graph', function (graphSeries) {
var coordSys = graphSeries.coordinateSystem;
if (coordSys && coordSys.type !== 'view') {
return;
}
if (graphSeries.get('layout') === 'force') {
var preservedPoints_1 = graphSeries.preservedPoints || {};
var graph_1 = graphSeries.getGraph();
var nodeData_1 = graph_1.data;
var edgeData = graph_1.edgeData;
var forceModel = graphSeries.getModel('force');
var initLayout = forceModel.get('initLayout');
if (graphSeries.preservedPoints) {
nodeData_1.each(function (idx) {
var id = nodeData_1.getId(idx);
nodeData_1.setItemLayout(idx, preservedPoints_1[id] || [NaN, NaN]);
});
} else if (!initLayout || initLayout === 'none') {
simpleLayout(graphSeries);
} else if (initLayout === 'circular') {
circularLayout(graphSeries, 'value');
}
var nodeDataExtent_1 = nodeData_1.getDataExtent('value');
var edgeDataExtent_1 = edgeData.getDataExtent('value');
// let edgeDataExtent = edgeData.getDataExtent('value');
var repulsion = forceModel.get('repulsion');
var edgeLength = forceModel.get('edgeLength');
var repulsionArr_1 = zrUtil.isArray(repulsion) ? repulsion : [repulsion, repulsion];
var edgeLengthArr_1 = zrUtil.isArray(edgeLength) ? edgeLength : [edgeLength, edgeLength];
// Larger value has smaller length
edgeLengthArr_1 = [edgeLengthArr_1[1], edgeLengthArr_1[0]];
var nodes_1 = nodeData_1.mapArray('value', function (value, idx) {
var point = nodeData_1.getItemLayout(idx);
var rep = linearMap(value, nodeDataExtent_1, repulsionArr_1);
if (isNaN(rep)) {
rep = (repulsionArr_1[0] + repulsionArr_1[1]) / 2;
}
return {
w: rep,
rep: rep,
fixed: nodeData_1.getItemModel(idx).get('fixed'),
p: !point || isNaN(point[0]) || isNaN(point[1]) ? null : point
};
});
var edges = edgeData.mapArray('value', function (value, idx) {
var edge = graph_1.getEdgeByIndex(idx);
var d = linearMap(value, edgeDataExtent_1, edgeLengthArr_1);
if (isNaN(d)) {
d = (edgeLengthArr_1[0] + edgeLengthArr_1[1]) / 2;
}
var edgeModel = edge.getModel();
var curveness = zrUtil.retrieve3(edge.getModel().get(['lineStyle', 'curveness']), -getCurvenessForEdge(edge, graphSeries, idx, true), 0);
return {
n1: nodes_1[edge.node1.dataIndex],
n2: nodes_1[edge.node2.dataIndex],
d: d,
curveness: curveness,
ignoreForceLayout: edgeModel.get('ignoreForceLayout')
};
});
// let coordSys = graphSeries.coordinateSystem;
var rect = coordSys.getBoundingRect();
var forceInstance = forceLayout(nodes_1, edges, {
rect: rect,
gravity: forceModel.get('gravity'),
friction: forceModel.get('friction')
});
forceInstance.beforeStep(function (nodes, edges) {
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].fixed) {
// Write back to layout instance
vec2.copy(nodes[i].p, graph_1.getNodeByIndex(i).getLayout());
}
}
});
forceInstance.afterStep(function (nodes, edges, stopped) {
for (var i = 0, l = nodes.length; i < l; i++) {
if (!nodes[i].fixed) {
graph_1.getNodeByIndex(i).setLayout(nodes[i].p);
}
preservedPoints_1[nodeData_1.getId(i)] = nodes[i].p;
}
for (var i = 0, l = edges.length; i < l; i++) {
var e = edges[i];
var edge = graph_1.getEdgeByIndex(i);
var p1 = e.n1.p;
var p2 = e.n2.p;
var points = edge.getLayout();
points = points ? points.slice() : [];
points[0] = points[0] || [];
points[1] = points[1] || [];
vec2.copy(points[0], p1);
vec2.copy(points[1], p2);
if (+e.curveness) {
points[2] = [(p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness, (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness];
}
edge.setLayout(points);
}
});
graphSeries.forceLayout = forceInstance;
graphSeries.preservedPoints = preservedPoints_1;
// Step to get the layout
forceInstance.step();
} else {
// Remove prev injected forceLayout instance
graphSeries.forceLayout = null;
}
});
}

View File

@ -0,0 +1,62 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
export function getNodeGlobalScale(seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys.type !== 'view') {
return 1;
}
var nodeScaleRatio = seriesModel.option.nodeScaleRatio;
var groupZoom = coordSys.scaleX;
// Scale node when zoom changes
var roamZoom = coordSys.getZoom();
var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
return nodeScale / groupZoom;
}
export function getSymbolSize(node) {
var symbolSize = node.getVisual('symbolSize');
if (symbolSize instanceof Array) {
symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
}
return +symbolSize;
}

View File

@ -0,0 +1,97 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import categoryFilter from './categoryFilter.js';
import categoryVisual from './categoryVisual.js';
import edgeVisual from './edgeVisual.js';
import simpleLayout from './simpleLayout.js';
import circularLayout from './circularLayout.js';
import forceLayout from './forceLayout.js';
import createView from './createView.js';
import View from '../../coord/View.js';
import GraphView from './GraphView.js';
import GraphSeriesModel from './GraphSeries.js';
import { updateCenterAndZoom } from '../../action/roamHelper.js';
import { noop } from 'zrender/lib/core/util.js';
var actionInfo = {
type: 'graphRoam',
event: 'graphRoam',
update: 'none'
};
export function install(registers) {
registers.registerChartView(GraphView);
registers.registerSeriesModel(GraphSeriesModel);
registers.registerProcessor(categoryFilter);
registers.registerVisual(categoryVisual);
registers.registerVisual(edgeVisual);
registers.registerLayout(simpleLayout);
registers.registerLayout(registers.PRIORITY.VISUAL.POST_CHART_LAYOUT, circularLayout);
registers.registerLayout(forceLayout);
registers.registerCoordinateSystem('graphView', {
dimensions: View.dimensions,
create: createView
});
// Register legacy focus actions
registers.registerAction({
type: 'focusNodeAdjacency',
event: 'focusNodeAdjacency',
update: 'series:focusNodeAdjacency'
}, noop);
registers.registerAction({
type: 'unfocusNodeAdjacency',
event: 'unfocusNodeAdjacency',
update: 'series:unfocusNodeAdjacency'
}, noop);
// Register roam action.
registers.registerAction(actionInfo, function (payload, ecModel, api) {
ecModel.eachComponent({
mainType: 'series',
query: payload
}, function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var res = updateCenterAndZoom(coordSys, payload, undefined, api);
seriesModel.setCenter && seriesModel.setCenter(res.center);
seriesModel.setZoom && seriesModel.setZoom(res.zoom);
});
});
}

View File

@ -0,0 +1,78 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { each } from 'zrender/lib/core/util.js';
import { simpleLayout, simpleLayoutEdge } from './simpleLayoutHelper.js';
export default function graphSimpleLayout(ecModel, api) {
ecModel.eachSeriesByType('graph', function (seriesModel) {
var layout = seriesModel.get('layout');
var coordSys = seriesModel.coordinateSystem;
if (coordSys && coordSys.type !== 'view') {
var data_1 = seriesModel.getData();
var dimensions_1 = [];
each(coordSys.dimensions, function (coordDim) {
dimensions_1 = dimensions_1.concat(data_1.mapDimensionsAll(coordDim));
});
for (var dataIndex = 0; dataIndex < data_1.count(); dataIndex++) {
var value = [];
var hasValue = false;
for (var i = 0; i < dimensions_1.length; i++) {
var val = data_1.get(dimensions_1[i], dataIndex);
if (!isNaN(val)) {
hasValue = true;
}
value.push(val);
}
if (hasValue) {
data_1.setItemLayout(dataIndex, coordSys.dataToPoint(value));
} else {
// Also {Array.<number>}, not undefined to avoid if...else... statement
data_1.setItemLayout(dataIndex, [NaN, NaN]);
}
}
simpleLayoutEdge(data_1.graph, seriesModel);
} else if (!layout || layout === 'none') {
simpleLayout(seriesModel);
}
});
}

View File

@ -0,0 +1,70 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as vec2 from 'zrender/lib/core/vector.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { getCurvenessForEdge } from '../helper/multipleGraphEdgeHelper.js';
export function simpleLayout(seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && coordSys.type !== 'view') {
return;
}
var graph = seriesModel.getGraph();
graph.eachNode(function (node) {
var model = node.getModel();
node.setLayout([+model.get('x'), +model.get('y')]);
});
simpleLayoutEdge(graph, seriesModel);
}
export function simpleLayoutEdge(graph, seriesModel) {
graph.eachEdge(function (edge, index) {
var curveness = zrUtil.retrieve3(edge.getModel().get(['lineStyle', 'curveness']), -getCurvenessForEdge(edge, seriesModel, index, true), 0);
var p1 = vec2.clone(edge.node1.getLayout());
var p2 = vec2.clone(edge.node2.getLayout());
var points = [p1, p2];
if (+curveness) {
points.push([(p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness]);
}
edge.setLayout(points);
});
}

46
frontend/node_modules/echarts/lib/chart/heatmap.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './heatmap/install.js';
use(install);

View File

@ -0,0 +1,166 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
/* global Uint8ClampedArray */
import { platformApi } from 'zrender/lib/core/platform.js';
var GRADIENT_LEVELS = 256;
var HeatmapLayer = /** @class */function () {
function HeatmapLayer() {
this.blurSize = 30;
this.pointSize = 20;
this.maxOpacity = 1;
this.minOpacity = 0;
this._gradientPixels = {
inRange: null,
outOfRange: null
};
var canvas = platformApi.createCanvas();
this.canvas = canvas;
}
/**
* Renders Heatmap and returns the rendered canvas
* @param data array of data, each has x, y, value
* @param width canvas width
* @param height canvas height
*/
HeatmapLayer.prototype.update = function (data, width, height, normalize, colorFunc, isInRange) {
var brush = this._getBrush();
var gradientInRange = this._getGradient(colorFunc, 'inRange');
var gradientOutOfRange = this._getGradient(colorFunc, 'outOfRange');
var r = this.pointSize + this.blurSize;
var canvas = this.canvas;
var ctx = canvas.getContext('2d');
var len = data.length;
canvas.width = width;
canvas.height = height;
for (var i = 0; i < len; ++i) {
var p = data[i];
var x = p[0];
var y = p[1];
var value = p[2];
// calculate alpha using value
var alpha = normalize(value);
// draw with the circle brush with alpha
ctx.globalAlpha = alpha;
ctx.drawImage(brush, x - r, y - r);
}
if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}
// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
var minOpacity = this.minOpacity;
var maxOpacity = this.maxOpacity;
var diffOpacity = maxOpacity - minOpacity;
while (offset < pixelLen) {
var alpha = pixels[offset + 3] / 256;
var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
// Simple optimize to ignore the empty data
if (alpha > 0) {
var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
pixels[offset++] = gradient[gradientOffset];
pixels[offset++] = gradient[gradientOffset + 1];
pixels[offset++] = gradient[gradientOffset + 2];
pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
} else {
offset += 4;
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
};
/**
* get canvas of a black circle brush used for canvas to draw later
*/
HeatmapLayer.prototype._getBrush = function () {
var brushCanvas = this._brushCanvas || (this._brushCanvas = platformApi.createCanvas());
// set brush size
var r = this.pointSize + this.blurSize;
var d = r * 2;
brushCanvas.width = d;
brushCanvas.height = d;
var ctx = brushCanvas.getContext('2d');
ctx.clearRect(0, 0, d, d);
// in order to render shadow without the distinct circle,
// draw the distinct circle in an invisible place,
// and use shadowOffset to draw shadow in the center of the canvas
ctx.shadowOffsetX = d;
ctx.shadowBlur = this.blurSize;
// draw the shadow in black, and use alpha and shadow blur to generate
// color in color map
ctx.shadowColor = '#000';
// draw circle in the left to the canvas
ctx.beginPath();
ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
return brushCanvas;
};
/**
* get gradient color map
* @private
*/
HeatmapLayer.prototype._getGradient = function (colorFunc, state) {
var gradientPixels = this._gradientPixels;
var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
var color = [0, 0, 0, 0];
var off = 0;
for (var i = 0; i < 256; i++) {
colorFunc[state](i / 255, true, color);
pixelsSingleState[off++] = color[0];
pixelsSingleState[off++] = color[1];
pixelsSingleState[off++] = color[2];
pixelsSingleState[off++] = color[3];
}
return pixelsSingleState;
};
return HeatmapLayer;
}();
export default HeatmapLayer;

View File

@ -0,0 +1,89 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import SeriesModel from '../../model/Series.js';
import createSeriesData from '../helper/createSeriesData.js';
import CoordinateSystem from '../../core/CoordinateSystem.js';
var HeatmapSeriesModel = /** @class */function (_super) {
__extends(HeatmapSeriesModel, _super);
function HeatmapSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = HeatmapSeriesModel.type;
return _this;
}
HeatmapSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesData(null, this, {
generateCoord: 'value'
});
};
HeatmapSeriesModel.prototype.preventIncremental = function () {
var coordSysCreator = CoordinateSystem.get(this.get('coordinateSystem'));
if (coordSysCreator && coordSysCreator.dimensions) {
return coordSysCreator.dimensions[0] === 'lng' && coordSysCreator.dimensions[1] === 'lat';
}
};
HeatmapSeriesModel.type = 'series.heatmap';
HeatmapSeriesModel.dependencies = ['grid', 'geo', 'calendar'];
HeatmapSeriesModel.defaultOption = {
coordinateSystem: 'cartesian2d',
// zlevel: 0,
z: 2,
// Cartesian coordinate system
// xAxisIndex: 0,
// yAxisIndex: 0,
// Geo coordinate system
geoIndex: 0,
blurSize: 30,
pointSize: 20,
maxOpacity: 1,
minOpacity: 0,
select: {
itemStyle: {
borderColor: '#212121'
}
}
};
return HeatmapSeriesModel;
}(SeriesModel);
export default HeatmapSeriesModel;

View File

@ -0,0 +1,310 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import { toggleHoverEmphasis } from '../../util/states.js';
import HeatmapLayer from './HeatmapLayer.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import ChartView from '../../view/Chart.js';
import { isCoordinateSystemType } from '../../coord/CoordinateSystem.js';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
var dataSpan = dataExtent[1] - dataExtent[0];
pieceList = zrUtil.map(pieceList, function (piece) {
return {
interval: [(piece.interval[0] - dataExtent[0]) / dataSpan, (piece.interval[1] - dataExtent[0]) / dataSpan]
};
});
var len = pieceList.length;
var lastIndex = 0;
return function (val) {
var i;
// Try to find in the location of the last found
for (i = lastIndex; i < len; i++) {
var interval = pieceList[i].interval;
if (interval[0] <= val && val <= interval[1]) {
lastIndex = i;
break;
}
}
if (i === len) {
// Not found, back interation
for (i = lastIndex - 1; i >= 0; i--) {
var interval = pieceList[i].interval;
if (interval[0] <= val && val <= interval[1]) {
lastIndex = i;
break;
}
}
}
return i >= 0 && i < len && selected[i];
};
}
function getIsInContinuousRange(dataExtent, range) {
var dataSpan = dataExtent[1] - dataExtent[0];
range = [(range[0] - dataExtent[0]) / dataSpan, (range[1] - dataExtent[0]) / dataSpan];
return function (val) {
return val >= range[0] && val <= range[1];
};
}
function isGeoCoordSys(coordSys) {
var dimensions = coordSys.dimensions;
// Not use coordSys.type === 'geo' because coordSys maybe extended
return dimensions[0] === 'lng' && dimensions[1] === 'lat';
}
var HeatmapView = /** @class */function (_super) {
__extends(HeatmapView, _super);
function HeatmapView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = HeatmapView.type;
return _this;
}
HeatmapView.prototype.render = function (seriesModel, ecModel, api) {
var visualMapOfThisSeries;
ecModel.eachComponent('visualMap', function (visualMap) {
visualMap.eachTargetSeries(function (targetSeries) {
if (targetSeries === seriesModel) {
visualMapOfThisSeries = visualMap;
}
});
});
if (process.env.NODE_ENV !== 'production') {
if (!visualMapOfThisSeries) {
throw new Error('Heatmap must use with visualMap');
}
}
// Clear previously rendered progressive elements.
this._progressiveEls = null;
this.group.removeAll();
var coordSys = seriesModel.coordinateSystem;
if (coordSys.type === 'cartesian2d' || coordSys.type === 'calendar') {
this._renderOnCartesianAndCalendar(seriesModel, api, 0, seriesModel.getData().count());
} else if (isGeoCoordSys(coordSys)) {
this._renderOnGeo(coordSys, seriesModel, visualMapOfThisSeries, api);
}
};
HeatmapView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
this.group.removeAll();
};
HeatmapView.prototype.incrementalRender = function (params, seriesModel, ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys) {
// geo does not support incremental rendering?
if (isGeoCoordSys(coordSys)) {
this.render(seriesModel, ecModel, api);
} else {
this._progressiveEls = [];
this._renderOnCartesianAndCalendar(seriesModel, api, params.start, params.end, true);
}
}
};
HeatmapView.prototype.eachRendered = function (cb) {
graphic.traverseElements(this._progressiveEls || this.group, cb);
};
HeatmapView.prototype._renderOnCartesianAndCalendar = function (seriesModel, api, start, end, incremental) {
var coordSys = seriesModel.coordinateSystem;
var isCartesian2d = isCoordinateSystemType(coordSys, 'cartesian2d');
var width;
var height;
var xAxisExtent;
var yAxisExtent;
if (isCartesian2d) {
var xAxis = coordSys.getAxis('x');
var yAxis = coordSys.getAxis('y');
if (process.env.NODE_ENV !== 'production') {
if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
throw new Error('Heatmap on cartesian must have two category axes');
}
if (!(xAxis.onBand && yAxis.onBand)) {
throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
}
}
// add 0.5px to avoid the gaps
width = xAxis.getBandWidth() + .5;
height = yAxis.getBandWidth() + .5;
xAxisExtent = xAxis.scale.getExtent();
yAxisExtent = yAxis.scale.getExtent();
}
var group = this.group;
var data = seriesModel.getData();
var emphasisStyle = seriesModel.getModel(['emphasis', 'itemStyle']).getItemStyle();
var blurStyle = seriesModel.getModel(['blur', 'itemStyle']).getItemStyle();
var selectStyle = seriesModel.getModel(['select', 'itemStyle']).getItemStyle();
var borderRadius = seriesModel.get(['itemStyle', 'borderRadius']);
var labelStatesModels = getLabelStatesModels(seriesModel);
var emphasisModel = seriesModel.getModel('emphasis');
var focus = emphasisModel.get('focus');
var blurScope = emphasisModel.get('blurScope');
var emphasisDisabled = emphasisModel.get('disabled');
var dataDims = isCartesian2d ? [data.mapDimension('x'), data.mapDimension('y'), data.mapDimension('value')] : [data.mapDimension('time'), data.mapDimension('value')];
for (var idx = start; idx < end; idx++) {
var rect = void 0;
var style = data.getItemVisual(idx, 'style');
if (isCartesian2d) {
var dataDimX = data.get(dataDims[0], idx);
var dataDimY = data.get(dataDims[1], idx);
// Ignore empty data and out of extent data
if (isNaN(data.get(dataDims[2], idx)) || isNaN(dataDimX) || isNaN(dataDimY) || dataDimX < xAxisExtent[0] || dataDimX > xAxisExtent[1] || dataDimY < yAxisExtent[0] || dataDimY > yAxisExtent[1]) {
continue;
}
var point = coordSys.dataToPoint([dataDimX, dataDimY]);
rect = new graphic.Rect({
shape: {
x: point[0] - width / 2,
y: point[1] - height / 2,
width: width,
height: height
},
style: style
});
} else {
// Ignore empty data
if (isNaN(data.get(dataDims[1], idx))) {
continue;
}
rect = new graphic.Rect({
z2: 1,
shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape,
style: style
});
}
// Optimization for large dataset
if (data.hasItemOption) {
var itemModel = data.getItemModel(idx);
var emphasisModel_1 = itemModel.getModel('emphasis');
emphasisStyle = emphasisModel_1.getModel('itemStyle').getItemStyle();
blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
// Each item value struct in the data would be firstly
// {
// itemStyle: { borderRadius: [30, 30] },
// value: [2022, 02, 22]
// }
borderRadius = itemModel.get(['itemStyle', 'borderRadius']);
focus = emphasisModel_1.get('focus');
blurScope = emphasisModel_1.get('blurScope');
emphasisDisabled = emphasisModel_1.get('disabled');
labelStatesModels = getLabelStatesModels(itemModel);
}
rect.shape.r = borderRadius;
var rawValue = seriesModel.getRawValue(idx);
var defaultText = '-';
if (rawValue && rawValue[2] != null) {
defaultText = rawValue[2] + '';
}
setLabelStyle(rect, labelStatesModels, {
labelFetcher: seriesModel,
labelDataIndex: idx,
defaultOpacity: style.opacity,
defaultText: defaultText
});
rect.ensureState('emphasis').style = emphasisStyle;
rect.ensureState('blur').style = blurStyle;
rect.ensureState('select').style = selectStyle;
toggleHoverEmphasis(rect, focus, blurScope, emphasisDisabled);
rect.incremental = incremental;
// PENDING
if (incremental) {
// Rect must use hover layer if it's incremental.
rect.states.emphasis.hoverLayer = true;
}
group.add(rect);
data.setItemGraphicEl(idx, rect);
if (this._progressiveEls) {
this._progressiveEls.push(rect);
}
}
};
HeatmapView.prototype._renderOnGeo = function (geo, seriesModel, visualMapModel, api) {
var inRangeVisuals = visualMapModel.targetVisuals.inRange;
var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
// if (!visualMapping) {
// throw new Error('Data range must have color visuals');
// }
var data = seriesModel.getData();
var hmLayer = this._hmLayer || this._hmLayer || new HeatmapLayer();
hmLayer.blurSize = seriesModel.get('blurSize');
hmLayer.pointSize = seriesModel.get('pointSize');
hmLayer.minOpacity = seriesModel.get('minOpacity');
hmLayer.maxOpacity = seriesModel.get('maxOpacity');
var rect = geo.getViewRect().clone();
var roamTransform = geo.getRoamTransform();
rect.applyTransform(roamTransform);
// Clamp on viewport
var x = Math.max(rect.x, 0);
var y = Math.max(rect.y, 0);
var x2 = Math.min(rect.width + rect.x, api.getWidth());
var y2 = Math.min(rect.height + rect.y, api.getHeight());
var width = x2 - x;
var height = y2 - y;
var dims = [data.mapDimension('lng'), data.mapDimension('lat'), data.mapDimension('value')];
var points = data.mapArray(dims, function (lng, lat, value) {
var pt = geo.dataToPoint([lng, lat]);
pt[0] -= x;
pt[1] -= y;
pt.push(value);
return pt;
});
var dataExtent = visualMapModel.getExtent();
var isInRange = visualMapModel.type === 'visualMap.continuous' ? getIsInContinuousRange(dataExtent, visualMapModel.option.range) : getIsInPiecewiseRange(dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected);
hmLayer.update(points, width, height, inRangeVisuals.color.getNormalizer(), {
inRange: inRangeVisuals.color.getColorMapper(),
outOfRange: outOfRangeVisuals.color.getColorMapper()
}, isInRange);
var img = new graphic.Image({
style: {
width: width,
height: height,
x: x,
y: y,
image: hmLayer.canvas
},
silent: true
});
this.group.add(img);
};
HeatmapView.type = 'heatmap';
return HeatmapView;
}(ChartView);
export default HeatmapView;

View File

@ -0,0 +1,49 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import HeatmapView from './HeatmapView.js';
import HeatmapSeriesModel from './HeatmapSeries.js';
export function install(registers) {
registers.registerChartView(HeatmapView);
registers.registerSeriesModel(HeatmapSeriesModel);
}

View File

@ -0,0 +1,207 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
/**
* Provide effect for line
*/
import * as graphic from '../../util/graphic.js';
import Line from './Line.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { createSymbol } from '../../util/symbol.js';
import * as vec2 from 'zrender/lib/core/vector.js';
import * as curveUtil from 'zrender/lib/core/curve.js';
var EffectLine = /** @class */function (_super) {
__extends(EffectLine, _super);
function EffectLine(lineData, idx, seriesScope) {
var _this = _super.call(this) || this;
_this.add(_this.createLine(lineData, idx, seriesScope));
_this._updateEffectSymbol(lineData, idx);
return _this;
}
EffectLine.prototype.createLine = function (lineData, idx, seriesScope) {
return new Line(lineData, idx, seriesScope);
};
EffectLine.prototype._updateEffectSymbol = function (lineData, idx) {
var itemModel = lineData.getItemModel(idx);
var effectModel = itemModel.getModel('effect');
var size = effectModel.get('symbolSize');
var symbolType = effectModel.get('symbol');
if (!zrUtil.isArray(size)) {
size = [size, size];
}
var lineStyle = lineData.getItemVisual(idx, 'style');
var color = effectModel.get('color') || lineStyle && lineStyle.stroke;
var symbol = this.childAt(1);
if (this._symbolType !== symbolType) {
// Remove previous
this.remove(symbol);
symbol = createSymbol(symbolType, -0.5, -0.5, 1, 1, color);
symbol.z2 = 100;
symbol.culling = true;
this.add(symbol);
}
// Symbol may be removed if loop is false
if (!symbol) {
return;
}
// Shadow color is same with color in default
symbol.setStyle('shadowColor', color);
symbol.setStyle(effectModel.getItemStyle(['color']));
symbol.scaleX = size[0];
symbol.scaleY = size[1];
symbol.setColor(color);
this._symbolType = symbolType;
this._symbolScale = size;
this._updateEffectAnimation(lineData, effectModel, idx);
};
EffectLine.prototype._updateEffectAnimation = function (lineData, effectModel, idx) {
var symbol = this.childAt(1);
if (!symbol) {
return;
}
var points = lineData.getItemLayout(idx);
var period = effectModel.get('period') * 1000;
var loop = effectModel.get('loop');
var roundTrip = effectModel.get('roundTrip');
var constantSpeed = effectModel.get('constantSpeed');
var delayExpr = zrUtil.retrieve(effectModel.get('delay'), function (idx) {
return idx / lineData.count() * period / 3;
});
// Ignore when updating
symbol.ignore = true;
this._updateAnimationPoints(symbol, points);
if (constantSpeed > 0) {
period = this._getLineLength(symbol) / constantSpeed * 1000;
}
if (period !== this._period || loop !== this._loop || roundTrip !== this._roundTrip) {
symbol.stopAnimation();
var delayNum = void 0;
if (zrUtil.isFunction(delayExpr)) {
delayNum = delayExpr(idx);
} else {
delayNum = delayExpr;
}
if (symbol.__t > 0) {
delayNum = -period * symbol.__t;
}
this._animateSymbol(symbol, period, delayNum, loop, roundTrip);
}
this._period = period;
this._loop = loop;
this._roundTrip = roundTrip;
};
EffectLine.prototype._animateSymbol = function (symbol, period, delayNum, loop, roundTrip) {
if (period > 0) {
symbol.__t = 0;
var self_1 = this;
var animator = symbol.animate('', loop).when(roundTrip ? period * 2 : period, {
__t: roundTrip ? 2 : 1
}).delay(delayNum).during(function () {
self_1._updateSymbolPosition(symbol);
});
if (!loop) {
animator.done(function () {
self_1.remove(symbol);
});
}
animator.start();
}
};
EffectLine.prototype._getLineLength = function (symbol) {
// Not so accurate
return vec2.dist(symbol.__p1, symbol.__cp1) + vec2.dist(symbol.__cp1, symbol.__p2);
};
EffectLine.prototype._updateAnimationPoints = function (symbol, points) {
symbol.__p1 = points[0];
symbol.__p2 = points[1];
symbol.__cp1 = points[2] || [(points[0][0] + points[1][0]) / 2, (points[0][1] + points[1][1]) / 2];
};
EffectLine.prototype.updateData = function (lineData, idx, seriesScope) {
this.childAt(0).updateData(lineData, idx, seriesScope);
this._updateEffectSymbol(lineData, idx);
};
EffectLine.prototype._updateSymbolPosition = function (symbol) {
var p1 = symbol.__p1;
var p2 = symbol.__p2;
var cp1 = symbol.__cp1;
var t = symbol.__t < 1 ? symbol.__t : 2 - symbol.__t;
var pos = [symbol.x, symbol.y];
var lastPos = pos.slice();
var quadraticAt = curveUtil.quadraticAt;
var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
// Tangent
var tx = symbol.__t < 1 ? quadraticDerivativeAt(p1[0], cp1[0], p2[0], t) : quadraticDerivativeAt(p2[0], cp1[0], p1[0], 1 - t);
var ty = symbol.__t < 1 ? quadraticDerivativeAt(p1[1], cp1[1], p2[1], t) : quadraticDerivativeAt(p2[1], cp1[1], p1[1], 1 - t);
symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
// enable continuity trail for 'line', 'rect', 'roundRect' symbolType
if (this._symbolType === 'line' || this._symbolType === 'rect' || this._symbolType === 'roundRect') {
if (symbol.__lastT !== undefined && symbol.__lastT < symbol.__t) {
symbol.scaleY = vec2.dist(lastPos, pos) * 1.05;
// make sure the last segment render within endPoint
if (t === 1) {
pos[0] = lastPos[0] + (pos[0] - lastPos[0]) / 2;
pos[1] = lastPos[1] + (pos[1] - lastPos[1]) / 2;
}
} else if (symbol.__lastT === 1) {
// After first loop, symbol.__t does NOT start with 0, so connect p1 to pos directly.
symbol.scaleY = 2 * vec2.dist(p1, pos);
} else {
symbol.scaleY = this._symbolScale[1];
}
}
symbol.__lastT = symbol.__t;
symbol.ignore = false;
symbol.x = pos[0];
symbol.y = pos[1];
};
EffectLine.prototype.updateLayout = function (lineData, idx) {
this.childAt(0).updateLayout(lineData, idx);
var effectModel = lineData.getItemModel(idx).getModel('effect');
this._updateEffectAnimation(lineData, effectModel, idx);
};
return EffectLine;
}(graphic.Group);
export default EffectLine;

View File

@ -0,0 +1,134 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import Polyline from './Polyline.js';
import EffectLine from './EffectLine.js';
import * as vec2 from 'zrender/lib/core/vector.js';
var EffectPolyline = /** @class */function (_super) {
__extends(EffectPolyline, _super);
function EffectPolyline() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._lastFrame = 0;
_this._lastFramePercent = 0;
return _this;
}
// Override
EffectPolyline.prototype.createLine = function (lineData, idx, seriesScope) {
return new Polyline(lineData, idx, seriesScope);
};
;
// Override
EffectPolyline.prototype._updateAnimationPoints = function (symbol, points) {
this._points = points;
var accLenArr = [0];
var len = 0;
for (var i = 1; i < points.length; i++) {
var p1 = points[i - 1];
var p2 = points[i];
len += vec2.dist(p1, p2);
accLenArr.push(len);
}
if (len === 0) {
this._length = 0;
return;
}
for (var i = 0; i < accLenArr.length; i++) {
accLenArr[i] /= len;
}
this._offsets = accLenArr;
this._length = len;
};
;
// Override
EffectPolyline.prototype._getLineLength = function () {
return this._length;
};
;
// Override
EffectPolyline.prototype._updateSymbolPosition = function (symbol) {
var t = symbol.__t < 1 ? symbol.__t : 2 - symbol.__t;
var points = this._points;
var offsets = this._offsets;
var len = points.length;
if (!offsets) {
// Has length 0
return;
}
var lastFrame = this._lastFrame;
var frame;
if (t < this._lastFramePercent) {
// Start from the next frame
// PENDING start from lastFrame ?
var start = Math.min(lastFrame + 1, len - 1);
for (frame = start; frame >= 0; frame--) {
if (offsets[frame] <= t) {
break;
}
}
// PENDING really need to do this ?
frame = Math.min(frame, len - 2);
} else {
for (frame = lastFrame; frame < len; frame++) {
if (offsets[frame] > t) {
break;
}
}
frame = Math.min(frame - 1, len - 2);
}
var p = (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame]);
var p0 = points[frame];
var p1 = points[frame + 1];
symbol.x = p0[0] * (1 - p) + p * p1[0];
symbol.y = p0[1] * (1 - p) + p * p1[1];
var tx = symbol.__t < 1 ? p1[0] - p0[0] : p0[0] - p1[0];
var ty = symbol.__t < 1 ? p1[1] - p0[1] : p0[1] - p1[1];
symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
this._lastFrame = frame;
this._lastFramePercent = t;
symbol.ignore = false;
};
;
return EffectPolyline;
}(EffectLine);
export default EffectPolyline;

View File

@ -0,0 +1,207 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import { createSymbol, normalizeSymbolOffset, normalizeSymbolSize } from '../../util/symbol.js';
import { Group } from '../../util/graphic.js';
import { enterEmphasis, leaveEmphasis, toggleHoverEmphasis } from '../../util/states.js';
import SymbolClz from './Symbol.js';
function updateRipplePath(rippleGroup, effectCfg) {
var color = effectCfg.rippleEffectColor || effectCfg.color;
rippleGroup.eachChild(function (ripplePath) {
ripplePath.attr({
z: effectCfg.z,
zlevel: effectCfg.zlevel,
style: {
stroke: effectCfg.brushType === 'stroke' ? color : null,
fill: effectCfg.brushType === 'fill' ? color : null
}
});
});
}
var EffectSymbol = /** @class */function (_super) {
__extends(EffectSymbol, _super);
function EffectSymbol(data, idx) {
var _this = _super.call(this) || this;
var symbol = new SymbolClz(data, idx);
var rippleGroup = new Group();
_this.add(symbol);
_this.add(rippleGroup);
_this.updateData(data, idx);
return _this;
}
EffectSymbol.prototype.stopEffectAnimation = function () {
this.childAt(1).removeAll();
};
EffectSymbol.prototype.startEffectAnimation = function (effectCfg) {
var symbolType = effectCfg.symbolType;
var color = effectCfg.color;
var rippleNumber = effectCfg.rippleNumber;
var rippleGroup = this.childAt(1);
for (var i = 0; i < rippleNumber; i++) {
// If width/height are set too small (e.g., set to 1) on ios10
// and macOS Sierra, a circle stroke become a rect, no matter what
// the scale is set. So we set width/height as 2. See #4136.
var ripplePath = createSymbol(symbolType, -1, -1, 2, 2, color);
ripplePath.attr({
style: {
strokeNoScale: true
},
z2: 99,
silent: true,
scaleX: 0.5,
scaleY: 0.5
});
var delay = -i / rippleNumber * effectCfg.period + effectCfg.effectOffset;
ripplePath.animate('', true).when(effectCfg.period, {
scaleX: effectCfg.rippleScale / 2,
scaleY: effectCfg.rippleScale / 2
}).delay(delay).start();
ripplePath.animateStyle(true).when(effectCfg.period, {
opacity: 0
}).delay(delay).start();
rippleGroup.add(ripplePath);
}
updateRipplePath(rippleGroup, effectCfg);
};
/**
* Update effect symbol
*/
EffectSymbol.prototype.updateEffectAnimation = function (effectCfg) {
var oldEffectCfg = this._effectCfg;
var rippleGroup = this.childAt(1);
// Must reinitialize effect if following configuration changed
var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale', 'rippleNumber'];
for (var i = 0; i < DIFFICULT_PROPS.length; i++) {
var propName = DIFFICULT_PROPS[i];
if (oldEffectCfg[propName] !== effectCfg[propName]) {
this.stopEffectAnimation();
this.startEffectAnimation(effectCfg);
return;
}
}
updateRipplePath(rippleGroup, effectCfg);
};
/**
* Highlight symbol
*/
EffectSymbol.prototype.highlight = function () {
enterEmphasis(this);
};
/**
* Downplay symbol
*/
EffectSymbol.prototype.downplay = function () {
leaveEmphasis(this);
};
EffectSymbol.prototype.getSymbolType = function () {
var symbol = this.childAt(0);
return symbol && symbol.getSymbolType();
};
/**
* Update symbol properties
*/
EffectSymbol.prototype.updateData = function (data, idx) {
var _this = this;
var seriesModel = data.hostModel;
this.childAt(0).updateData(data, idx);
var rippleGroup = this.childAt(1);
var itemModel = data.getItemModel(idx);
var symbolType = data.getItemVisual(idx, 'symbol');
var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
var symbolStyle = data.getItemVisual(idx, 'style');
var color = symbolStyle && symbolStyle.fill;
var emphasisModel = itemModel.getModel('emphasis');
rippleGroup.setScale(symbolSize);
rippleGroup.traverse(function (ripplePath) {
ripplePath.setStyle('fill', color);
});
var symbolOffset = normalizeSymbolOffset(data.getItemVisual(idx, 'symbolOffset'), symbolSize);
if (symbolOffset) {
rippleGroup.x = symbolOffset[0];
rippleGroup.y = symbolOffset[1];
}
var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
rippleGroup.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var effectCfg = {};
effectCfg.showEffectOn = seriesModel.get('showEffectOn');
effectCfg.rippleScale = itemModel.get(['rippleEffect', 'scale']);
effectCfg.brushType = itemModel.get(['rippleEffect', 'brushType']);
effectCfg.period = itemModel.get(['rippleEffect', 'period']) * 1000;
effectCfg.effectOffset = idx / data.count();
effectCfg.z = seriesModel.getShallow('z') || 0;
effectCfg.zlevel = seriesModel.getShallow('zlevel') || 0;
effectCfg.symbolType = symbolType;
effectCfg.color = color;
effectCfg.rippleEffectColor = itemModel.get(['rippleEffect', 'color']);
effectCfg.rippleNumber = itemModel.get(['rippleEffect', 'number']);
if (effectCfg.showEffectOn === 'render') {
this._effectCfg ? this.updateEffectAnimation(effectCfg) : this.startEffectAnimation(effectCfg);
this._effectCfg = effectCfg;
} else {
// Not keep old effect config
this._effectCfg = null;
this.stopEffectAnimation();
this.onHoverStateChange = function (toState) {
if (toState === 'emphasis') {
if (effectCfg.showEffectOn !== 'render') {
_this.startEffectAnimation(effectCfg);
}
} else if (toState === 'normal') {
if (effectCfg.showEffectOn !== 'render') {
_this.stopEffectAnimation();
}
}
};
}
this._effectCfg = effectCfg;
toggleHoverEmphasis(this, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
};
;
EffectSymbol.prototype.fadeOut = function (cb) {
cb && cb();
};
;
return EffectSymbol;
}(Group);
export default EffectSymbol;

View File

@ -0,0 +1,302 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
// TODO Batch by color
import * as graphic from '../../util/graphic.js';
import * as lineContain from 'zrender/lib/contain/line.js';
import * as quadraticContain from 'zrender/lib/contain/quadratic.js';
import { getECData } from '../../util/innerStore.js';
var LargeLinesPathShape = /** @class */function () {
function LargeLinesPathShape() {
this.polyline = false;
this.curveness = 0;
this.segs = [];
}
return LargeLinesPathShape;
}();
var LargeLinesPath = /** @class */function (_super) {
__extends(LargeLinesPath, _super);
function LargeLinesPath(opts) {
var _this = _super.call(this, opts) || this;
_this._off = 0;
_this.hoverDataIdx = -1;
return _this;
}
LargeLinesPath.prototype.reset = function () {
this.notClear = false;
this._off = 0;
};
LargeLinesPath.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
LargeLinesPath.prototype.getDefaultShape = function () {
return new LargeLinesPathShape();
};
LargeLinesPath.prototype.buildPath = function (ctx, shape) {
var segs = shape.segs;
var curveness = shape.curveness;
var i;
if (shape.polyline) {
for (i = this._off; i < segs.length;) {
var count = segs[i++];
if (count > 0) {
ctx.moveTo(segs[i++], segs[i++]);
for (var k = 1; k < count; k++) {
ctx.lineTo(segs[i++], segs[i++]);
}
}
}
} else {
for (i = this._off; i < segs.length;) {
var x0 = segs[i++];
var y0 = segs[i++];
var x1 = segs[i++];
var y1 = segs[i++];
ctx.moveTo(x0, y0);
if (curveness > 0) {
var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
ctx.quadraticCurveTo(x2, y2, x1, y1);
} else {
ctx.lineTo(x1, y1);
}
}
}
if (this.incremental) {
this._off = i;
this.notClear = true;
}
};
LargeLinesPath.prototype.findDataIndex = function (x, y) {
var shape = this.shape;
var segs = shape.segs;
var curveness = shape.curveness;
var lineWidth = this.style.lineWidth;
if (shape.polyline) {
var dataIndex = 0;
for (var i = 0; i < segs.length;) {
var count = segs[i++];
if (count > 0) {
var x0 = segs[i++];
var y0 = segs[i++];
for (var k = 1; k < count; k++) {
var x1 = segs[i++];
var y1 = segs[i++];
if (lineContain.containStroke(x0, y0, x1, y1, lineWidth, x, y)) {
return dataIndex;
}
}
}
dataIndex++;
}
} else {
var dataIndex = 0;
for (var i = 0; i < segs.length;) {
var x0 = segs[i++];
var y0 = segs[i++];
var x1 = segs[i++];
var y1 = segs[i++];
if (curveness > 0) {
var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
if (quadraticContain.containStroke(x0, y0, x2, y2, x1, y1, lineWidth, x, y)) {
return dataIndex;
}
} else {
if (lineContain.containStroke(x0, y0, x1, y1, lineWidth, x, y)) {
return dataIndex;
}
}
dataIndex++;
}
}
return -1;
};
LargeLinesPath.prototype.contain = function (x, y) {
var localPos = this.transformCoordToLocal(x, y);
var rect = this.getBoundingRect();
x = localPos[0];
y = localPos[1];
if (rect.contain(x, y)) {
// Cache found data index.
var dataIdx = this.hoverDataIdx = this.findDataIndex(x, y);
return dataIdx >= 0;
}
this.hoverDataIdx = -1;
return false;
};
LargeLinesPath.prototype.getBoundingRect = function () {
// Ignore stroke for large symbol draw.
var rect = this._rect;
if (!rect) {
var shape = this.shape;
var points = shape.segs;
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
for (var i = 0; i < points.length;) {
var x = points[i++];
var y = points[i++];
minX = Math.min(x, minX);
maxX = Math.max(x, maxX);
minY = Math.min(y, minY);
maxY = Math.max(y, maxY);
}
rect = this._rect = new graphic.BoundingRect(minX, minY, maxX, maxY);
}
return rect;
};
return LargeLinesPath;
}(graphic.Path);
var LargeLineDraw = /** @class */function () {
function LargeLineDraw() {
this.group = new graphic.Group();
}
/**
* Update symbols draw by new data
*/
LargeLineDraw.prototype.updateData = function (data) {
this._clear();
var lineEl = this._create();
lineEl.setShape({
segs: data.getLayout('linesPoints')
});
this._setCommon(lineEl, data);
};
;
/**
* @override
*/
LargeLineDraw.prototype.incrementalPrepareUpdate = function (data) {
this.group.removeAll();
this._clear();
};
;
/**
* @override
*/
LargeLineDraw.prototype.incrementalUpdate = function (taskParams, data) {
var lastAdded = this._newAdded[0];
var linePoints = data.getLayout('linesPoints');
var oldSegs = lastAdded && lastAdded.shape.segs;
// Merging the exists. Each element has 1e4 points.
// Consider the performance balance between too much elements and too much points in one shape(may affect hover optimization)
if (oldSegs && oldSegs.length < 2e4) {
var oldLen = oldSegs.length;
var newSegs = new Float32Array(oldLen + linePoints.length);
// Concat two array
newSegs.set(oldSegs);
newSegs.set(linePoints, oldLen);
lastAdded.setShape({
segs: newSegs
});
} else {
// Clear
this._newAdded = [];
var lineEl = this._create();
lineEl.incremental = true;
lineEl.setShape({
segs: linePoints
});
this._setCommon(lineEl, data);
lineEl.__startIndex = taskParams.start;
}
};
/**
* @override
*/
LargeLineDraw.prototype.remove = function () {
this._clear();
};
LargeLineDraw.prototype.eachRendered = function (cb) {
this._newAdded[0] && cb(this._newAdded[0]);
};
LargeLineDraw.prototype._create = function () {
var lineEl = new LargeLinesPath({
cursor: 'default',
ignoreCoarsePointer: true
});
this._newAdded.push(lineEl);
this.group.add(lineEl);
return lineEl;
};
LargeLineDraw.prototype._setCommon = function (lineEl, data, isIncremental) {
var hostModel = data.hostModel;
lineEl.setShape({
polyline: hostModel.get('polyline'),
curveness: hostModel.get(['lineStyle', 'curveness'])
});
lineEl.useStyle(hostModel.getModel('lineStyle').getLineStyle());
lineEl.style.strokeNoScale = true;
var style = data.getVisual('style');
if (style && style.stroke) {
lineEl.setStyle('stroke', style.stroke);
}
lineEl.setStyle('fill', null);
var ecData = getECData(lineEl);
// Enable tooltip
// PENDING May have performance issue when path is extremely large
ecData.seriesIndex = hostModel.seriesIndex;
lineEl.on('mousemove', function (e) {
ecData.dataIndex = null;
var dataIndex = lineEl.hoverDataIdx;
if (dataIndex > 0) {
// Provide dataIndex for tooltip
ecData.dataIndex = dataIndex + lineEl.__startIndex;
}
});
};
;
LargeLineDraw.prototype._clear = function () {
this._newAdded = [];
this.group.removeAll();
};
;
return LargeLineDraw;
}();
export default LargeLineDraw;

View File

@ -0,0 +1,309 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
/* global Float32Array */
// TODO Batch by color
import * as graphic from '../../util/graphic.js';
import { createSymbol } from '../../util/symbol.js';
import { getECData } from '../../util/innerStore.js';
var BOOST_SIZE_THRESHOLD = 4;
var LargeSymbolPathShape = /** @class */function () {
function LargeSymbolPathShape() {}
return LargeSymbolPathShape;
}();
var LargeSymbolPath = /** @class */function (_super) {
__extends(LargeSymbolPath, _super);
function LargeSymbolPath(opts) {
var _this = _super.call(this, opts) || this;
_this._off = 0;
_this.hoverDataIdx = -1;
return _this;
}
LargeSymbolPath.prototype.getDefaultShape = function () {
return new LargeSymbolPathShape();
};
LargeSymbolPath.prototype.reset = function () {
this.notClear = false;
this._off = 0;
};
LargeSymbolPath.prototype.buildPath = function (path, shape) {
var points = shape.points;
var size = shape.size;
var symbolProxy = this.symbolProxy;
var symbolProxyShape = symbolProxy.shape;
var ctx = path.getContext ? path.getContext() : path;
var canBoost = ctx && size[0] < BOOST_SIZE_THRESHOLD;
var softClipShape = this.softClipShape;
var i;
// Do draw in afterBrush.
if (canBoost) {
this._ctx = ctx;
return;
}
this._ctx = null;
for (i = this._off; i < points.length;) {
var x = points[i++];
var y = points[i++];
if (isNaN(x) || isNaN(y)) {
continue;
}
if (softClipShape && !softClipShape.contain(x, y)) {
continue;
}
symbolProxyShape.x = x - size[0] / 2;
symbolProxyShape.y = y - size[1] / 2;
symbolProxyShape.width = size[0];
symbolProxyShape.height = size[1];
symbolProxy.buildPath(path, symbolProxyShape, true);
}
if (this.incremental) {
this._off = i;
this.notClear = true;
}
};
LargeSymbolPath.prototype.afterBrush = function () {
var shape = this.shape;
var points = shape.points;
var size = shape.size;
var ctx = this._ctx;
var softClipShape = this.softClipShape;
var i;
if (!ctx) {
return;
}
// PENDING If style or other canvas status changed?
for (i = this._off; i < points.length;) {
var x = points[i++];
var y = points[i++];
if (isNaN(x) || isNaN(y)) {
continue;
}
if (softClipShape && !softClipShape.contain(x, y)) {
continue;
}
// fillRect is faster than building a rect path and draw.
// And it support light globalCompositeOperation.
ctx.fillRect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);
}
if (this.incremental) {
this._off = i;
this.notClear = true;
}
};
LargeSymbolPath.prototype.findDataIndex = function (x, y) {
// TODO ???
// Consider transform
var shape = this.shape;
var points = shape.points;
var size = shape.size;
var w = Math.max(size[0], 4);
var h = Math.max(size[1], 4);
// Not consider transform
// Treat each element as a rect
// top down traverse
for (var idx = points.length / 2 - 1; idx >= 0; idx--) {
var i = idx * 2;
var x0 = points[i] - w / 2;
var y0 = points[i + 1] - h / 2;
if (x >= x0 && y >= y0 && x <= x0 + w && y <= y0 + h) {
return idx;
}
}
return -1;
};
LargeSymbolPath.prototype.contain = function (x, y) {
var localPos = this.transformCoordToLocal(x, y);
var rect = this.getBoundingRect();
x = localPos[0];
y = localPos[1];
if (rect.contain(x, y)) {
// Cache found data index.
var dataIdx = this.hoverDataIdx = this.findDataIndex(x, y);
return dataIdx >= 0;
}
this.hoverDataIdx = -1;
return false;
};
LargeSymbolPath.prototype.getBoundingRect = function () {
// Ignore stroke for large symbol draw.
var rect = this._rect;
if (!rect) {
var shape = this.shape;
var points = shape.points;
var size = shape.size;
var w = size[0];
var h = size[1];
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
for (var i = 0; i < points.length;) {
var x = points[i++];
var y = points[i++];
minX = Math.min(x, minX);
maxX = Math.max(x, maxX);
minY = Math.min(y, minY);
maxY = Math.max(y, maxY);
}
rect = this._rect = new graphic.BoundingRect(minX - w / 2, minY - h / 2, maxX - minX + w, maxY - minY + h);
}
return rect;
};
return LargeSymbolPath;
}(graphic.Path);
var LargeSymbolDraw = /** @class */function () {
function LargeSymbolDraw() {
this.group = new graphic.Group();
}
/**
* Update symbols draw by new data
*/
LargeSymbolDraw.prototype.updateData = function (data, opt) {
this._clear();
var symbolEl = this._create();
symbolEl.setShape({
points: data.getLayout('points')
});
this._setCommon(symbolEl, data, opt);
};
LargeSymbolDraw.prototype.updateLayout = function (data) {
var points = data.getLayout('points');
this.group.eachChild(function (child) {
if (child.startIndex != null) {
var len = (child.endIndex - child.startIndex) * 2;
var byteOffset = child.startIndex * 4 * 2;
points = new Float32Array(points.buffer, byteOffset, len);
}
child.setShape('points', points);
// Reset draw cursor.
child.reset();
});
};
LargeSymbolDraw.prototype.incrementalPrepareUpdate = function (data) {
this._clear();
};
LargeSymbolDraw.prototype.incrementalUpdate = function (taskParams, data, opt) {
var lastAdded = this._newAdded[0];
var points = data.getLayout('points');
var oldPoints = lastAdded && lastAdded.shape.points;
// Merging the exists. Each element has 1e4 points.
// Consider the performance balance between too much elements and too much points in one shape(may affect hover optimization)
if (oldPoints && oldPoints.length < 2e4) {
var oldLen = oldPoints.length;
var newPoints = new Float32Array(oldLen + points.length);
// Concat two array
newPoints.set(oldPoints);
newPoints.set(points, oldLen);
// Update endIndex
lastAdded.endIndex = taskParams.end;
lastAdded.setShape({
points: newPoints
});
} else {
// Clear
this._newAdded = [];
var symbolEl = this._create();
symbolEl.startIndex = taskParams.start;
symbolEl.endIndex = taskParams.end;
symbolEl.incremental = true;
symbolEl.setShape({
points: points
});
this._setCommon(symbolEl, data, opt);
}
};
LargeSymbolDraw.prototype.eachRendered = function (cb) {
this._newAdded[0] && cb(this._newAdded[0]);
};
LargeSymbolDraw.prototype._create = function () {
var symbolEl = new LargeSymbolPath({
cursor: 'default'
});
symbolEl.ignoreCoarsePointer = true;
this.group.add(symbolEl);
this._newAdded.push(symbolEl);
return symbolEl;
};
LargeSymbolDraw.prototype._setCommon = function (symbolEl, data, opt) {
var hostModel = data.hostModel;
opt = opt || {};
var size = data.getVisual('symbolSize');
symbolEl.setShape('size', size instanceof Array ? size : [size, size]);
symbolEl.softClipShape = opt.clipShape || null;
// Create symbolProxy to build path for each data
symbolEl.symbolProxy = createSymbol(data.getVisual('symbol'), 0, 0, 0, 0);
// Use symbolProxy setColor method
symbolEl.setColor = symbolEl.symbolProxy.setColor;
var extrudeShadow = symbolEl.shape.size[0] < BOOST_SIZE_THRESHOLD;
symbolEl.useStyle(
// Draw shadow when doing fillRect is extremely slow.
hostModel.getModel('itemStyle').getItemStyle(extrudeShadow ? ['color', 'shadowBlur', 'shadowColor'] : ['color']));
var globalStyle = data.getVisual('style');
var visualColor = globalStyle && globalStyle.fill;
if (visualColor) {
symbolEl.setColor(visualColor);
}
var ecData = getECData(symbolEl);
// Enable tooltip
// PENDING May have performance issue when path is extremely large
ecData.seriesIndex = hostModel.seriesIndex;
symbolEl.on('mousemove', function (e) {
ecData.dataIndex = null;
var dataIndex = symbolEl.hoverDataIdx;
if (dataIndex >= 0) {
// Provide dataIndex for tooltip
ecData.dataIndex = dataIndex + (symbolEl.startIndex || 0);
}
});
};
LargeSymbolDraw.prototype.remove = function () {
this._clear();
};
LargeSymbolDraw.prototype._clear = function () {
this._newAdded = [];
this.group.removeAll();
};
return LargeSymbolDraw;
}();
export default LargeSymbolDraw;

417
frontend/node_modules/echarts/lib/chart/helper/Line.js generated vendored Normal file
View File

@ -0,0 +1,417 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import { isArray, each } from 'zrender/lib/core/util.js';
import * as vector from 'zrender/lib/core/vector.js';
import * as symbolUtil from '../../util/symbol.js';
import ECLinePath from './LinePath.js';
import * as graphic from '../../util/graphic.js';
import { toggleHoverEmphasis, enterEmphasis, leaveEmphasis, SPECIAL_STATES } from '../../util/states.js';
import { getLabelStatesModels, setLabelStyle } from '../../label/labelStyle.js';
import { round } from '../../util/number.js';
var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
function makeSymbolTypeKey(symbolCategory) {
return '_' + symbolCategory + 'Type';
}
function makeSymbolTypeValue(name, lineData, idx) {
var symbolType = lineData.getItemVisual(idx, name);
if (!symbolType || symbolType === 'none') {
return symbolType;
}
var symbolSize = lineData.getItemVisual(idx, name + 'Size');
var symbolRotate = lineData.getItemVisual(idx, name + 'Rotate');
var symbolOffset = lineData.getItemVisual(idx, name + 'Offset');
var symbolKeepAspect = lineData.getItemVisual(idx, name + 'KeepAspect');
var symbolSizeArr = symbolUtil.normalizeSymbolSize(symbolSize);
var symbolOffsetArr = symbolUtil.normalizeSymbolOffset(symbolOffset || 0, symbolSizeArr);
return symbolType + symbolSizeArr + symbolOffsetArr + (symbolRotate || '') + (symbolKeepAspect || '');
}
/**
* @inner
*/
function createSymbol(name, lineData, idx) {
var symbolType = lineData.getItemVisual(idx, name);
if (!symbolType || symbolType === 'none') {
return;
}
var symbolSize = lineData.getItemVisual(idx, name + 'Size');
var symbolRotate = lineData.getItemVisual(idx, name + 'Rotate');
var symbolOffset = lineData.getItemVisual(idx, name + 'Offset');
var symbolKeepAspect = lineData.getItemVisual(idx, name + 'KeepAspect');
var symbolSizeArr = symbolUtil.normalizeSymbolSize(symbolSize);
var symbolOffsetArr = symbolUtil.normalizeSymbolOffset(symbolOffset || 0, symbolSizeArr);
var symbolPath = symbolUtil.createSymbol(symbolType, -symbolSizeArr[0] / 2 + symbolOffsetArr[0], -symbolSizeArr[1] / 2 + symbolOffsetArr[1], symbolSizeArr[0], symbolSizeArr[1], null, symbolKeepAspect);
symbolPath.__specifiedRotation = symbolRotate == null || isNaN(symbolRotate) ? void 0 : +symbolRotate * Math.PI / 180 || 0;
symbolPath.name = name;
return symbolPath;
}
function createLine(points) {
var line = new ECLinePath({
name: 'line',
subPixelOptimize: true
});
setLinePoints(line.shape, points);
return line;
}
function setLinePoints(targetShape, points) {
targetShape.x1 = points[0][0];
targetShape.y1 = points[0][1];
targetShape.x2 = points[1][0];
targetShape.y2 = points[1][1];
targetShape.percent = 1;
var cp1 = points[2];
if (cp1) {
targetShape.cpx1 = cp1[0];
targetShape.cpy1 = cp1[1];
} else {
targetShape.cpx1 = NaN;
targetShape.cpy1 = NaN;
}
}
var Line = /** @class */function (_super) {
__extends(Line, _super);
function Line(lineData, idx, seriesScope) {
var _this = _super.call(this) || this;
_this._createLine(lineData, idx, seriesScope);
return _this;
}
Line.prototype._createLine = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var linePoints = lineData.getItemLayout(idx);
var line = createLine(linePoints);
line.shape.percent = 0;
graphic.initProps(line, {
shape: {
percent: 1
}
}, seriesModel, idx);
this.add(line);
each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbol = createSymbol(symbolCategory, lineData, idx);
// symbols must added after line to make sure
// it will be updated after line#update.
// Or symbol position and rotation update in line#beforeUpdate will be one frame slow
this.add(symbol);
this[makeSymbolTypeKey(symbolCategory)] = makeSymbolTypeValue(symbolCategory, lineData, idx);
}, this);
this._updateCommonStl(lineData, idx, seriesScope);
};
// TODO More strict on the List type in parameters?
Line.prototype.updateData = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childOfName('line');
var linePoints = lineData.getItemLayout(idx);
var target = {
shape: {}
};
setLinePoints(target.shape, linePoints);
graphic.updateProps(line, target, seriesModel, idx);
each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbolType = makeSymbolTypeValue(symbolCategory, lineData, idx);
var key = makeSymbolTypeKey(symbolCategory);
// Symbol changed
if (this[key] !== symbolType) {
this.remove(this.childOfName(symbolCategory));
var symbol = createSymbol(symbolCategory, lineData, idx);
this.add(symbol);
}
this[key] = symbolType;
}, this);
this._updateCommonStl(lineData, idx, seriesScope);
};
;
Line.prototype.getLinePath = function () {
return this.childAt(0);
};
Line.prototype._updateCommonStl = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childOfName('line');
var emphasisLineStyle = seriesScope && seriesScope.emphasisLineStyle;
var blurLineStyle = seriesScope && seriesScope.blurLineStyle;
var selectLineStyle = seriesScope && seriesScope.selectLineStyle;
var labelStatesModels = seriesScope && seriesScope.labelStatesModels;
var emphasisDisabled = seriesScope && seriesScope.emphasisDisabled;
var focus = seriesScope && seriesScope.focus;
var blurScope = seriesScope && seriesScope.blurScope;
// Optimization for large dataset
if (!seriesScope || lineData.hasItemOption) {
var itemModel = lineData.getItemModel(idx);
var emphasisModel = itemModel.getModel('emphasis');
emphasisLineStyle = emphasisModel.getModel('lineStyle').getLineStyle();
blurLineStyle = itemModel.getModel(['blur', 'lineStyle']).getLineStyle();
selectLineStyle = itemModel.getModel(['select', 'lineStyle']).getLineStyle();
emphasisDisabled = emphasisModel.get('disabled');
focus = emphasisModel.get('focus');
blurScope = emphasisModel.get('blurScope');
labelStatesModels = getLabelStatesModels(itemModel);
}
var lineStyle = lineData.getItemVisual(idx, 'style');
var visualColor = lineStyle.stroke;
line.useStyle(lineStyle);
line.style.fill = null;
line.style.strokeNoScale = true;
line.ensureState('emphasis').style = emphasisLineStyle;
line.ensureState('blur').style = blurLineStyle;
line.ensureState('select').style = selectLineStyle;
// Update symbol
each(SYMBOL_CATEGORIES, function (symbolCategory) {
var symbol = this.childOfName(symbolCategory);
if (symbol) {
// Share opacity and color with line.
symbol.setColor(visualColor);
symbol.style.opacity = lineStyle.opacity;
for (var i = 0; i < SPECIAL_STATES.length; i++) {
var stateName = SPECIAL_STATES[i];
var lineState = line.getState(stateName);
if (lineState) {
var lineStateStyle = lineState.style || {};
var state = symbol.ensureState(stateName);
var stateStyle = state.style || (state.style = {});
if (lineStateStyle.stroke != null) {
stateStyle[symbol.__isEmptyBrush ? 'stroke' : 'fill'] = lineStateStyle.stroke;
}
if (lineStateStyle.opacity != null) {
stateStyle.opacity = lineStateStyle.opacity;
}
}
}
symbol.markRedraw();
}
}, this);
var rawVal = seriesModel.getRawValue(idx);
setLabelStyle(this, labelStatesModels, {
labelDataIndex: idx,
labelFetcher: {
getFormattedLabel: function (dataIndex, stateName) {
return seriesModel.getFormattedLabel(dataIndex, stateName, lineData.dataType);
}
},
inheritColor: visualColor || '#000',
defaultOpacity: lineStyle.opacity,
defaultText: (rawVal == null ? lineData.getName(idx) : isFinite(rawVal) ? round(rawVal) : rawVal) + ''
});
var label = this.getTextContent();
// Always set `textStyle` even if `normalStyle.text` is null, because default
// values have to be set on `normalStyle`.
if (label) {
var labelNormalModel = labelStatesModels.normal;
label.__align = label.style.align;
label.__verticalAlign = label.style.verticalAlign;
// 'start', 'middle', 'end'
label.__position = labelNormalModel.get('position') || 'middle';
var distance = labelNormalModel.get('distance');
if (!isArray(distance)) {
distance = [distance, distance];
}
label.__labelDistance = distance;
}
this.setTextConfig({
position: null,
local: true,
inside: false // Can't be inside for stroke element.
});
toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);
};
Line.prototype.highlight = function () {
enterEmphasis(this);
};
Line.prototype.downplay = function () {
leaveEmphasis(this);
};
Line.prototype.updateLayout = function (lineData, idx) {
this.setLinePoints(lineData.getItemLayout(idx));
};
Line.prototype.setLinePoints = function (points) {
var linePath = this.childOfName('line');
setLinePoints(linePath.shape, points);
linePath.dirty();
};
Line.prototype.beforeUpdate = function () {
var lineGroup = this;
var symbolFrom = lineGroup.childOfName('fromSymbol');
var symbolTo = lineGroup.childOfName('toSymbol');
var label = lineGroup.getTextContent();
// Quick reject
if (!symbolFrom && !symbolTo && (!label || label.ignore)) {
return;
}
var invScale = 1;
var parentNode = this.parent;
while (parentNode) {
if (parentNode.scaleX) {
invScale /= parentNode.scaleX;
}
parentNode = parentNode.parent;
}
var line = lineGroup.childOfName('line');
// If line not changed
// FIXME Parent scale changed
if (!this.__dirty && !line.__dirty) {
return;
}
var percent = line.shape.percent;
var fromPos = line.pointAt(0);
var toPos = line.pointAt(percent);
var d = vector.sub([], toPos, fromPos);
vector.normalize(d, d);
function setSymbolRotation(symbol, percent) {
// Fix #12388
// when symbol is set to be 'arrow' in markLine,
// symbolRotate value will be ignored, and compulsively use tangent angle.
// rotate by default if symbol rotation is not specified
var specifiedRotation = symbol.__specifiedRotation;
if (specifiedRotation == null) {
var tangent = line.tangentAt(percent);
symbol.attr('rotation', (percent === 1 ? -1 : 1) * Math.PI / 2 - Math.atan2(tangent[1], tangent[0]));
} else {
symbol.attr('rotation', specifiedRotation);
}
}
if (symbolFrom) {
symbolFrom.setPosition(fromPos);
setSymbolRotation(symbolFrom, 0);
symbolFrom.scaleX = symbolFrom.scaleY = invScale * percent;
symbolFrom.markRedraw();
}
if (symbolTo) {
symbolTo.setPosition(toPos);
setSymbolRotation(symbolTo, 1);
symbolTo.scaleX = symbolTo.scaleY = invScale * percent;
symbolTo.markRedraw();
}
if (label && !label.ignore) {
label.x = label.y = 0;
label.originX = label.originY = 0;
var textAlign = void 0;
var textVerticalAlign = void 0;
var distance = label.__labelDistance;
var distanceX = distance[0] * invScale;
var distanceY = distance[1] * invScale;
var halfPercent = percent / 2;
var tangent = line.tangentAt(halfPercent);
var n = [tangent[1], -tangent[0]];
var cp = line.pointAt(halfPercent);
if (n[1] > 0) {
n[0] = -n[0];
n[1] = -n[1];
}
var dir = tangent[0] < 0 ? -1 : 1;
if (label.__position !== 'start' && label.__position !== 'end') {
var rotation = -Math.atan2(tangent[1], tangent[0]);
if (toPos[0] < fromPos[0]) {
rotation = Math.PI + rotation;
}
label.rotation = rotation;
}
var dy = void 0;
switch (label.__position) {
case 'insideStartTop':
case 'insideMiddleTop':
case 'insideEndTop':
case 'middle':
dy = -distanceY;
textVerticalAlign = 'bottom';
break;
case 'insideStartBottom':
case 'insideMiddleBottom':
case 'insideEndBottom':
dy = distanceY;
textVerticalAlign = 'top';
break;
default:
dy = 0;
textVerticalAlign = 'middle';
}
switch (label.__position) {
case 'end':
label.x = d[0] * distanceX + toPos[0];
label.y = d[1] * distanceY + toPos[1];
textAlign = d[0] > 0.8 ? 'left' : d[0] < -0.8 ? 'right' : 'center';
textVerticalAlign = d[1] > 0.8 ? 'top' : d[1] < -0.8 ? 'bottom' : 'middle';
break;
case 'start':
label.x = -d[0] * distanceX + fromPos[0];
label.y = -d[1] * distanceY + fromPos[1];
textAlign = d[0] > 0.8 ? 'right' : d[0] < -0.8 ? 'left' : 'center';
textVerticalAlign = d[1] > 0.8 ? 'bottom' : d[1] < -0.8 ? 'top' : 'middle';
break;
case 'insideStartTop':
case 'insideStart':
case 'insideStartBottom':
label.x = distanceX * dir + fromPos[0];
label.y = fromPos[1] + dy;
textAlign = tangent[0] < 0 ? 'right' : 'left';
label.originX = -distanceX * dir;
label.originY = -dy;
break;
case 'insideMiddleTop':
case 'insideMiddle':
case 'insideMiddleBottom':
case 'middle':
label.x = cp[0];
label.y = cp[1] + dy;
textAlign = 'center';
label.originY = -dy;
break;
case 'insideEndTop':
case 'insideEnd':
case 'insideEndBottom':
label.x = -distanceX * dir + toPos[0];
label.y = toPos[1] + dy;
textAlign = tangent[0] >= 0 ? 'right' : 'left';
label.originX = distanceX * dir;
label.originY = -dy;
break;
}
label.scaleX = label.scaleY = invScale;
label.setStyle({
// Use the user specified text align and baseline first
verticalAlign: label.__verticalAlign || textVerticalAlign,
align: label.__align || textAlign
});
}
};
return Line;
}(graphic.Group);
export default Line;

View File

@ -0,0 +1,167 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as graphic from '../../util/graphic.js';
import LineGroup from './Line.js';
import { getLabelStatesModels } from '../../label/labelStyle.js';
var LineDraw = /** @class */function () {
function LineDraw(LineCtor) {
this.group = new graphic.Group();
this._LineCtor = LineCtor || LineGroup;
}
LineDraw.prototype.updateData = function (lineData) {
var _this = this;
// Remove progressive els.
this._progressiveEls = null;
var lineDraw = this;
var group = lineDraw.group;
var oldLineData = lineDraw._lineData;
lineDraw._lineData = lineData;
// There is no oldLineData only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!oldLineData) {
group.removeAll();
}
var seriesScope = makeSeriesScope(lineData);
lineData.diff(oldLineData).add(function (idx) {
_this._doAdd(lineData, idx, seriesScope);
}).update(function (newIdx, oldIdx) {
_this._doUpdate(oldLineData, lineData, oldIdx, newIdx, seriesScope);
}).remove(function (idx) {
group.remove(oldLineData.getItemGraphicEl(idx));
}).execute();
};
;
LineDraw.prototype.updateLayout = function () {
var lineData = this._lineData;
// Do not support update layout in incremental mode.
if (!lineData) {
return;
}
lineData.eachItemGraphicEl(function (el, idx) {
el.updateLayout(lineData, idx);
}, this);
};
;
LineDraw.prototype.incrementalPrepareUpdate = function (lineData) {
this._seriesScope = makeSeriesScope(lineData);
this._lineData = null;
this.group.removeAll();
};
;
LineDraw.prototype.incrementalUpdate = function (taskParams, lineData) {
this._progressiveEls = [];
function updateIncrementalAndHover(el) {
if (!el.isGroup && !isEffectObject(el)) {
el.incremental = true;
el.ensureState('emphasis').hoverLayer = true;
}
}
for (var idx = taskParams.start; idx < taskParams.end; idx++) {
var itemLayout = lineData.getItemLayout(idx);
if (lineNeedsDraw(itemLayout)) {
var el = new this._LineCtor(lineData, idx, this._seriesScope);
el.traverse(updateIncrementalAndHover);
this.group.add(el);
lineData.setItemGraphicEl(idx, el);
this._progressiveEls.push(el);
}
}
};
;
LineDraw.prototype.remove = function () {
this.group.removeAll();
};
;
LineDraw.prototype.eachRendered = function (cb) {
graphic.traverseElements(this._progressiveEls || this.group, cb);
};
LineDraw.prototype._doAdd = function (lineData, idx, seriesScope) {
var itemLayout = lineData.getItemLayout(idx);
if (!lineNeedsDraw(itemLayout)) {
return;
}
var el = new this._LineCtor(lineData, idx, seriesScope);
lineData.setItemGraphicEl(idx, el);
this.group.add(el);
};
LineDraw.prototype._doUpdate = function (oldLineData, newLineData, oldIdx, newIdx, seriesScope) {
var itemEl = oldLineData.getItemGraphicEl(oldIdx);
if (!lineNeedsDraw(newLineData.getItemLayout(newIdx))) {
this.group.remove(itemEl);
return;
}
if (!itemEl) {
itemEl = new this._LineCtor(newLineData, newIdx, seriesScope);
} else {
itemEl.updateData(newLineData, newIdx, seriesScope);
}
newLineData.setItemGraphicEl(newIdx, itemEl);
this.group.add(itemEl);
};
return LineDraw;
}();
function isEffectObject(el) {
return el.animators && el.animators.length > 0;
}
function makeSeriesScope(lineData) {
var hostModel = lineData.hostModel;
var emphasisModel = hostModel.getModel('emphasis');
return {
lineStyle: hostModel.getModel('lineStyle').getLineStyle(),
emphasisLineStyle: emphasisModel.getModel(['lineStyle']).getLineStyle(),
blurLineStyle: hostModel.getModel(['blur', 'lineStyle']).getLineStyle(),
selectLineStyle: hostModel.getModel(['select', 'lineStyle']).getLineStyle(),
emphasisDisabled: emphasisModel.get('disabled'),
blurScope: emphasisModel.get('blurScope'),
focus: emphasisModel.get('focus'),
labelStatesModels: getLabelStatesModels(hostModel)
};
}
function isPointNaN(pt) {
return isNaN(pt[0]) || isNaN(pt[1]);
}
function lineNeedsDraw(pts) {
return pts && !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
}
export default LineDraw;

View File

@ -0,0 +1,111 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
/**
* Line path for bezier and straight line draw
*/
import * as graphic from '../../util/graphic.js';
import * as vec2 from 'zrender/lib/core/vector.js';
var straightLineProto = graphic.Line.prototype;
var bezierCurveProto = graphic.BezierCurve.prototype;
var StraightLineShape = /** @class */function () {
function StraightLineShape() {
// Start point
this.x1 = 0;
this.y1 = 0;
// End point
this.x2 = 0;
this.y2 = 0;
this.percent = 1;
}
return StraightLineShape;
}();
var CurveShape = /** @class */function (_super) {
__extends(CurveShape, _super);
function CurveShape() {
return _super !== null && _super.apply(this, arguments) || this;
}
return CurveShape;
}(StraightLineShape);
function isStraightLine(shape) {
return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
}
var ECLinePath = /** @class */function (_super) {
__extends(ECLinePath, _super);
function ECLinePath(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'ec-line';
return _this;
}
ECLinePath.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
ECLinePath.prototype.getDefaultShape = function () {
return new StraightLineShape();
};
ECLinePath.prototype.buildPath = function (ctx, shape) {
if (isStraightLine(shape)) {
straightLineProto.buildPath.call(this, ctx, shape);
} else {
bezierCurveProto.buildPath.call(this, ctx, shape);
}
};
ECLinePath.prototype.pointAt = function (t) {
if (isStraightLine(this.shape)) {
return straightLineProto.pointAt.call(this, t);
} else {
return bezierCurveProto.pointAt.call(this, t);
}
};
ECLinePath.prototype.tangentAt = function (t) {
var shape = this.shape;
var p = isStraightLine(shape) ? [shape.x2 - shape.x1, shape.y2 - shape.y1] : bezierCurveProto.tangentAt.call(this, t);
return vec2.normalize(p, p);
};
return ECLinePath;
}(graphic.Path);
export default ECLinePath;

View File

@ -0,0 +1,107 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import { toggleHoverEmphasis } from '../../util/states.js';
var Polyline = /** @class */function (_super) {
__extends(Polyline, _super);
function Polyline(lineData, idx, seriesScope) {
var _this = _super.call(this) || this;
_this._createPolyline(lineData, idx, seriesScope);
return _this;
}
Polyline.prototype._createPolyline = function (lineData, idx, seriesScope) {
// let seriesModel = lineData.hostModel;
var points = lineData.getItemLayout(idx);
var line = new graphic.Polyline({
shape: {
points: points
}
});
this.add(line);
this._updateCommonStl(lineData, idx, seriesScope);
};
;
Polyline.prototype.updateData = function (lineData, idx, seriesScope) {
var seriesModel = lineData.hostModel;
var line = this.childAt(0);
var target = {
shape: {
points: lineData.getItemLayout(idx)
}
};
graphic.updateProps(line, target, seriesModel, idx);
this._updateCommonStl(lineData, idx, seriesScope);
};
;
Polyline.prototype._updateCommonStl = function (lineData, idx, seriesScope) {
var line = this.childAt(0);
var itemModel = lineData.getItemModel(idx);
var emphasisLineStyle = seriesScope && seriesScope.emphasisLineStyle;
var focus = seriesScope && seriesScope.focus;
var blurScope = seriesScope && seriesScope.blurScope;
var emphasisDisabled = seriesScope && seriesScope.emphasisDisabled;
if (!seriesScope || lineData.hasItemOption) {
var emphasisModel = itemModel.getModel('emphasis');
emphasisLineStyle = emphasisModel.getModel('lineStyle').getLineStyle();
emphasisDisabled = emphasisModel.get('disabled');
focus = emphasisModel.get('focus');
blurScope = emphasisModel.get('blurScope');
}
line.useStyle(lineData.getItemVisual(idx, 'style'));
line.style.fill = null;
line.style.strokeNoScale = true;
var lineEmphasisState = line.ensureState('emphasis');
lineEmphasisState.style = emphasisLineStyle;
toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);
};
;
Polyline.prototype.updateLayout = function (lineData, idx) {
var polyline = this.childAt(0);
polyline.setShape('points', lineData.getItemLayout(idx));
};
;
return Polyline;
}(graphic.Group);
export default Polyline;

View File

@ -0,0 +1,333 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import { createSymbol, normalizeSymbolOffset, normalizeSymbolSize } from '../../util/symbol.js';
import * as graphic from '../../util/graphic.js';
import { getECData } from '../../util/innerStore.js';
import { enterEmphasis, leaveEmphasis, toggleHoverEmphasis } from '../../util/states.js';
import { getDefaultLabel } from './labelHelper.js';
import { extend } from 'zrender/lib/core/util.js';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
import ZRImage from 'zrender/lib/graphic/Image.js';
import { saveOldStyle } from '../../animation/basicTransition.js';
var Symbol = /** @class */function (_super) {
__extends(Symbol, _super);
function Symbol(data, idx, seriesScope, opts) {
var _this = _super.call(this) || this;
_this.updateData(data, idx, seriesScope, opts);
return _this;
}
Symbol.prototype._createSymbol = function (symbolType, data, idx, symbolSize, keepAspect) {
// Remove paths created before
this.removeAll();
// let symbolPath = createSymbol(
// symbolType, -0.5, -0.5, 1, 1, color
// );
// If width/height are set too small (e.g., set to 1) on ios10
// and macOS Sierra, a circle stroke become a rect, no matter what
// the scale is set. So we set width/height as 2. See #4150.
var symbolPath = createSymbol(symbolType, -1, -1, 2, 2, null, keepAspect);
symbolPath.attr({
z2: 100,
culling: true,
scaleX: symbolSize[0] / 2,
scaleY: symbolSize[1] / 2
});
// Rewrite drift method
symbolPath.drift = driftSymbol;
this._symbolType = symbolType;
this.add(symbolPath);
};
/**
* Stop animation
* @param {boolean} toLastFrame
*/
Symbol.prototype.stopSymbolAnimation = function (toLastFrame) {
this.childAt(0).stopAnimation(null, toLastFrame);
};
Symbol.prototype.getSymbolType = function () {
return this._symbolType;
};
/**
* FIXME:
* Caution: This method breaks the encapsulation of this module,
* but it indeed brings convenience. So do not use the method
* unless you detailedly know all the implements of `Symbol`,
* especially animation.
*
* Get symbol path element.
*/
Symbol.prototype.getSymbolPath = function () {
return this.childAt(0);
};
/**
* Highlight symbol
*/
Symbol.prototype.highlight = function () {
enterEmphasis(this.childAt(0));
};
/**
* Downplay symbol
*/
Symbol.prototype.downplay = function () {
leaveEmphasis(this.childAt(0));
};
/**
* @param {number} zlevel
* @param {number} z
*/
Symbol.prototype.setZ = function (zlevel, z) {
var symbolPath = this.childAt(0);
symbolPath.zlevel = zlevel;
symbolPath.z = z;
};
Symbol.prototype.setDraggable = function (draggable, hasCursorOption) {
var symbolPath = this.childAt(0);
symbolPath.draggable = draggable;
symbolPath.cursor = !hasCursorOption && draggable ? 'move' : symbolPath.cursor;
};
/**
* Update symbol properties
*/
Symbol.prototype.updateData = function (data, idx, seriesScope, opts) {
this.silent = false;
var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
var seriesModel = data.hostModel;
var symbolSize = Symbol.getSymbolSize(data, idx);
var isInit = symbolType !== this._symbolType;
var disableAnimation = opts && opts.disableAnimation;
if (isInit) {
var keepAspect = data.getItemVisual(idx, 'symbolKeepAspect');
this._createSymbol(symbolType, data, idx, symbolSize, keepAspect);
} else {
var symbolPath = this.childAt(0);
symbolPath.silent = false;
var target = {
scaleX: symbolSize[0] / 2,
scaleY: symbolSize[1] / 2
};
disableAnimation ? symbolPath.attr(target) : graphic.updateProps(symbolPath, target, seriesModel, idx);
saveOldStyle(symbolPath);
}
this._updateCommon(data, idx, symbolSize, seriesScope, opts);
if (isInit) {
var symbolPath = this.childAt(0);
if (!disableAnimation) {
var target = {
scaleX: this._sizeX,
scaleY: this._sizeY,
style: {
// Always fadeIn. Because it has fadeOut animation when symbol is removed..
opacity: symbolPath.style.opacity
}
};
symbolPath.scaleX = symbolPath.scaleY = 0;
symbolPath.style.opacity = 0;
graphic.initProps(symbolPath, target, seriesModel, idx);
}
}
if (disableAnimation) {
// Must stop leave transition manually if don't call initProps or updateProps.
this.childAt(0).stopAnimation('leave');
}
};
Symbol.prototype._updateCommon = function (data, idx, symbolSize, seriesScope, opts) {
var symbolPath = this.childAt(0);
var seriesModel = data.hostModel;
var emphasisItemStyle;
var blurItemStyle;
var selectItemStyle;
var focus;
var blurScope;
var emphasisDisabled;
var labelStatesModels;
var hoverScale;
var cursorStyle;
if (seriesScope) {
emphasisItemStyle = seriesScope.emphasisItemStyle;
blurItemStyle = seriesScope.blurItemStyle;
selectItemStyle = seriesScope.selectItemStyle;
focus = seriesScope.focus;
blurScope = seriesScope.blurScope;
labelStatesModels = seriesScope.labelStatesModels;
hoverScale = seriesScope.hoverScale;
cursorStyle = seriesScope.cursorStyle;
emphasisDisabled = seriesScope.emphasisDisabled;
}
if (!seriesScope || data.hasItemOption) {
var itemModel = seriesScope && seriesScope.itemModel ? seriesScope.itemModel : data.getItemModel(idx);
var emphasisModel = itemModel.getModel('emphasis');
emphasisItemStyle = emphasisModel.getModel('itemStyle').getItemStyle();
selectItemStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
blurItemStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
focus = emphasisModel.get('focus');
blurScope = emphasisModel.get('blurScope');
emphasisDisabled = emphasisModel.get('disabled');
labelStatesModels = getLabelStatesModels(itemModel);
hoverScale = emphasisModel.getShallow('scale');
cursorStyle = itemModel.getShallow('cursor');
}
var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
var symbolOffset = normalizeSymbolOffset(data.getItemVisual(idx, 'symbolOffset'), symbolSize);
if (symbolOffset) {
symbolPath.x = symbolOffset[0];
symbolPath.y = symbolOffset[1];
}
cursorStyle && symbolPath.attr('cursor', cursorStyle);
var symbolStyle = data.getItemVisual(idx, 'style');
var visualColor = symbolStyle.fill;
if (symbolPath instanceof ZRImage) {
var pathStyle = symbolPath.style;
symbolPath.useStyle(extend({
// TODO other properties like x, y ?
image: pathStyle.image,
x: pathStyle.x,
y: pathStyle.y,
width: pathStyle.width,
height: pathStyle.height
}, symbolStyle));
} else {
if (symbolPath.__isEmptyBrush) {
// fill and stroke will be swapped if it's empty.
// So we cloned a new style to avoid it affecting the original style in visual storage.
// TODO Better implementation. No empty logic!
symbolPath.useStyle(extend({}, symbolStyle));
} else {
symbolPath.useStyle(symbolStyle);
}
// Disable decal because symbol scale will been applied on the decal.
symbolPath.style.decal = null;
symbolPath.setColor(visualColor, opts && opts.symbolInnerColor);
symbolPath.style.strokeNoScale = true;
}
var liftZ = data.getItemVisual(idx, 'liftZ');
var z2Origin = this._z2;
if (liftZ != null) {
if (z2Origin == null) {
this._z2 = symbolPath.z2;
symbolPath.z2 += liftZ;
}
} else if (z2Origin != null) {
symbolPath.z2 = z2Origin;
this._z2 = null;
}
var useNameLabel = opts && opts.useNameLabel;
setLabelStyle(symbolPath, labelStatesModels, {
labelFetcher: seriesModel,
labelDataIndex: idx,
defaultText: getLabelDefaultText,
inheritColor: visualColor,
defaultOpacity: symbolStyle.opacity
});
// Do not execute util needed.
function getLabelDefaultText(idx) {
return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
}
this._sizeX = symbolSize[0] / 2;
this._sizeY = symbolSize[1] / 2;
var emphasisState = symbolPath.ensureState('emphasis');
emphasisState.style = emphasisItemStyle;
symbolPath.ensureState('select').style = selectItemStyle;
symbolPath.ensureState('blur').style = blurItemStyle;
// null / undefined / true means to use default strategy.
// 0 / false / negative number / NaN / Infinity means no scale.
var scaleRatio = hoverScale == null || hoverScale === true ? Math.max(1.1, 3 / this._sizeY)
// PENDING: restrict hoverScale > 1? It seems unreasonable to scale down
: isFinite(hoverScale) && hoverScale > 0 ? +hoverScale : 1;
// always set scale to allow resetting
emphasisState.scaleX = this._sizeX * scaleRatio;
emphasisState.scaleY = this._sizeY * scaleRatio;
this.setSymbolScale(1);
toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);
};
Symbol.prototype.setSymbolScale = function (scale) {
this.scaleX = this.scaleY = scale;
};
Symbol.prototype.fadeOut = function (cb, seriesModel, opt) {
var symbolPath = this.childAt(0);
var dataIndex = getECData(this).dataIndex;
var animationOpt = opt && opt.animation;
// Avoid mistaken hover when fading out
this.silent = symbolPath.silent = true;
// Not show text when animating
if (opt && opt.fadeLabel) {
var textContent = symbolPath.getTextContent();
if (textContent) {
graphic.removeElement(textContent, {
style: {
opacity: 0
}
}, seriesModel, {
dataIndex: dataIndex,
removeOpt: animationOpt,
cb: function () {
symbolPath.removeTextContent();
}
});
}
} else {
symbolPath.removeTextContent();
}
graphic.removeElement(symbolPath, {
style: {
opacity: 0
},
scaleX: 0,
scaleY: 0
}, seriesModel, {
dataIndex: dataIndex,
cb: cb,
removeOpt: animationOpt
});
};
Symbol.getSymbolSize = function (data, idx) {
return normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
};
return Symbol;
}(graphic.Group);
function driftSymbol(dx, dy) {
this.parent.drift(dx, dy);
}
export default Symbol;

View File

@ -0,0 +1,216 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as graphic from '../../util/graphic.js';
import SymbolClz from './Symbol.js';
import { isObject } from 'zrender/lib/core/util.js';
import { getLabelStatesModels } from '../../label/labelStyle.js';
function symbolNeedsDraw(data, point, idx, opt) {
return point && !isNaN(point[0]) && !isNaN(point[1]) && !(opt.isIgnore && opt.isIgnore(idx))
// We do not set clipShape on group, because it will cut part of
// the symbol element shape. We use the same clip shape here as
// the line clip.
&& !(opt.clipShape && !opt.clipShape.contain(point[0], point[1])) && data.getItemVisual(idx, 'symbol') !== 'none';
}
function normalizeUpdateOpt(opt) {
if (opt != null && !isObject(opt)) {
opt = {
isIgnore: opt
};
}
return opt || {};
}
function makeSeriesScope(data) {
var seriesModel = data.hostModel;
var emphasisModel = seriesModel.getModel('emphasis');
return {
emphasisItemStyle: emphasisModel.getModel('itemStyle').getItemStyle(),
blurItemStyle: seriesModel.getModel(['blur', 'itemStyle']).getItemStyle(),
selectItemStyle: seriesModel.getModel(['select', 'itemStyle']).getItemStyle(),
focus: emphasisModel.get('focus'),
blurScope: emphasisModel.get('blurScope'),
emphasisDisabled: emphasisModel.get('disabled'),
hoverScale: emphasisModel.get('scale'),
labelStatesModels: getLabelStatesModels(seriesModel),
cursorStyle: seriesModel.get('cursor')
};
}
var SymbolDraw = /** @class */function () {
function SymbolDraw(SymbolCtor) {
this.group = new graphic.Group();
this._SymbolCtor = SymbolCtor || SymbolClz;
}
/**
* Update symbols draw by new data
*/
SymbolDraw.prototype.updateData = function (data, opt) {
// Remove progressive els.
this._progressiveEls = null;
opt = normalizeUpdateOpt(opt);
var group = this.group;
var seriesModel = data.hostModel;
var oldData = this._data;
var SymbolCtor = this._SymbolCtor;
var disableAnimation = opt.disableAnimation;
var seriesScope = makeSeriesScope(data);
var symbolUpdateOpt = {
disableAnimation: disableAnimation
};
var getSymbolPoint = opt.getSymbolPoint || function (idx) {
return data.getItemLayout(idx);
};
// There is no oldLineData only when first rendering or switching from
// stream mode to normal mode, where previous elements should be removed.
if (!oldData) {
group.removeAll();
}
data.diff(oldData).add(function (newIdx) {
var point = getSymbolPoint(newIdx);
if (symbolNeedsDraw(data, point, newIdx, opt)) {
var symbolEl = new SymbolCtor(data, newIdx, seriesScope, symbolUpdateOpt);
symbolEl.setPosition(point);
data.setItemGraphicEl(newIdx, symbolEl);
group.add(symbolEl);
}
}).update(function (newIdx, oldIdx) {
var symbolEl = oldData.getItemGraphicEl(oldIdx);
var point = getSymbolPoint(newIdx);
if (!symbolNeedsDraw(data, point, newIdx, opt)) {
group.remove(symbolEl);
return;
}
var newSymbolType = data.getItemVisual(newIdx, 'symbol') || 'circle';
var oldSymbolType = symbolEl && symbolEl.getSymbolType && symbolEl.getSymbolType();
if (!symbolEl
// Create a new if symbol type changed.
|| oldSymbolType && oldSymbolType !== newSymbolType) {
group.remove(symbolEl);
symbolEl = new SymbolCtor(data, newIdx, seriesScope, symbolUpdateOpt);
symbolEl.setPosition(point);
} else {
symbolEl.updateData(data, newIdx, seriesScope, symbolUpdateOpt);
var target = {
x: point[0],
y: point[1]
};
disableAnimation ? symbolEl.attr(target) : graphic.updateProps(symbolEl, target, seriesModel);
}
// Add back
group.add(symbolEl);
data.setItemGraphicEl(newIdx, symbolEl);
}).remove(function (oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
el && el.fadeOut(function () {
group.remove(el);
}, seriesModel);
}).execute();
this._getSymbolPoint = getSymbolPoint;
this._data = data;
};
;
SymbolDraw.prototype.updateLayout = function () {
var _this = this;
var data = this._data;
if (data) {
// Not use animation
data.eachItemGraphicEl(function (el, idx) {
var point = _this._getSymbolPoint(idx);
el.setPosition(point);
el.markRedraw();
});
}
};
;
SymbolDraw.prototype.incrementalPrepareUpdate = function (data) {
this._seriesScope = makeSeriesScope(data);
this._data = null;
this.group.removeAll();
};
;
/**
* Update symbols draw by new data
*/
SymbolDraw.prototype.incrementalUpdate = function (taskParams, data, opt) {
// Clear
this._progressiveEls = [];
opt = normalizeUpdateOpt(opt);
function updateIncrementalAndHover(el) {
if (!el.isGroup) {
el.incremental = true;
el.ensureState('emphasis').hoverLayer = true;
}
}
for (var idx = taskParams.start; idx < taskParams.end; idx++) {
var point = data.getItemLayout(idx);
if (symbolNeedsDraw(data, point, idx, opt)) {
var el = new this._SymbolCtor(data, idx, this._seriesScope);
el.traverse(updateIncrementalAndHover);
el.setPosition(point);
this.group.add(el);
data.setItemGraphicEl(idx, el);
this._progressiveEls.push(el);
}
}
};
;
SymbolDraw.prototype.eachRendered = function (cb) {
graphic.traverseElements(this._progressiveEls || this.group, cb);
};
SymbolDraw.prototype.remove = function (enableAnimation) {
var group = this.group;
var data = this._data;
// Incremental model do not have this._data.
if (data && enableAnimation) {
data.eachItemGraphicEl(function (el) {
el.fadeOut(function () {
group.remove(el);
}, data.hostModel);
});
} else {
group.removeAll();
}
};
;
return SymbolDraw;
}();
export default SymbolDraw;

View File

@ -0,0 +1,145 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as graphic from '../../util/graphic.js';
import { round } from '../../util/number.js';
import { isFunction } from 'zrender/lib/core/util.js';
function createGridClipPath(cartesian, hasAnimation, seriesModel, done, during) {
var rect = cartesian.getArea();
var x = rect.x;
var y = rect.y;
var width = rect.width;
var height = rect.height;
var lineWidth = seriesModel.get(['lineStyle', 'width']) || 0;
// Expand the clip path a bit to avoid the border is clipped and looks thinner
x -= lineWidth / 2;
y -= lineWidth / 2;
width += lineWidth;
height += lineWidth;
// fix: https://github.com/apache/incubator-echarts/issues/11369
width = Math.ceil(width);
if (x !== Math.floor(x)) {
x = Math.floor(x);
// if no extra 1px on `width`, it will still be clipped since `x` is floored
width++;
}
var clipPath = new graphic.Rect({
shape: {
x: x,
y: y,
width: width,
height: height
}
});
if (hasAnimation) {
var baseAxis = cartesian.getBaseAxis();
var isHorizontal = baseAxis.isHorizontal();
var isAxisInversed = baseAxis.inverse;
if (isHorizontal) {
if (isAxisInversed) {
clipPath.shape.x += width;
}
clipPath.shape.width = 0;
} else {
if (!isAxisInversed) {
clipPath.shape.y += height;
}
clipPath.shape.height = 0;
}
var duringCb = isFunction(during) ? function (percent) {
during(percent, clipPath);
} : null;
graphic.initProps(clipPath, {
shape: {
width: width,
height: height,
x: x,
y: y
}
}, seriesModel, null, done, duringCb);
}
return clipPath;
}
function createPolarClipPath(polar, hasAnimation, seriesModel) {
var sectorArea = polar.getArea();
// Avoid float number rounding error for symbol on the edge of axis extent.
var r0 = round(sectorArea.r0, 1);
var r = round(sectorArea.r, 1);
var clipPath = new graphic.Sector({
shape: {
cx: round(polar.cx, 1),
cy: round(polar.cy, 1),
r0: r0,
r: r,
startAngle: sectorArea.startAngle,
endAngle: sectorArea.endAngle,
clockwise: sectorArea.clockwise
}
});
if (hasAnimation) {
var isRadial = polar.getBaseAxis().dim === 'angle';
if (isRadial) {
clipPath.shape.endAngle = sectorArea.startAngle;
} else {
clipPath.shape.r = r0;
}
graphic.initProps(clipPath, {
shape: {
endAngle: sectorArea.endAngle,
r: r
}
}, seriesModel);
}
return clipPath;
}
function createClipPath(coordSys, hasAnimation, seriesModel, done, during) {
if (!coordSys) {
return null;
} else if (coordSys.type === 'polar') {
return createPolarClipPath(coordSys, hasAnimation, seriesModel);
} else if (coordSys.type === 'cartesian2d') {
return createGridClipPath(coordSys, hasAnimation, seriesModel, done, during);
}
return null;
}
export { createGridClipPath, createPolarClipPath, createClipPath };

View File

@ -0,0 +1,114 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
import SeriesData from '../../data/SeriesData.js';
import Graph from '../../data/Graph.js';
import linkSeriesData from '../../data/helper/linkSeriesData.js';
import prepareSeriesDataSchema from '../../data/helper/createDimensions.js';
import CoordinateSystem from '../../core/CoordinateSystem.js';
import createSeriesData from './createSeriesData.js';
import { convertOptionIdName } from '../../util/model.js';
export default function createGraphFromNodeEdge(nodes, edges, seriesModel, directed, beforeLink) {
// ??? TODO
// support dataset?
var graph = new Graph(directed);
for (var i = 0; i < nodes.length; i++) {
graph.addNode(zrUtil.retrieve(
// Id, name, dataIndex
nodes[i].id, nodes[i].name, i), i);
}
var linkNameList = [];
var validEdges = [];
var linkCount = 0;
for (var i = 0; i < edges.length; i++) {
var link = edges[i];
var source = link.source;
var target = link.target;
// addEdge may fail when source or target not exists
if (graph.addEdge(source, target, linkCount)) {
validEdges.push(link);
linkNameList.push(zrUtil.retrieve(convertOptionIdName(link.id, null), source + ' > ' + target));
linkCount++;
}
}
var coordSys = seriesModel.get('coordinateSystem');
var nodeData;
if (coordSys === 'cartesian2d' || coordSys === 'polar') {
nodeData = createSeriesData(nodes, seriesModel);
} else {
var coordSysCtor = CoordinateSystem.get(coordSys);
var coordDimensions = coordSysCtor ? coordSysCtor.dimensions || [] : [];
// FIXME: Some geo do not need `value` dimenson, whereas `calendar` needs
// `value` dimension, but graph need `value` dimension. It's better to
// uniform this behavior.
if (zrUtil.indexOf(coordDimensions, 'value') < 0) {
coordDimensions.concat(['value']);
}
var dimensions = prepareSeriesDataSchema(nodes, {
coordDimensions: coordDimensions,
encodeDefine: seriesModel.getEncode()
}).dimensions;
nodeData = new SeriesData(dimensions, seriesModel);
nodeData.initData(nodes);
}
var edgeData = new SeriesData(['value'], seriesModel);
edgeData.initData(validEdges, linkNameList);
beforeLink && beforeLink(nodeData, edgeData);
linkSeriesData({
mainData: nodeData,
struct: graph,
structAttr: 'graph',
datas: {
node: nodeData,
edge: edgeData
},
datasAttr: {
node: 'data',
edge: 'edgeData'
}
});
// Update dataIndex of nodes and edges because invalid edge may be removed
graph.update();
return graph;
}

View File

@ -0,0 +1,62 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { makeInner } from '../../util/model.js';
/**
* @return {string} If large mode changed, return string 'reset';
*/
export default function createRenderPlanner() {
var inner = makeInner();
return function (seriesModel) {
var fields = inner(seriesModel);
var pipelineContext = seriesModel.pipelineContext;
var originalLarge = !!fields.large;
var originalProgressive = !!fields.progressiveRender;
// FIXME: if the planner works on a filtered series, `pipelineContext` does not
// exists. See #11611 . Probably we need to modify this structure, see the comment
// on `performRawSeries` in `Schedular.js`.
var large = fields.large = !!(pipelineContext && pipelineContext.large);
var progressive = fields.progressiveRender = !!(pipelineContext && pipelineContext.progressiveRender);
return !!(originalLarge !== large || originalProgressive !== progressive) && 'reset';
};
}

View File

@ -0,0 +1,162 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
import SeriesData from '../../data/SeriesData.js';
import prepareSeriesDataSchema from '../../data/helper/createDimensions.js';
import { getDimensionTypeByAxis } from '../../data/helper/dimensionHelper.js';
import { getDataItemValue } from '../../util/model.js';
import CoordinateSystem from '../../core/CoordinateSystem.js';
import { getCoordSysInfoBySeries } from '../../model/referHelper.js';
import { createSourceFromSeriesDataOption } from '../../data/Source.js';
import { enableDataStack } from '../../data/helper/dataStackHelper.js';
import { makeSeriesEncodeForAxisCoordSys } from '../../data/helper/sourceHelper.js';
import { SOURCE_FORMAT_ORIGINAL } from '../../util/types.js';
function getCoordSysDimDefs(seriesModel, coordSysInfo) {
var coordSysName = seriesModel.get('coordinateSystem');
var registeredCoordSys = CoordinateSystem.get(coordSysName);
var coordSysDimDefs;
if (coordSysInfo && coordSysInfo.coordSysDims) {
coordSysDimDefs = zrUtil.map(coordSysInfo.coordSysDims, function (dim) {
var dimInfo = {
name: dim
};
var axisModel = coordSysInfo.axisMap.get(dim);
if (axisModel) {
var axisType = axisModel.get('type');
dimInfo.type = getDimensionTypeByAxis(axisType);
}
return dimInfo;
});
}
if (!coordSysDimDefs) {
// Get dimensions from registered coordinate system
coordSysDimDefs = registeredCoordSys && (registeredCoordSys.getDimensionsInfo ? registeredCoordSys.getDimensionsInfo() : registeredCoordSys.dimensions.slice()) || ['x', 'y'];
}
return coordSysDimDefs;
}
function injectOrdinalMeta(dimInfoList, createInvertedIndices, coordSysInfo) {
var firstCategoryDimIndex;
var hasNameEncode;
coordSysInfo && zrUtil.each(dimInfoList, function (dimInfo, dimIndex) {
var coordDim = dimInfo.coordDim;
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
if (categoryAxisModel) {
if (firstCategoryDimIndex == null) {
firstCategoryDimIndex = dimIndex;
}
dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta();
if (createInvertedIndices) {
dimInfo.createInvertedIndices = true;
}
}
if (dimInfo.otherDims.itemName != null) {
hasNameEncode = true;
}
});
if (!hasNameEncode && firstCategoryDimIndex != null) {
dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0;
}
return firstCategoryDimIndex;
}
/**
* Caution: there are side effects to `sourceManager` in this method.
* Should better only be called in `Series['getInitialData']`.
*/
function createSeriesData(sourceRaw, seriesModel, opt) {
opt = opt || {};
var sourceManager = seriesModel.getSourceManager();
var source;
var isOriginalSource = false;
if (sourceRaw) {
isOriginalSource = true;
source = createSourceFromSeriesDataOption(sourceRaw);
} else {
source = sourceManager.getSource();
// Is series.data. not dataset.
isOriginalSource = source.sourceFormat === SOURCE_FORMAT_ORIGINAL;
}
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
var coordSysDimDefs = getCoordSysDimDefs(seriesModel, coordSysInfo);
var useEncodeDefaulter = opt.useEncodeDefaulter;
var encodeDefaulter = zrUtil.isFunction(useEncodeDefaulter) ? useEncodeDefaulter : useEncodeDefaulter ? zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel) : null;
var createDimensionOptions = {
coordDimensions: coordSysDimDefs,
generateCoord: opt.generateCoord,
encodeDefine: seriesModel.getEncode(),
encodeDefaulter: encodeDefaulter,
canOmitUnusedDimensions: !isOriginalSource
};
var schema = prepareSeriesDataSchema(source, createDimensionOptions);
var firstCategoryDimIndex = injectOrdinalMeta(schema.dimensions, opt.createInvertedIndices, coordSysInfo);
var store = !isOriginalSource ? sourceManager.getSharedDataStore(schema) : null;
var stackCalculationInfo = enableDataStack(seriesModel, {
schema: schema,
store: store
});
var data = new SeriesData(schema, seriesModel);
data.setCalculationInfo(stackCalculationInfo);
var dimValueGetter = firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source) ? function (itemOpt, dimName, dataIndex, dimIndex) {
// Use dataIndex as ordinal value in categoryAxis
return dimIndex === firstCategoryDimIndex ? dataIndex : this.defaultDimValueGetter(itemOpt, dimName, dataIndex, dimIndex);
} : null;
data.hasItemOption = false;
data.initData(
// Try to reuse the data store in sourceManager if using dataset.
isOriginalSource ? source : store, null, dimValueGetter);
return data;
}
function isNeedCompleteOrdinalData(source) {
if (source.sourceFormat === SOURCE_FORMAT_ORIGINAL) {
var sampleItem = firstDataNotNull(source.data || []);
return !zrUtil.isArray(getDataItemValue(sampleItem));
}
}
function firstDataNotNull(arr) {
var i = 0;
while (i < arr.length && arr[i] == null) {
i++;
}
return arr[i];
}
export default createSeriesData;

View File

@ -0,0 +1,68 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import prepareSeriesDataSchema from '../../data/helper/createDimensions.js';
import SeriesData from '../../data/SeriesData.js';
import { extend, isArray } from 'zrender/lib/core/util.js';
/**
* [Usage]:
* (1)
* createListSimply(seriesModel, ['value']);
* (2)
* createListSimply(seriesModel, {
* coordDimensions: ['value'],
* dimensionsCount: 5
* });
*/
export default function createSeriesDataSimply(seriesModel, opt, nameList) {
opt = isArray(opt) && {
coordDimensions: opt
} || extend({
encodeDefine: seriesModel.getEncode()
}, opt);
var source = seriesModel.getSource();
var dimensions = prepareSeriesDataSchema(source, opt).dimensions;
var list = new SeriesData(dimensions, seriesModel);
list.initData(source, nameList);
return list;
}

View File

@ -0,0 +1,58 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { getDecalFromPalette } from '../../model/mixin/palette.js';
export default function enableAriaDecalForTree(seriesModel) {
var data = seriesModel.getData();
var tree = data.tree;
var decalPaletteScope = {};
tree.eachNode(function (node) {
// Use decal of level 1 node
var current = node;
while (current && current.depth > 1) {
current = current.parentNode;
}
var decal = getDecalFromPalette(seriesModel.ecModel, current.name || current.dataIndex + '', decalPaletteScope);
node.setVisual('decal', decal);
});
}

View File

@ -0,0 +1,77 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { retrieveRawValue } from '../../data/helper/dataProvider.js';
import { isArray } from 'zrender/lib/core/util.js';
/**
* @return label string. Not null/undefined
*/
export function getDefaultLabel(data, dataIndex) {
var labelDims = data.mapDimensionsAll('defaultedLabel');
var len = labelDims.length;
// Simple optimization (in lots of cases, label dims length is 1)
if (len === 1) {
var rawVal = retrieveRawValue(data, dataIndex, labelDims[0]);
return rawVal != null ? rawVal + '' : null;
} else if (len) {
var vals = [];
for (var i = 0; i < labelDims.length; i++) {
vals.push(retrieveRawValue(data, dataIndex, labelDims[i]));
}
return vals.join(' ');
}
}
export function getDefaultInterpolatedLabel(data, interpolatedValue) {
var labelDims = data.mapDimensionsAll('defaultedLabel');
if (!isArray(interpolatedValue)) {
return interpolatedValue + '';
}
var vals = [];
for (var i = 0; i < labelDims.length; i++) {
var dimIndex = data.getDimensionIndex(labelDims[i]);
if (dimIndex >= 0) {
vals.push(interpolatedValue[dimIndex]);
}
}
return vals.join(' ');
}

View File

@ -0,0 +1,226 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
// @ts-nocheck
import * as zrUtil from 'zrender/lib/core/util.js';
var KEY_DELIMITER = '-->';
/**
* params handler
* @param {module:echarts/model/SeriesModel} seriesModel
* @returns {*}
*/
var getAutoCurvenessParams = function (seriesModel) {
return seriesModel.get('autoCurveness') || null;
};
/**
* Generate a list of edge curvatures, 20 is the default
* @param {module:echarts/model/SeriesModel} seriesModel
* @param {number} appendLength
* @return 20 => [0, -0.2, 0.2, -0.4, 0.4, -0.6, 0.6, -0.8, 0.8, -1, 1, -1.2, 1.2, -1.4, 1.4, -1.6, 1.6, -1.8, 1.8, -2]
*/
var createCurveness = function (seriesModel, appendLength) {
var autoCurvenessParmas = getAutoCurvenessParams(seriesModel);
var length = 20;
var curvenessList = [];
// handler the function set
if (zrUtil.isNumber(autoCurvenessParmas)) {
length = autoCurvenessParmas;
} else if (zrUtil.isArray(autoCurvenessParmas)) {
seriesModel.__curvenessList = autoCurvenessParmas;
return;
}
// append length
if (appendLength > length) {
length = appendLength;
}
// make sure the length is even
var len = length % 2 ? length + 2 : length + 3;
curvenessList = [];
for (var i = 0; i < len; i++) {
curvenessList.push((i % 2 ? i + 1 : i) / 10 * (i % 2 ? -1 : 1));
}
seriesModel.__curvenessList = curvenessList;
};
/**
* Create different cache key data in the positive and negative directions, in order to set the curvature later
* @param {number|string|module:echarts/data/Graph.Node} n1
* @param {number|string|module:echarts/data/Graph.Node} n2
* @param {module:echarts/model/SeriesModel} seriesModel
* @returns {string} key
*/
var getKeyOfEdges = function (n1, n2, seriesModel) {
var source = [n1.id, n1.dataIndex].join('.');
var target = [n2.id, n2.dataIndex].join('.');
return [seriesModel.uid, source, target].join(KEY_DELIMITER);
};
/**
* get opposite key
* @param {string} key
* @returns {string}
*/
var getOppositeKey = function (key) {
var keys = key.split(KEY_DELIMITER);
return [keys[0], keys[2], keys[1]].join(KEY_DELIMITER);
};
/**
* get edgeMap with key
* @param edge
* @param {module:echarts/model/SeriesModel} seriesModel
*/
var getEdgeFromMap = function (edge, seriesModel) {
var key = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
return seriesModel.__edgeMap[key];
};
/**
* calculate all cases total length
* @param edge
* @param seriesModel
* @returns {number}
*/
var getTotalLengthBetweenNodes = function (edge, seriesModel) {
var len = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node1, edge.node2, seriesModel), seriesModel);
var lenV = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node2, edge.node1, seriesModel), seriesModel);
return len + lenV;
};
/**
*
* @param key
*/
var getEdgeMapLengthWithKey = function (key, seriesModel) {
var edgeMap = seriesModel.__edgeMap;
return edgeMap[key] ? edgeMap[key].length : 0;
};
/**
* Count the number of edges between the same two points, used to obtain the curvature table and the parity of the edge
* @see /graph/GraphSeries.js@getInitialData
* @param {module:echarts/model/SeriesModel} seriesModel
*/
export function initCurvenessList(seriesModel) {
if (!getAutoCurvenessParams(seriesModel)) {
return;
}
seriesModel.__curvenessList = [];
seriesModel.__edgeMap = {};
// calc the array of curveness List
createCurveness(seriesModel);
}
/**
* set edgeMap with key
* @param {number|string|module:echarts/data/Graph.Node} n1
* @param {number|string|module:echarts/data/Graph.Node} n2
* @param {module:echarts/model/SeriesModel} seriesModel
* @param {number} index
*/
export function createEdgeMapForCurveness(n1, n2, seriesModel, index) {
if (!getAutoCurvenessParams(seriesModel)) {
return;
}
var key = getKeyOfEdges(n1, n2, seriesModel);
var edgeMap = seriesModel.__edgeMap;
var oppositeEdges = edgeMap[getOppositeKey(key)];
// set direction
if (edgeMap[key] && !oppositeEdges) {
edgeMap[key].isForward = true;
} else if (oppositeEdges && edgeMap[key]) {
oppositeEdges.isForward = true;
edgeMap[key].isForward = false;
}
edgeMap[key] = edgeMap[key] || [];
edgeMap[key].push(index);
}
/**
* get curvature for edge
* @param edge
* @param {module:echarts/model/SeriesModel} seriesModel
* @param index
*/
export function getCurvenessForEdge(edge, seriesModel, index, needReverse) {
var autoCurvenessParams = getAutoCurvenessParams(seriesModel);
var isArrayParam = zrUtil.isArray(autoCurvenessParams);
if (!autoCurvenessParams) {
return null;
}
var edgeArray = getEdgeFromMap(edge, seriesModel);
if (!edgeArray) {
return null;
}
var edgeIndex = -1;
for (var i = 0; i < edgeArray.length; i++) {
if (edgeArray[i] === index) {
edgeIndex = i;
break;
}
}
// if totalLen is Longer createCurveness
var totalLen = getTotalLengthBetweenNodes(edge, seriesModel);
createCurveness(seriesModel, totalLen);
edge.lineStyle = edge.lineStyle || {};
// if is opposite edge, must set curvenss to opposite number
var curKey = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
var curvenessList = seriesModel.__curvenessList;
// if pass array no need parity
var parityCorrection = isArrayParam ? 0 : totalLen % 2 ? 0 : 1;
if (!edgeArray.isForward) {
// the opposite edge show outside
var oppositeKey = getOppositeKey(curKey);
var len = getEdgeMapLengthWithKey(oppositeKey, seriesModel);
var resValue = curvenessList[edgeIndex + len + parityCorrection];
// isNeedReverse, simple, force type need reverse the curveness in the junction of the forword and the opposite
if (needReverse) {
// set as array may make the parity handle with the len of opposite
if (isArrayParam) {
if (autoCurvenessParams && autoCurvenessParams[0] === 0) {
return (len + parityCorrection) % 2 ? resValue : -resValue;
} else {
return ((len % 2 ? 0 : 1) + parityCorrection) % 2 ? resValue : -resValue;
}
} else {
return (len + parityCorrection) % 2 ? resValue : -resValue;
}
} else {
return curvenessList[edgeIndex + len + parityCorrection];
}
} else {
return curvenessList[parityCorrection + edgeIndex];
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { isArray, map } from 'zrender/lib/core/util.js';
import { parsePercent } from 'zrender/lib/contain/text.js';
export function getSectorCornerRadius(model, shape, zeroIfNull) {
var cornerRadius = model.get('borderRadius');
if (cornerRadius == null) {
return zeroIfNull ? {
cornerRadius: 0
} : null;
}
if (!isArray(cornerRadius)) {
cornerRadius = [cornerRadius, cornerRadius, cornerRadius, cornerRadius];
}
var dr = Math.abs(shape.r || 0 - shape.r0 || 0);
return {
cornerRadius: map(cornerRadius, function (cr) {
return parsePercent(cr, dr);
})
};
}

View File

@ -0,0 +1,92 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import * as zrUtil from 'zrender/lib/core/util.js';
export function retrieveTargetInfo(payload, validPayloadTypes, seriesModel) {
if (payload && zrUtil.indexOf(validPayloadTypes, payload.type) >= 0) {
var root = seriesModel.getData().tree.root;
var targetNode = payload.targetNode;
if (zrUtil.isString(targetNode)) {
targetNode = root.getNodeById(targetNode);
}
if (targetNode && root.contains(targetNode)) {
return {
node: targetNode
};
}
var targetNodeId = payload.targetNodeId;
if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
return {
node: targetNode
};
}
}
}
// Not includes the given node at the last item.
export function getPathToRoot(node) {
var path = [];
while (node) {
node = node.parentNode;
node && path.push(node);
}
return path.reverse();
}
export function aboveViewRoot(viewRoot, node) {
var viewPath = getPathToRoot(viewRoot);
return zrUtil.indexOf(viewPath, node) >= 0;
}
// From root to the input node (the input node will be included).
export function wrapTreePathInfo(node, seriesModel) {
var treePathInfo = [];
while (node) {
var nodeDataIndex = node.dataIndex;
treePathInfo.push({
name: node.name,
dataIndex: nodeDataIndex,
value: seriesModel.getRawValue(nodeDataIndex)
});
node = node.parentNode;
}
treePathInfo.reverse();
return treePathInfo;
}

View File

@ -0,0 +1,145 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import createSeriesDataSimply from './createSeriesDataSimply.js';
import * as zrUtil from 'zrender/lib/core/util.js';
import { getDimensionTypeByAxis } from '../../data/helper/dimensionHelper.js';
import { makeSeriesEncodeForAxisCoordSys } from '../../data/helper/sourceHelper.js';
var WhiskerBoxCommonMixin = /** @class */function () {
function WhiskerBoxCommonMixin() {}
/**
* @private
*/
WhiskerBoxCommonMixin.prototype._hasEncodeRule = function (key) {
var encodeRules = this.getEncode();
return encodeRules && encodeRules.get(key) != null;
};
/**
* @override
*/
WhiskerBoxCommonMixin.prototype.getInitialData = function (option, ecModel) {
// When both types of xAxis and yAxis are 'value', layout is
// needed to be specified by user. Otherwise, layout can be
// judged by which axis is category.
var ordinalMeta;
var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
var xAxisType = xAxisModel.get('type');
var yAxisType = yAxisModel.get('type');
var addOrdinal;
// FIXME
// Consider time axis.
if (xAxisType === 'category') {
option.layout = 'horizontal';
ordinalMeta = xAxisModel.getOrdinalMeta();
addOrdinal = !this._hasEncodeRule('x');
} else if (yAxisType === 'category') {
option.layout = 'vertical';
ordinalMeta = yAxisModel.getOrdinalMeta();
addOrdinal = !this._hasEncodeRule('y');
} else {
option.layout = option.layout || 'horizontal';
}
var coordDims = ['x', 'y'];
var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
var otherAxisDim = coordDims[1 - baseAxisDimIndex];
var axisModels = [xAxisModel, yAxisModel];
var baseAxisType = axisModels[baseAxisDimIndex].get('type');
var otherAxisType = axisModels[1 - baseAxisDimIndex].get('type');
var data = option.data;
// Clone a new data for next setOption({}) usage.
// Avoid modifying current data will affect further update.
if (data && addOrdinal) {
var newOptionData_1 = [];
zrUtil.each(data, function (item, index) {
var newItem;
if (zrUtil.isArray(item)) {
newItem = item.slice();
// Modify current using data.
item.unshift(index);
} else if (zrUtil.isArray(item.value)) {
newItem = zrUtil.extend({}, item);
newItem.value = newItem.value.slice();
// Modify current using data.
item.value.unshift(index);
} else {
newItem = item;
}
newOptionData_1.push(newItem);
});
option.data = newOptionData_1;
}
var defaultValueDimensions = this.defaultValueDimensions;
var coordDimensions = [{
name: baseAxisDim,
type: getDimensionTypeByAxis(baseAxisType),
ordinalMeta: ordinalMeta,
otherDims: {
tooltip: false,
itemName: 0
},
dimsDef: ['base']
}, {
name: otherAxisDim,
type: getDimensionTypeByAxis(otherAxisType),
dimsDef: defaultValueDimensions.slice()
}];
return createSeriesDataSimply(this, {
coordDimensions: coordDimensions,
dimensionsCount: defaultValueDimensions.length + 1,
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordDimensions, this)
});
};
/**
* If horizontal, base axis is x, otherwise y.
* @override
*/
WhiskerBoxCommonMixin.prototype.getBaseAxis = function () {
var dim = this._baseAxisDim;
return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
};
return WhiskerBoxCommonMixin;
}();
;
export { WhiskerBoxCommonMixin };

46
frontend/node_modules/echarts/lib/chart/line.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './line/install.js';
use(install);

View File

@ -0,0 +1,152 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import createSeriesData from '../helper/createSeriesData.js';
import SeriesModel from '../../model/Series.js';
import { createSymbol } from '../../util/symbol.js';
import { Group } from '../../util/graphic.js';
var LineSeriesModel = /** @class */function (_super) {
__extends(LineSeriesModel, _super);
function LineSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = LineSeriesModel.type;
_this.hasSymbolVisual = true;
return _this;
}
LineSeriesModel.prototype.getInitialData = function (option) {
if (process.env.NODE_ENV !== 'production') {
var coordSys = option.coordinateSystem;
if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
throw new Error('Line not support coordinateSystem besides cartesian and polar');
}
}
return createSeriesData(null, this, {
useEncodeDefaulter: true
});
};
LineSeriesModel.prototype.getLegendIcon = function (opt) {
var group = new Group();
var line = createSymbol('line', 0, opt.itemHeight / 2, opt.itemWidth, 0, opt.lineStyle.stroke, false);
group.add(line);
line.setStyle(opt.lineStyle);
var visualType = this.getData().getVisual('symbol');
var visualRotate = this.getData().getVisual('symbolRotate');
var symbolType = visualType === 'none' ? 'circle' : visualType;
// Symbol size is 80% when there is a line
var size = opt.itemHeight * 0.8;
var symbol = createSymbol(symbolType, (opt.itemWidth - size) / 2, (opt.itemHeight - size) / 2, size, size, opt.itemStyle.fill);
group.add(symbol);
symbol.setStyle(opt.itemStyle);
var symbolRotate = opt.iconRotate === 'inherit' ? visualRotate : opt.iconRotate || 0;
symbol.rotation = symbolRotate * Math.PI / 180;
symbol.setOrigin([opt.itemWidth / 2, opt.itemHeight / 2]);
if (symbolType.indexOf('empty') > -1) {
symbol.style.stroke = symbol.style.fill;
symbol.style.fill = '#fff';
symbol.style.lineWidth = 2;
}
return group;
};
LineSeriesModel.type = 'series.line';
LineSeriesModel.dependencies = ['grid', 'polar'];
LineSeriesModel.defaultOption = {
// zlevel: 0,
z: 3,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
clip: true,
label: {
position: 'top'
},
// itemStyle: {
// },
endLabel: {
show: false,
valueAnimation: true,
distance: 8
},
lineStyle: {
width: 2,
type: 'solid'
},
emphasis: {
scale: true
},
// areaStyle: {
// origin of areaStyle. Valid values:
// `'auto'/null/undefined`: from axisLine to data
// `'start'`: from min to data
// `'end'`: from data to max
// origin: 'auto'
// },
// false, 'start', 'end', 'middle'
step: false,
// Disabled if step is true
smooth: false,
smoothMonotone: null,
symbol: 'emptyCircle',
symbolSize: 4,
symbolRotate: null,
showSymbol: true,
// `false`: follow the label interval strategy.
// `true`: show all symbols.
// `'auto'`: If possible, show all symbols, otherwise
// follow the label interval strategy.
showAllSymbol: 'auto',
// Whether to connect break point.
connectNulls: false,
// Sampling for large data. Can be: 'average', 'max', 'min', 'sum', 'lttb'.
sampling: 'none',
animationEasing: 'linear',
// Disable progressive
progressive: 0,
hoverLayerThreshold: Infinity,
universalTransition: {
divideShape: 'clone'
},
triggerLineEvent: false
};
return LineSeriesModel;
}(SeriesModel);
export default LineSeriesModel;

1119
frontend/node_modules/echarts/lib/chart/line/LineView.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

122
frontend/node_modules/echarts/lib/chart/line/helper.js generated vendored Normal file
View File

@ -0,0 +1,122 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { isDimensionStacked } from '../../data/helper/dataStackHelper.js';
import { isNumber, map } from 'zrender/lib/core/util.js';
export function prepareDataCoordInfo(coordSys, data, valueOrigin) {
var baseAxis = coordSys.getBaseAxis();
var valueAxis = coordSys.getOtherAxis(baseAxis);
var valueStart = getValueStart(valueAxis, valueOrigin);
var baseAxisDim = baseAxis.dim;
var valueAxisDim = valueAxis.dim;
var valueDim = data.mapDimension(valueAxisDim);
var baseDim = data.mapDimension(baseAxisDim);
var baseDataOffset = valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0;
var dims = map(coordSys.dimensions, function (coordDim) {
return data.mapDimension(coordDim);
});
var stacked = false;
var stackResultDim = data.getCalculationInfo('stackResultDimension');
if (isDimensionStacked(data, dims[0] /* , dims[1] */)) {
// jshint ignore:line
stacked = true;
dims[0] = stackResultDim;
}
if (isDimensionStacked(data, dims[1] /* , dims[0] */)) {
// jshint ignore:line
stacked = true;
dims[1] = stackResultDim;
}
return {
dataDimsForPoint: dims,
valueStart: valueStart,
valueAxisDim: valueAxisDim,
baseAxisDim: baseAxisDim,
stacked: !!stacked,
valueDim: valueDim,
baseDim: baseDim,
baseDataOffset: baseDataOffset,
stackedOverDimension: data.getCalculationInfo('stackedOverDimension')
};
}
function getValueStart(valueAxis, valueOrigin) {
var valueStart = 0;
var extent = valueAxis.scale.getExtent();
if (valueOrigin === 'start') {
valueStart = extent[0];
} else if (valueOrigin === 'end') {
valueStart = extent[1];
}
// If origin is specified as a number, use it as
// valueStart directly
else if (isNumber(valueOrigin) && !isNaN(valueOrigin)) {
valueStart = valueOrigin;
}
// auto
else {
// Both positive
if (extent[0] > 0) {
valueStart = extent[0];
}
// Both negative
else if (extent[1] < 0) {
valueStart = extent[1];
}
// If is one positive, and one negative, onZero shall be true
}
return valueStart;
}
export function getStackedOnPoint(dataCoordInfo, coordSys, data, idx) {
var value = NaN;
if (dataCoordInfo.stacked) {
value = data.get(data.getCalculationInfo('stackedOverDimension'), idx);
}
if (isNaN(value)) {
value = dataCoordInfo.valueStart;
}
var baseDataOffset = dataCoordInfo.baseDataOffset;
var stackedData = [];
stackedData[baseDataOffset] = data.get(dataCoordInfo.baseDim, idx);
stackedData[1 - baseDataOffset] = value;
return coordSys.dataToPoint(stackedData);
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import LineSeries from './LineSeries.js';
import LineView from './LineView.js';
// In case developer forget to include grid component
import layoutPoints from '../../layout/points.js';
import dataSample from '../../processor/dataSample.js';
export function install(registers) {
registers.registerChartView(LineView);
registers.registerSeriesModel(LineSeries);
registers.registerLayout(layoutPoints('line', true));
registers.registerVisual({
seriesType: 'line',
reset: function (seriesModel) {
var data = seriesModel.getData();
// Visual coding for legend
var lineStyle = seriesModel.getModel('lineStyle').getLineStyle();
if (lineStyle && !lineStyle.stroke) {
// Fill in visual should be palette color if
// has color callback
lineStyle.stroke = data.getVisual('style').fill;
}
data.setVisual('legendLineStyle', lineStyle);
}
});
// Down sample after filter
registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, dataSample('line'));
}

View File

@ -0,0 +1,165 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { prepareDataCoordInfo, getStackedOnPoint } from './helper.js';
import { createFloat32Array } from '../../util/vendor.js';
function diffData(oldData, newData) {
var diffResult = [];
newData.diff(oldData).add(function (idx) {
diffResult.push({
cmd: '+',
idx: idx
});
}).update(function (newIdx, oldIdx) {
diffResult.push({
cmd: '=',
idx: oldIdx,
idx1: newIdx
});
}).remove(function (idx) {
diffResult.push({
cmd: '-',
idx: idx
});
}).execute();
return diffResult;
}
export default function lineAnimationDiff(oldData, newData, oldStackedOnPoints, newStackedOnPoints, oldCoordSys, newCoordSys, oldValueOrigin, newValueOrigin) {
var diff = diffData(oldData, newData);
// let newIdList = newData.mapArray(newData.getId);
// let oldIdList = oldData.mapArray(oldData.getId);
// convertToIntId(newIdList, oldIdList);
// // FIXME One data ?
// diff = arrayDiff(oldIdList, newIdList);
var currPoints = [];
var nextPoints = [];
// Points for stacking base line
var currStackedPoints = [];
var nextStackedPoints = [];
var status = [];
var sortedIndices = [];
var rawIndices = [];
var newDataOldCoordInfo = prepareDataCoordInfo(oldCoordSys, newData, oldValueOrigin);
// const oldDataNewCoordInfo = prepareDataCoordInfo(newCoordSys, oldData, newValueOrigin);
var oldPoints = oldData.getLayout('points') || [];
var newPoints = newData.getLayout('points') || [];
for (var i = 0; i < diff.length; i++) {
var diffItem = diff[i];
var pointAdded = true;
var oldIdx2 = void 0;
var newIdx2 = void 0;
// FIXME, animation is not so perfect when dataZoom window moves fast
// Which is in case remvoing or add more than one data in the tail or head
switch (diffItem.cmd) {
case '=':
oldIdx2 = diffItem.idx * 2;
newIdx2 = diffItem.idx1 * 2;
var currentX = oldPoints[oldIdx2];
var currentY = oldPoints[oldIdx2 + 1];
var nextX = newPoints[newIdx2];
var nextY = newPoints[newIdx2 + 1];
// If previous data is NaN, use next point directly
if (isNaN(currentX) || isNaN(currentY)) {
currentX = nextX;
currentY = nextY;
}
currPoints.push(currentX, currentY);
nextPoints.push(nextX, nextY);
currStackedPoints.push(oldStackedOnPoints[oldIdx2], oldStackedOnPoints[oldIdx2 + 1]);
nextStackedPoints.push(newStackedOnPoints[newIdx2], newStackedOnPoints[newIdx2 + 1]);
rawIndices.push(newData.getRawIndex(diffItem.idx1));
break;
case '+':
var newIdx = diffItem.idx;
var newDataDimsForPoint = newDataOldCoordInfo.dataDimsForPoint;
var oldPt = oldCoordSys.dataToPoint([newData.get(newDataDimsForPoint[0], newIdx), newData.get(newDataDimsForPoint[1], newIdx)]);
newIdx2 = newIdx * 2;
currPoints.push(oldPt[0], oldPt[1]);
nextPoints.push(newPoints[newIdx2], newPoints[newIdx2 + 1]);
var stackedOnPoint = getStackedOnPoint(newDataOldCoordInfo, oldCoordSys, newData, newIdx);
currStackedPoints.push(stackedOnPoint[0], stackedOnPoint[1]);
nextStackedPoints.push(newStackedOnPoints[newIdx2], newStackedOnPoints[newIdx2 + 1]);
rawIndices.push(newData.getRawIndex(newIdx));
break;
case '-':
pointAdded = false;
}
// Original indices
if (pointAdded) {
status.push(diffItem);
sortedIndices.push(sortedIndices.length);
}
}
// Diff result may be crossed if all items are changed
// Sort by data index
sortedIndices.sort(function (a, b) {
return rawIndices[a] - rawIndices[b];
});
var len = currPoints.length;
var sortedCurrPoints = createFloat32Array(len);
var sortedNextPoints = createFloat32Array(len);
var sortedCurrStackedPoints = createFloat32Array(len);
var sortedNextStackedPoints = createFloat32Array(len);
var sortedStatus = [];
for (var i = 0; i < sortedIndices.length; i++) {
var idx = sortedIndices[i];
var i2 = i * 2;
var idx2 = idx * 2;
sortedCurrPoints[i2] = currPoints[idx2];
sortedCurrPoints[i2 + 1] = currPoints[idx2 + 1];
sortedNextPoints[i2] = nextPoints[idx2];
sortedNextPoints[i2 + 1] = nextPoints[idx2 + 1];
sortedCurrStackedPoints[i2] = currStackedPoints[idx2];
sortedCurrStackedPoints[i2 + 1] = currStackedPoints[idx2 + 1];
sortedNextStackedPoints[i2] = nextStackedPoints[idx2];
sortedNextStackedPoints[i2 + 1] = nextStackedPoints[idx2 + 1];
sortedStatus[i] = status[idx];
}
return {
current: sortedCurrPoints,
next: sortedNextPoints,
stackedOnCurrent: sortedCurrStackedPoints,
stackedOnNext: sortedNextStackedPoints,
status: sortedStatus
};
}

353
frontend/node_modules/echarts/lib/chart/line/poly.js generated vendored Normal file
View File

@ -0,0 +1,353 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
// Poly path support NaN point
import Path from 'zrender/lib/graphic/Path.js';
import PathProxy from 'zrender/lib/core/PathProxy.js';
import { cubicRootAt, cubicAt } from 'zrender/lib/core/curve.js';
var mathMin = Math.min;
var mathMax = Math.max;
function isPointNull(x, y) {
return isNaN(x) || isNaN(y);
}
/**
* Draw smoothed line in non-monotone, in may cause undesired curve in extreme
* situations. This should be used when points are non-monotone neither in x or
* y dimension.
*/
function drawSegment(ctx, points, start, segLen, allLen, dir, smooth, smoothMonotone, connectNulls) {
var prevX;
var prevY;
var cpx0;
var cpy0;
var cpx1;
var cpy1;
var idx = start;
var k = 0;
for (; k < segLen; k++) {
var x = points[idx * 2];
var y = points[idx * 2 + 1];
if (idx >= allLen || idx < 0) {
break;
}
if (isPointNull(x, y)) {
if (connectNulls) {
idx += dir;
continue;
}
break;
}
if (idx === start) {
ctx[dir > 0 ? 'moveTo' : 'lineTo'](x, y);
cpx0 = x;
cpy0 = y;
} else {
var dx = x - prevX;
var dy = y - prevY;
// Ignore tiny segment.
if (dx * dx + dy * dy < 0.5) {
idx += dir;
continue;
}
if (smooth > 0) {
var nextIdx = idx + dir;
var nextX = points[nextIdx * 2];
var nextY = points[nextIdx * 2 + 1];
// Ignore duplicate point
while (nextX === x && nextY === y && k < segLen) {
k++;
nextIdx += dir;
idx += dir;
nextX = points[nextIdx * 2];
nextY = points[nextIdx * 2 + 1];
x = points[idx * 2];
y = points[idx * 2 + 1];
dx = x - prevX;
dy = y - prevY;
}
var tmpK = k + 1;
if (connectNulls) {
// Find next point not null
while (isPointNull(nextX, nextY) && tmpK < segLen) {
tmpK++;
nextIdx += dir;
nextX = points[nextIdx * 2];
nextY = points[nextIdx * 2 + 1];
}
}
var ratioNextSeg = 0.5;
var vx = 0;
var vy = 0;
var nextCpx0 = void 0;
var nextCpy0 = void 0;
// Is last point
if (tmpK >= segLen || isPointNull(nextX, nextY)) {
cpx1 = x;
cpy1 = y;
} else {
vx = nextX - prevX;
vy = nextY - prevY;
var dx0 = x - prevX;
var dx1 = nextX - x;
var dy0 = y - prevY;
var dy1 = nextY - y;
var lenPrevSeg = void 0;
var lenNextSeg = void 0;
if (smoothMonotone === 'x') {
lenPrevSeg = Math.abs(dx0);
lenNextSeg = Math.abs(dx1);
var dir_1 = vx > 0 ? 1 : -1;
cpx1 = x - dir_1 * lenPrevSeg * smooth;
cpy1 = y;
nextCpx0 = x + dir_1 * lenNextSeg * smooth;
nextCpy0 = y;
} else if (smoothMonotone === 'y') {
lenPrevSeg = Math.abs(dy0);
lenNextSeg = Math.abs(dy1);
var dir_2 = vy > 0 ? 1 : -1;
cpx1 = x;
cpy1 = y - dir_2 * lenPrevSeg * smooth;
nextCpx0 = x;
nextCpy0 = y + dir_2 * lenNextSeg * smooth;
} else {
lenPrevSeg = Math.sqrt(dx0 * dx0 + dy0 * dy0);
lenNextSeg = Math.sqrt(dx1 * dx1 + dy1 * dy1);
// Use ratio of seg length
ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
cpx1 = x - vx * smooth * (1 - ratioNextSeg);
cpy1 = y - vy * smooth * (1 - ratioNextSeg);
// cp0 of next segment
nextCpx0 = x + vx * smooth * ratioNextSeg;
nextCpy0 = y + vy * smooth * ratioNextSeg;
// Smooth constraint between point and next point.
// Avoid exceeding extreme after smoothing.
nextCpx0 = mathMin(nextCpx0, mathMax(nextX, x));
nextCpy0 = mathMin(nextCpy0, mathMax(nextY, y));
nextCpx0 = mathMax(nextCpx0, mathMin(nextX, x));
nextCpy0 = mathMax(nextCpy0, mathMin(nextY, y));
// Reclaculate cp1 based on the adjusted cp0 of next seg.
vx = nextCpx0 - x;
vy = nextCpy0 - y;
cpx1 = x - vx * lenPrevSeg / lenNextSeg;
cpy1 = y - vy * lenPrevSeg / lenNextSeg;
// Smooth constraint between point and prev point.
// Avoid exceeding extreme after smoothing.
cpx1 = mathMin(cpx1, mathMax(prevX, x));
cpy1 = mathMin(cpy1, mathMax(prevY, y));
cpx1 = mathMax(cpx1, mathMin(prevX, x));
cpy1 = mathMax(cpy1, mathMin(prevY, y));
// Adjust next cp0 again.
vx = x - cpx1;
vy = y - cpy1;
nextCpx0 = x + vx * lenNextSeg / lenPrevSeg;
nextCpy0 = y + vy * lenNextSeg / lenPrevSeg;
}
}
ctx.bezierCurveTo(cpx0, cpy0, cpx1, cpy1, x, y);
cpx0 = nextCpx0;
cpy0 = nextCpy0;
} else {
ctx.lineTo(x, y);
}
}
prevX = x;
prevY = y;
idx += dir;
}
return k;
}
var ECPolylineShape = /** @class */function () {
function ECPolylineShape() {
this.smooth = 0;
this.smoothConstraint = true;
}
return ECPolylineShape;
}();
var ECPolyline = /** @class */function (_super) {
__extends(ECPolyline, _super);
function ECPolyline(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'ec-polyline';
return _this;
}
ECPolyline.prototype.getDefaultStyle = function () {
return {
stroke: '#000',
fill: null
};
};
ECPolyline.prototype.getDefaultShape = function () {
return new ECPolylineShape();
};
ECPolyline.prototype.buildPath = function (ctx, shape) {
var points = shape.points;
var i = 0;
var len = points.length / 2;
// const result = getBoundingBox(points, shape.smoothConstraint);
if (shape.connectNulls) {
// Must remove first and last null values avoid draw error in polygon
for (; len > 0; len--) {
if (!isPointNull(points[len * 2 - 2], points[len * 2 - 1])) {
break;
}
}
for (; i < len; i++) {
if (!isPointNull(points[i * 2], points[i * 2 + 1])) {
break;
}
}
}
while (i < len) {
i += drawSegment(ctx, points, i, len, len, 1, shape.smooth, shape.smoothMonotone, shape.connectNulls) + 1;
}
};
ECPolyline.prototype.getPointOn = function (xOrY, dim) {
if (!this.path) {
this.createPathProxy();
this.buildPath(this.path, this.shape);
}
var path = this.path;
var data = path.data;
var CMD = PathProxy.CMD;
var x0;
var y0;
var isDimX = dim === 'x';
var roots = [];
for (var i = 0; i < data.length;) {
var cmd = data[i++];
var x = void 0;
var y = void 0;
var x2 = void 0;
var y2 = void 0;
var x3 = void 0;
var y3 = void 0;
var t = void 0;
switch (cmd) {
case CMD.M:
x0 = data[i++];
y0 = data[i++];
break;
case CMD.L:
x = data[i++];
y = data[i++];
t = isDimX ? (xOrY - x0) / (x - x0) : (xOrY - y0) / (y - y0);
if (t <= 1 && t >= 0) {
var val = isDimX ? (y - y0) * t + y0 : (x - x0) * t + x0;
return isDimX ? [xOrY, val] : [val, xOrY];
}
x0 = x;
y0 = y;
break;
case CMD.C:
x = data[i++];
y = data[i++];
x2 = data[i++];
y2 = data[i++];
x3 = data[i++];
y3 = data[i++];
var nRoot = isDimX ? cubicRootAt(x0, x, x2, x3, xOrY, roots) : cubicRootAt(y0, y, y2, y3, xOrY, roots);
if (nRoot > 0) {
for (var i_1 = 0; i_1 < nRoot; i_1++) {
var t_1 = roots[i_1];
if (t_1 <= 1 && t_1 >= 0) {
var val = isDimX ? cubicAt(y0, y, y2, y3, t_1) : cubicAt(x0, x, x2, x3, t_1);
return isDimX ? [xOrY, val] : [val, xOrY];
}
}
}
x0 = x3;
y0 = y3;
break;
}
}
};
return ECPolyline;
}(Path);
export { ECPolyline };
var ECPolygonShape = /** @class */function (_super) {
__extends(ECPolygonShape, _super);
function ECPolygonShape() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ECPolygonShape;
}(ECPolylineShape);
var ECPolygon = /** @class */function (_super) {
__extends(ECPolygon, _super);
function ECPolygon(opts) {
var _this = _super.call(this, opts) || this;
_this.type = 'ec-polygon';
return _this;
}
ECPolygon.prototype.getDefaultShape = function () {
return new ECPolygonShape();
};
ECPolygon.prototype.buildPath = function (ctx, shape) {
var points = shape.points;
var stackedOnPoints = shape.stackedOnPoints;
var i = 0;
var len = points.length / 2;
var smoothMonotone = shape.smoothMonotone;
if (shape.connectNulls) {
// Must remove first and last null values avoid draw error in polygon
for (; len > 0; len--) {
if (!isPointNull(points[len * 2 - 2], points[len * 2 - 1])) {
break;
}
}
for (; i < len; i++) {
if (!isPointNull(points[i * 2], points[i * 2 + 1])) {
break;
}
}
}
while (i < len) {
var k = drawSegment(ctx, points, i, len, len, 1, shape.smooth, smoothMonotone, shape.connectNulls);
drawSegment(ctx, stackedOnPoints, i + k - 1, k, len, -1, shape.stackedOnSmooth, smoothMonotone, shape.connectNulls);
i += k + 1;
ctx.closePath();
}
};
return ECPolygon;
}(Path);
export { ECPolygon };

46
frontend/node_modules/echarts/lib/chart/lines.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { use } from '../extension.js';
import { install } from './lines/install.js';
use(install);

View File

@ -0,0 +1,309 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
/* global Uint32Array, Float64Array, Float32Array */
import SeriesModel from '../../model/Series.js';
import SeriesData from '../../data/SeriesData.js';
import { concatArray, mergeAll, map, isNumber } from 'zrender/lib/core/util.js';
import CoordinateSystem from '../../core/CoordinateSystem.js';
import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup.js';
var Uint32Arr = typeof Uint32Array === 'undefined' ? Array : Uint32Array;
var Float64Arr = typeof Float64Array === 'undefined' ? Array : Float64Array;
function compatEc2(seriesOpt) {
var data = seriesOpt.data;
if (data && data[0] && data[0][0] && data[0][0].coord) {
if (process.env.NODE_ENV !== 'production') {
console.warn('Lines data configuration has been changed to' + ' { coords:[[1,2],[2,3]] }');
}
seriesOpt.data = map(data, function (itemOpt) {
var coords = [itemOpt[0].coord, itemOpt[1].coord];
var target = {
coords: coords
};
if (itemOpt[0].name) {
target.fromName = itemOpt[0].name;
}
if (itemOpt[1].name) {
target.toName = itemOpt[1].name;
}
return mergeAll([target, itemOpt[0], itemOpt[1]]);
});
}
}
var LinesSeriesModel = /** @class */function (_super) {
__extends(LinesSeriesModel, _super);
function LinesSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = LinesSeriesModel.type;
_this.visualStyleAccessPath = 'lineStyle';
_this.visualDrawType = 'stroke';
return _this;
}
LinesSeriesModel.prototype.init = function (option) {
// The input data may be null/undefined.
option.data = option.data || [];
// Not using preprocessor because mergeOption may not have series.type
compatEc2(option);
var result = this._processFlatCoordsArray(option.data);
this._flatCoords = result.flatCoords;
this._flatCoordsOffset = result.flatCoordsOffset;
if (result.flatCoords) {
option.data = new Float32Array(result.count);
}
_super.prototype.init.apply(this, arguments);
};
LinesSeriesModel.prototype.mergeOption = function (option) {
compatEc2(option);
if (option.data) {
// Only update when have option data to merge.
var result = this._processFlatCoordsArray(option.data);
this._flatCoords = result.flatCoords;
this._flatCoordsOffset = result.flatCoordsOffset;
if (result.flatCoords) {
option.data = new Float32Array(result.count);
}
}
_super.prototype.mergeOption.apply(this, arguments);
};
LinesSeriesModel.prototype.appendData = function (params) {
var result = this._processFlatCoordsArray(params.data);
if (result.flatCoords) {
if (!this._flatCoords) {
this._flatCoords = result.flatCoords;
this._flatCoordsOffset = result.flatCoordsOffset;
} else {
this._flatCoords = concatArray(this._flatCoords, result.flatCoords);
this._flatCoordsOffset = concatArray(this._flatCoordsOffset, result.flatCoordsOffset);
}
params.data = new Float32Array(result.count);
}
this.getRawData().appendData(params.data);
};
LinesSeriesModel.prototype._getCoordsFromItemModel = function (idx) {
var itemModel = this.getData().getItemModel(idx);
var coords = itemModel.option instanceof Array ? itemModel.option : itemModel.getShallow('coords');
if (process.env.NODE_ENV !== 'production') {
if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
}
}
return coords;
};
LinesSeriesModel.prototype.getLineCoordsCount = function (idx) {
if (this._flatCoordsOffset) {
return this._flatCoordsOffset[idx * 2 + 1];
} else {
return this._getCoordsFromItemModel(idx).length;
}
};
LinesSeriesModel.prototype.getLineCoords = function (idx, out) {
if (this._flatCoordsOffset) {
var offset = this._flatCoordsOffset[idx * 2];
var len = this._flatCoordsOffset[idx * 2 + 1];
for (var i = 0; i < len; i++) {
out[i] = out[i] || [];
out[i][0] = this._flatCoords[offset + i * 2];
out[i][1] = this._flatCoords[offset + i * 2 + 1];
}
return len;
} else {
var coords = this._getCoordsFromItemModel(idx);
for (var i = 0; i < coords.length; i++) {
out[i] = out[i] || [];
out[i][0] = coords[i][0];
out[i][1] = coords[i][1];
}
return coords.length;
}
};
LinesSeriesModel.prototype._processFlatCoordsArray = function (data) {
var startOffset = 0;
if (this._flatCoords) {
startOffset = this._flatCoords.length;
}
// Stored as a typed array. In format
// Points Count(2) | x | y | x | y | Points Count(3) | x | y | x | y | x | y |
if (isNumber(data[0])) {
var len = data.length;
// Store offset and len of each segment
var coordsOffsetAndLenStorage = new Uint32Arr(len);
var coordsStorage = new Float64Arr(len);
var coordsCursor = 0;
var offsetCursor = 0;
var dataCount = 0;
for (var i = 0; i < len;) {
dataCount++;
var count = data[i++];
// Offset
coordsOffsetAndLenStorage[offsetCursor++] = coordsCursor + startOffset;
// Len
coordsOffsetAndLenStorage[offsetCursor++] = count;
for (var k = 0; k < count; k++) {
var x = data[i++];
var y = data[i++];
coordsStorage[coordsCursor++] = x;
coordsStorage[coordsCursor++] = y;
if (i > len) {
if (process.env.NODE_ENV !== 'production') {
throw new Error('Invalid data format.');
}
}
}
}
return {
flatCoordsOffset: new Uint32Array(coordsOffsetAndLenStorage.buffer, 0, offsetCursor),
flatCoords: coordsStorage,
count: dataCount
};
}
return {
flatCoordsOffset: null,
flatCoords: null,
count: data.length
};
};
LinesSeriesModel.prototype.getInitialData = function (option, ecModel) {
if (process.env.NODE_ENV !== 'production') {
var CoordSys = CoordinateSystem.get(option.coordinateSystem);
if (!CoordSys) {
throw new Error('Unknown coordinate system ' + option.coordinateSystem);
}
}
var lineData = new SeriesData(['value'], this);
lineData.hasItemOption = false;
lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
// dataItem is simply coords
if (dataItem instanceof Array) {
return NaN;
} else {
lineData.hasItemOption = true;
var value = dataItem.value;
if (value != null) {
return value instanceof Array ? value[dimIndex] : value;
}
}
});
return lineData;
};
LinesSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
var data = this.getData();
var itemModel = data.getItemModel(dataIndex);
var name = itemModel.get('name');
if (name) {
return name;
}
var fromName = itemModel.get('fromName');
var toName = itemModel.get('toName');
var nameArr = [];
fromName != null && nameArr.push(fromName);
toName != null && nameArr.push(toName);
return createTooltipMarkup('nameValue', {
name: nameArr.join(' > ')
});
};
LinesSeriesModel.prototype.preventIncremental = function () {
return !!this.get(['effect', 'show']);
};
LinesSeriesModel.prototype.getProgressive = function () {
var progressive = this.option.progressive;
if (progressive == null) {
return this.option.large ? 1e4 : this.get('progressive');
}
return progressive;
};
LinesSeriesModel.prototype.getProgressiveThreshold = function () {
var progressiveThreshold = this.option.progressiveThreshold;
if (progressiveThreshold == null) {
return this.option.large ? 2e4 : this.get('progressiveThreshold');
}
return progressiveThreshold;
};
LinesSeriesModel.prototype.getZLevelKey = function () {
var effectModel = this.getModel('effect');
var trailLength = effectModel.get('trailLength');
return this.getData().count() > this.getProgressiveThreshold()
// Each progressive series has individual key.
? this.id : effectModel.get('show') && trailLength > 0 ? trailLength + '' : '';
};
LinesSeriesModel.type = 'series.lines';
LinesSeriesModel.dependencies = ['grid', 'polar', 'geo', 'calendar'];
LinesSeriesModel.defaultOption = {
coordinateSystem: 'geo',
// zlevel: 0,
z: 2,
legendHoverLink: true,
// Cartesian coordinate system
xAxisIndex: 0,
yAxisIndex: 0,
symbol: ['none', 'none'],
symbolSize: [10, 10],
// Geo coordinate system
geoIndex: 0,
effect: {
show: false,
period: 4,
constantSpeed: 0,
symbol: 'circle',
symbolSize: 3,
loop: true,
trailLength: 0.2
},
large: false,
// Available when large is true
largeThreshold: 2000,
polyline: false,
clip: true,
label: {
show: false,
position: 'end'
// distance: 5,
// formatter: 标签文本格式器同Tooltip.formatter不支持异步回调
},
lineStyle: {
opacity: 0.5
}
};
return LinesSeriesModel;
}(SeriesModel);
export default LinesSeriesModel;

View File

@ -0,0 +1,184 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import { __extends } from "tslib";
import LineDraw from '../helper/LineDraw.js';
import EffectLine from '../helper/EffectLine.js';
import Line from '../helper/Line.js';
import Polyline from '../helper/Polyline.js';
import EffectPolyline from '../helper/EffectPolyline.js';
import LargeLineDraw from '../helper/LargeLineDraw.js';
import linesLayout from './linesLayout.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import ChartView from '../../view/Chart.js';
var LinesView = /** @class */function (_super) {
__extends(LinesView, _super);
function LinesView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = LinesView.type;
return _this;
}
LinesView.prototype.render = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var lineDraw = this._updateLineDraw(data, seriesModel);
var zlevel = seriesModel.get('zlevel');
var trailLength = seriesModel.get(['effect', 'trailLength']);
var zr = api.getZr();
// Avoid the drag cause ghost shadow
// FIXME Better way ?
// SVG doesn't support
var isSvg = zr.painter.getType() === 'svg';
if (!isSvg) {
zr.painter.getLayer(zlevel).clear(true);
}
// Config layer with motion blur
if (this._lastZlevel != null && !isSvg) {
zr.configLayer(this._lastZlevel, {
motionBlur: false
});
}
if (this._showEffect(seriesModel) && trailLength > 0) {
if (!isSvg) {
zr.configLayer(zlevel, {
motionBlur: true,
lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
});
} else if (process.env.NODE_ENV !== 'production') {
console.warn('SVG render mode doesn\'t support lines with trail effect');
}
}
lineDraw.updateData(data);
var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
if (clipPath) {
this.group.setClipPath(clipPath);
} else {
this.group.removeClipPath();
}
this._lastZlevel = zlevel;
this._finished = true;
};
LinesView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var lineDraw = this._updateLineDraw(data, seriesModel);
lineDraw.incrementalPrepareUpdate(data);
this._clearLayer(api);
this._finished = false;
};
LinesView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
this._lineDraw.incrementalUpdate(taskParams, seriesModel.getData());
this._finished = taskParams.end === seriesModel.getData().count();
};
LinesView.prototype.eachRendered = function (cb) {
this._lineDraw && this._lineDraw.eachRendered(cb);
};
LinesView.prototype.updateTransform = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var pipelineContext = seriesModel.pipelineContext;
if (!this._finished || pipelineContext.large || pipelineContext.progressiveRender) {
// TODO Don't have to do update in large mode. Only do it when there are millions of data.
return {
update: true
};
} else {
// TODO Use same logic with ScatterView.
// Manually update layout
var res = linesLayout.reset(seriesModel, ecModel, api);
if (res.progress) {
res.progress({
start: 0,
end: data.count(),
count: data.count()
}, data);
}
// Not in large mode
this._lineDraw.updateLayout();
this._clearLayer(api);
}
};
LinesView.prototype._updateLineDraw = function (data, seriesModel) {
var lineDraw = this._lineDraw;
var hasEffect = this._showEffect(seriesModel);
var isPolyline = !!seriesModel.get('polyline');
var pipelineContext = seriesModel.pipelineContext;
var isLargeDraw = pipelineContext.large;
if (process.env.NODE_ENV !== 'production') {
if (hasEffect && isLargeDraw) {
console.warn('Large lines not support effect');
}
}
if (!lineDraw || hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLargeDraw !== this._isLargeDraw) {
if (lineDraw) {
lineDraw.remove();
}
lineDraw = this._lineDraw = isLargeDraw ? new LargeLineDraw() : new LineDraw(isPolyline ? hasEffect ? EffectPolyline : Polyline : hasEffect ? EffectLine : Line);
this._hasEffet = hasEffect;
this._isPolyline = isPolyline;
this._isLargeDraw = isLargeDraw;
}
this.group.add(lineDraw.group);
return lineDraw;
};
LinesView.prototype._showEffect = function (seriesModel) {
return !!seriesModel.get(['effect', 'show']);
};
LinesView.prototype._clearLayer = function (api) {
// Not use motion when dragging or zooming
var zr = api.getZr();
var isSvg = zr.painter.getType() === 'svg';
if (!isSvg && this._lastZlevel != null) {
zr.painter.getLayer(this._lastZlevel).clear(true);
}
};
LinesView.prototype.remove = function (ecModel, api) {
this._lineDraw && this._lineDraw.remove();
this._lineDraw = null;
// Clear motion when lineDraw is removed
this._clearLayer(api);
};
LinesView.prototype.dispose = function (ecModel, api) {
this.remove(ecModel, api);
};
LinesView.type = 'lines';
return LinesView;
}(ChartView);
export default LinesView;

View File

@ -0,0 +1,53 @@
/*
* 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.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* 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.
*/
import LinesView from './LinesView.js';
import LinesSeriesModel from './LinesSeries.js';
import linesLayout from './linesLayout.js';
import linesVisual from './linesVisual.js';
export function install(registers) {
registers.registerChartView(LinesView);
registers.registerSeriesModel(LinesSeriesModel);
registers.registerLayout(linesLayout);
registers.registerVisual(linesVisual);
}

Some files were not shown because too many files have changed in this diff Show More