Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0][FEATURE] Label enhancement and state transition #12911

Merged
merged 90 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5809720
feat: add label manager for each series to layout label.
pissang Apr 22, 2020
2b8da72
feat: improve label layouting. displayed by priority(default to be si…
pissang Apr 23, 2020
8c467f2
Merge branch 'next' into label-enhancement
pissang Apr 24, 2020
9718d12
fix(label): respect the original ignore value when handling overlap
pissang Apr 24, 2020
db8297b
feat(label): ignore style.x/y when x/y is given in labelLayout
pissang Apr 24, 2020
6f9f5af
Merge branch 'next' into label-enhancement
pissang Apr 27, 2020
7df0126
Merge branch 'next' into label-enhancement
pissang Apr 27, 2020
447c0a6
fix(progressive): fix task may not been executed in progressive rende…
pissang Apr 30, 2020
7e84356
fix: avoid unexpected treeshaking.
pissang Apr 30, 2020
5239e3c
feat: using state for all user interactions.
pissang Apr 30, 2020
75a69b1
fix(pie): fix pie hover state
pissang Apr 30, 2020
b631038
fix(label): fix emphasis position.
pissang Apr 30, 2020
8bf2072
enhance(pie): improve pie animation. #12553
pissang May 3, 2020
c30f137
feat: add auto calculated label guide line.
pissang May 7, 2020
e201982
fix(state): fix some state issues on pie.
pissang May 14, 2020
17eb9c0
feat(state): add stateAnimation in all series. use state in sunburst.
pissang May 15, 2020
4ae89c2
enhance(state): clearStates and restoreState in the renderSeries over…
pissang May 17, 2020
c94b745
fix: fix rotation origin in graph and tree. fix itemStyle in and leve…
pissang May 18, 2020
0d467b1
fix: fix textContent z on hover.
pissang May 18, 2020
e4c1308
fix: still compat barBorderRadius, barBorderColor
pissang May 18, 2020
6b86fff
fix: use highlighted and selected flag to determine if apply state.
pissang May 19, 2020
0bb61d0
fix: exclude default stroke when intersecting labels.
pissang May 19, 2020
601259d
fix: fix hover scale in graph and tree
pissang May 26, 2020
ea1978b
fix: use fill instead of textFIll for text
pissang May 26, 2020
72c10a2
Merge branch 'next' into label-enhancement
pissang May 26, 2020
bce7435
fix(bar): compat barBorderWidth
pissang May 27, 2020
7f53a78
Merge branch 'next' into label-enhancement
pissang May 27, 2020
bda15a2
Merge branch 'next' into label-enhancement
pissang May 27, 2020
6fa462f
fix: compat barBorderXXX in backgroundStyle. rename barBorderRadius t…
pissang May 27, 2020
34e4cb0
feat: label and labelLine animation
pissang May 28, 2020
906e363
fix: compat barBorderXXX in backgroundStyle
pissang May 28, 2020
678b42d
fix: fix class error in ES6 built file
pissang May 28, 2020
fba40c7
fix: fix not existed emphasis state caused error.
pissang May 28, 2020
c11498d
refact: layout label after render in pie.
pissang May 28, 2020
4062b9f
feat: support state transition in geo component
pissang May 29, 2020
5accd25
feat(pie): improve the shape of label layout
pissang Jun 1, 2020
d8b1f1c
feat: add minTurnAngle in labelLine
pissang Jun 2, 2020
86d6c25
feat: ignore labelLayout if it's not specified in option
pissang Jun 2, 2020
fead688
feat(label): support overlap configuration in labelLayout
pissang Jun 2, 2020
dae5a2b
feat: add labelLine for all series
pissang Jun 3, 2020
c344d13
feat: add draggable in labelLayout
pissang Jun 3, 2020
6f57d74
fix(label): fix logic issues in setLabelLineStyle
pissang Jun 4, 2020
65f4fc4
feat: change label overlap configuration for supporting overlap layout
pissang Jun 4, 2020
ca57e80
feat(label: add shift-x, shift-y option for moveOverlap in labelLayout
pissang Jun 5, 2020
0089d9b
feat(label): optimize label auto layout when aligned horizontally or …
pissang Jun 7, 2020
1c7a130
feat(label): rewrite the label shift algorithm in layout
pissang Jun 7, 2020
a7310d8
feat(label): squeeze the labels then hide if there is no space.
pissang Jun 8, 2020
73f0a6b
fix(type): prefer rotate over rotation in label configuration
pissang Jun 8, 2020
eb94696
fix(state): fix emphasis toggle too frequently caused color lift accu…
pissang Jun 8, 2020
3a80a47
fix(toolbox): fix icon emphasis status not keep when selected.
pissang Jun 9, 2020
3f46e8a
fix(state): fix wrong emphasis lift color when animation is enabled
pissang Jun 9, 2020
a2645c1
fix(state): forget to remove saved states in clearStates.
pissang Jun 9, 2020
9919c52
fix(state): use flag to determine which states to restore instead of …
pissang Jun 9, 2020
dd37d60
fix(state): fix last commit, still needs save, clear and restore stat…
pissang Jun 9, 2020
e8605d0
fix(label): fix label animation with selected states.
pissang Jun 9, 2020
1dc916d
ts: update roamHelper
pissang Jun 10, 2020
9185991
fix(sunburst): fix sunburst animation
pissang Jun 10, 2020
fdcc88d
fix(treemap): fix treemap label displayed text
pissang Jun 10, 2020
678a33b
fix(visualMap): fix error when target series not exists.
pissang Jun 10, 2020
f3ed3fa
feat(label): use the new layout algorithm in pie
pissang Jun 20, 2020
27f2044
fix(label): fix wrong squeeze logic in label layout
pissang Jun 21, 2020
f1dd46d
enhance(labelLine): optimize smooth in labelLine
pissang Jun 22, 2020
306779e
fix(labelLine): only set smooth when it's changed.
pissang Jun 22, 2020
804a99c
feat(pie): support overflow wrap
pissang Jun 22, 2020
7db0a9c
feat(label): enable darkMode
pissang Jun 22, 2020
f40e0dd
feat(label): change label default color to black/white, 'inherit' to …
pissang Jun 22, 2020
27c3cce
fix(labelLine): fix error when labelLine don't have points
pissang Jun 22, 2020
83df54f
fix(label): label color is dark by default in pie and sunburst.
pissang Jun 23, 2020
58dc3f7
Merge branch 'next' into label-enhancement
pissang Jun 23, 2020
895cc00
change(bar): change to fade out animation when series is removed. #12543
pissang Jun 23, 2020
f6c5bef
fix(label): recalculate labelLine if label position is changed by use…
pissang Jun 23, 2020
97e15ec
fix(animation): force stop remove animation before init again.
pissang Jun 24, 2020
abdb831
fix(line): optimize area animation
pissang Jun 24, 2020
2e2a76e
refact(graph): use blur state instead of change opacity by manual
pissang Jun 24, 2020
52c0f4d
refact(sankey): use blur state.
pissang Jun 24, 2020
195ba7d
fix(label): fix interpolate value affect the original value.
pissang Jul 2, 2020
b26b5d5
feat(label): can change labelLine points in labelLayout
pissang Jul 2, 2020
6256346
fix(label): optimize layout on pie.
pissang Jul 2, 2020
e629132
fix(label): labelLine has same z, zlevel with element
pissang Jul 3, 2020
bf6c144
refact(label): add minMargin for layouting. the original margin is re…
pissang Jul 3, 2020
c003487
feat(label): add maxSurfaceAngle limit in pie
pissang Jul 3, 2020
cac1f9b
ts: fix types
pissang Jul 4, 2020
4ec8de7
fix(dataZoom): fix position not update after resized
pissang Jul 4, 2020
9df0be9
fix(state): fix state transition may not being applied bug.
pissang Jul 4, 2020
1cfa45d
fix(state): fix z2 lift on emphasis
pissang Jul 4, 2020
800ba5b
Merge branch 'next' into label-enhancement
pissang Jul 4, 2020
e43a58c
fix(pie): fix error when there is no data.
pissang Jul 5, 2020
e63a8fe
fix(label): fix map label layout.
pissang Jul 5, 2020
d00e836
test: fix cases
pissang Jul 5, 2020
79c644d
feat(animation): use cubicInOut easing by default
pissang Jul 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions src/ExtensionAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,33 @@ import {CoordinateSystemMaster} from './coord/CoordinateSystem';
import Element from 'zrender/src/Element';
import ComponentModel from './model/Component';

const availableMethods = {
getDom: 1,
getZr: 1,
getWidth: 1,
getHeight: 1,
getDevicePixelRatio: 1,
dispatchAction: 1,
isDisposed: 1,
on: 1,
off: 1,
getDataURL: 1,
getConnectedDataURL: 1,
getModel: 1,
getOption: 1,
getViewOfComponentModel: 1,
getViewOfSeriesModel: 1,
getId: 1
};

interface ExtensionAPI extends Pick<EChartsType, keyof typeof availableMethods> {}
const availableMethods: (keyof EChartsType)[] = [
'getDom',
'getZr',
'getWidth',
'getHeight',
'getDevicePixelRatio',
'dispatchAction',
'isDisposed',
'on',
'off',
'getDataURL',
'getConnectedDataURL',
'getModel',
'getOption',
'getViewOfComponentModel',
'getViewOfSeriesModel',
'getId',
'updateLabelLayout'
];

interface ExtensionAPI extends Pick<EChartsType, (typeof availableMethods)[number]> {}

abstract class ExtensionAPI {

constructor(ecInstance: EChartsType) {
zrUtil.each(availableMethods, function (v, name: string) {
(this as any)[name] = zrUtil.bind((ecInstance as any)[name], ecInstance);
zrUtil.each(availableMethods, function (methodName: string) {
(this as any)[methodName] = zrUtil.bind((ecInstance as any)[methodName], ecInstance);
}, this);
}

Expand Down
69 changes: 50 additions & 19 deletions src/chart/bar/BarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import {
initProps,
enableHoverEmphasis,
setLabelStyle,
clearStates,
updateLabel,
initLabel
initLabel,
removeElement
} from '../../util/graphic';
import Path, { PathProps } from 'zrender/src/graphic/Path';
import * as numberUtil from '../../util/number';
import Group from 'zrender/src/graphic/Group';
import {throttle} from '../../util/throttle';
import {createClipPath} from '../helper/createClipPathFromCoordSys';
Expand All @@ -41,7 +40,15 @@ import ChartView from '../../view/Chart';
import List, {DefaultDataVisual} from '../../data/List';
import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../ExtensionAPI';
import { StageHandlerProgressParams, ZRElementEvent, ColorString, OrdinalSortInfo, Payload, OrdinalNumber, OrdinalRawValue, DisplayState, ParsedValue } from '../../util/types';
import {
StageHandlerProgressParams,
ZRElementEvent,
ColorString,
OrdinalSortInfo,
Payload,
OrdinalNumber,
ParsedValue
} from '../../util/types';
import BarSeriesModel, { BarSeriesOption, BarDataItemOption } from './BarSeries';
import type Axis2D from '../../coord/cartesian/Axis2D';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
Expand Down Expand Up @@ -272,7 +279,15 @@ class BarView extends ChartView {
}

const el = elementCreator[coord.type](
seriesModel, data, dataIndex, layout, isHorizontalOrRadial, animationModel, false, getDuring(), roundCap
seriesModel,
data,
dataIndex,
layout,
isHorizontalOrRadial,
animationModel,
false,
getDuring(),
roundCap
);
data.setItemGraphicEl(dataIndex, el);
group.add(el);
Expand Down Expand Up @@ -317,13 +332,12 @@ class BarView extends ChartView {
}

if (el) {
clearStates(el);

if (coord.type === 'cartesian2d'
&& baseAxis.type === 'category' && (baseAxis as Axis2D).model.get('sort')
) {
const rect = layout as RectShape;
let seriesShape, axisShape;
let seriesShape;
let axisShape;
if (baseAxis.dim === 'x') {
axisShape = {
x: rect.x,
Expand All @@ -346,7 +360,14 @@ class BarView extends ChartView {
}

if (!isReorder) {
updateProps(el as Path, { shape: seriesShape }, animationModel, newIndex, null, getDuring());
updateProps(
el as Path,
{ shape: seriesShape },
animationModel,
newIndex,
null,
getDuring()
);
}
updateProps(el as Path, { shape: axisShape }, axisAnimationModel, newIndex, null);
}
Expand All @@ -363,7 +384,15 @@ class BarView extends ChartView {
}
else {
el = elementCreator[coord.type](
seriesModel, data, newIndex, layout, isHorizontalOrRadial, animationModel, true, getDuring(), roundCap
seriesModel,
data,
newIndex,
layout,
isHorizontalOrRadial,
animationModel,
true,
getDuring(),
roundCap
);
}

Expand Down Expand Up @@ -624,7 +653,9 @@ const elementCreator: {
};

const labelModel = seriesModel.getModel('label');
(isUpdate ? updateLabel : initLabel)(rect, data, newIndex, labelModel, seriesModel, animationModel, defaultTextGetter);
(isUpdate ? updateLabel : initLabel)(
rect, data, newIndex, labelModel, seriesModel, animationModel, defaultTextGetter
);
}

return rect;
Expand Down Expand Up @@ -657,7 +688,7 @@ const elementCreator: {
sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
animateTarget[animateProperty] = layout[animateProperty];
(isUpdate ? updateProps : initProps)(sector, {
shape: animateTarget,
shape: animateTarget
// __value: typeof dataValue === 'string' ? parseInt(dataValue, 10) : dataValue
}, animationModel);
}
Expand All @@ -673,9 +704,9 @@ function removeRect(
) {
// Not show text when animating
el.removeTextContent();
updateProps(el, {
shape: {
width: 0
removeElement(el, {
style: {
opacity: 0
}
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
Expand All @@ -689,9 +720,9 @@ function removeSector(
) {
// Not show text when animating
el.removeTextContent();
updateProps(el, {
shape: {
r: el.shape.r0
removeElement(el, {
style: {
opacity: 0
}
}, animationModel, dataIndex, function () {
el.parent && el.parent.remove(el);
Expand Down Expand Up @@ -776,7 +807,7 @@ function updateStyle(
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
autoColor: style.fill as ColorString,
inheritColor: style.fill as ColorString,
defaultOutsidePosition: labelPositionOutside
}
);
Expand Down
5 changes: 2 additions & 3 deletions src/chart/bar/PictorialBarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class PictorialBarView extends ChartView {
}

if (bar) {
bar.clearStates();
updateBar(bar, opt, symbolMeta);
}
else {
Expand Down Expand Up @@ -870,7 +869,7 @@ function removeBar(
bar.__pictorialClipPath && (animationModel = null);

zrUtil.each(pathes, function (path) {
graphic.updateProps(
graphic.removeElement(
path, { scaleX: 0, scaleY: 0 }, animationModel, dataIndex,
function () {
bar.parent && bar.parent.remove(bar);
Expand Down Expand Up @@ -953,7 +952,7 @@ function updateCommon(
labelFetcher: opt.seriesModel,
labelDataIndex: dataIndex,
defaultText: getDefaultLabel(opt.seriesModel.getData(), dataIndex),
autoColor: symbolMeta.style.fill as ColorString,
inheritColor: symbolMeta.style.fill as ColorString,
defaultOutsidePosition: barPositionOutside
}
);
Expand Down
1 change: 0 additions & 1 deletion src/chart/candlestick/CandlestickView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class CandlestickView extends ChartView {
el = createNormalBox(itemLayout, newIdx);
}
else {
graphic.clearStates(el);
graphic.updateProps(el, {
shape: {
points: itemLayout.ends
Expand Down
4 changes: 2 additions & 2 deletions src/chart/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/


// @ts-nocheck
import {__DEV__} from '../config';
import {
hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, keys, isArrayLike, bind
Expand Down Expand Up @@ -1377,7 +1377,7 @@ function makeRenderItem(
visualColor != null && (itemStyle.fill = visualColor);
opacity != null && (itemStyle.opacity = opacity);

const opt = {autoColor: isString(visualColor) ? visualColor : '#000'};
const opt = {inheritColor: isString(visualColor) ? visualColor : '#000'};
const labelModel = getLabelModel(dataIndexInside, NORMAL);
// Now that the feture of "auto adjust text fill/stroke" has been migrated to zrender
// since ec5, we should set `isAttached` as `false` here and make compat in
Expand Down
13 changes: 6 additions & 7 deletions src/chart/funnel/FunnelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
BoxLayoutOptionMixin,
HorizontalAlign,
LabelOption,
LabelGuideLineOption,
LabelLineOption,
ItemStyleOption,
OptionDataValueNumeric
} from '../../util/types';
Expand All @@ -51,12 +51,12 @@ export interface FunnelDataItemOption {
height?: number | string
}
label?: FunnelLabelOption
labelLine?: LabelGuideLineOption
labelLine?: LabelLineOption

emphasis?: {
itemStyle?: ItemStyleOption
label?: FunnelLabelOption
labelLine?: LabelGuideLineOption
labelLine?: LabelLineOption
}
}

Expand All @@ -80,12 +80,12 @@ export interface FunnelSeriesOption
funnelAlign?: HorizontalAlign

label?: FunnelLabelOption
labelLine?: LabelGuideLineOption
labelLine?: LabelLineOption
itemStyle?: ItemStyleOption

emphasis?: {
label?: FunnelLabelOption
labelLine?: LabelGuideLineOption
labelLine?: LabelLineOption
itemStyle?: ItemStyleOption
}

Expand Down Expand Up @@ -172,8 +172,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
length: 20,
lineStyle: {
// color: 各异,
width: 1,
type: 'solid'
width: 1
}
},
itemStyle: {
Expand Down
Loading