From eb6af35fbea5dab497da3a0ac3d380c47b0f6b16 Mon Sep 17 00:00:00 2001 From: plainheart Date: Sun, 25 Apr 2021 15:24:29 +0800 Subject: [PATCH 01/40] fix(tooltip): tooltip(especially in connected chart) may be lagged and shake from side to side in Chrome(with the devtools open) and Firefox. see #14695. --- src/component/tooltip/TooltipHTMLContent.ts | 2 +- src/component/tooltip/TooltipView.ts | 16 ++- test/tooltip-lag-glitch.html | 121 ++++++++++++++++++++ 3 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 test/tooltip-lag-glitch.html diff --git a/src/component/tooltip/TooltipHTMLContent.ts b/src/component/tooltip/TooltipHTMLContent.ts index ecd432fdd1..7d70c1b36d 100644 --- a/src/component/tooltip/TooltipHTMLContent.ts +++ b/src/component/tooltip/TooltipHTMLContent.ts @@ -100,7 +100,7 @@ function assembleTransition(duration: number, onlyFade?: boolean): string { if (!onlyFade) { transitionOption = ` ${duration}s ${transitionCurve}`; transitionText += env.transformSupported - ? `,${TRANSFORM_VENDOR}${transitionOption}` + ? `,${CSS_TRANSFORM_VENDOR}${transitionOption}` : `,left${transitionOption},top${transitionOption}`; } diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index 93949fce24..78c0ef5bff 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -57,6 +57,7 @@ import { DataByCoordSys, DataByAxis } from '../axisPointer/axisTrigger'; import { normalizeTooltipFormatResult } from '../../model/mixin/dataFormat'; import { createTooltipMarkup, buildTooltipMarkup, TooltipMarkupStyleCreator } from './tooltipMarkup'; import { findEventDispatcher } from '../../util/event'; +import { throttle } from '../../util/throttle'; const bind = zrUtil.bind; const each = zrUtil.each; @@ -166,6 +167,8 @@ class TooltipView extends ComponentView { private _lastDataByCoordSys: DataByCoordSys[]; + private _updatePosition: ReturnType | TooltipView['_doUpdatePosition']; + init(ecModel: GlobalModel, api: ExtensionAPI) { if (env.node) { return; @@ -213,6 +216,17 @@ class TooltipView extends ComponentView { this._initGlobalListener(); this._keepShow(); + + // PENDING + // `mousemove` event will be triggered very frequently when the mouse moves fast, + // which causes that the updatePosition was also called very frequently. + // In Chrome with devtools open and Firefox, tooltip looks lagged and shaked around. See #14695. + // To avoid the frequent triggering, + // consider throttling it in 50ms. (the tested result may need to validate) + this._updatePosition = + this._renderMode === 'html' + ? throttle(bind(this._doUpdatePosition, this), 50) + : this._doUpdatePosition; } private _initGlobalListener() { @@ -840,7 +854,7 @@ class TooltipView extends ComponentView { } } - private _updatePosition( + private _doUpdatePosition( tooltipModel: Model, positionExpr: TooltipOption['position'], x: number, // Mouse x diff --git a/test/tooltip-lag-glitch.html b/test/tooltip-lag-glitch.html new file mode 100644 index 0000000000..c721f41aac --- /dev/null +++ b/test/tooltip-lag-glitch.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + +
+
+ + + + + From f4ac290dcbee052e5e1337d9b68013995fc745a4 Mon Sep 17 00:00:00 2001 From: Savas Vedova Date: Mon, 23 Aug 2021 13:24:30 +0300 Subject: [PATCH 02/40] Fix: time axis overlapped labels --- src/component/axis/AxisBuilder.ts | 11 +++++++++++ src/label/labelLayoutHelper.ts | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index c262931039..eb7c2ca973 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -33,6 +33,7 @@ import { AxisBaseOption } from '../../coord/axisCommonTypes'; import Element from 'zrender/src/Element'; import { PathStyleProps } from 'zrender/src/graphic/Path'; import OrdinalScale from '../../scale/Ordinal'; +import { prepareLayoutList, hideOverlap } from '../../label/labelLayoutHelper'; const PI = Math.PI; @@ -347,6 +348,16 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu fixMinMaxLabelShow(axisModel, labelEls, ticksEls); buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection); + + const labelList = prepareLayoutList(labelEls.map(label => ({ + label, + priority: label.style.text?.includes('primary') ? 1 : 0, + defaultAttr: { + ignore: label.ignore + } + }))); + + hideOverlap(labelList); }, axisName(opt, axisModel, group, transformGroup) { diff --git a/src/label/labelLayoutHelper.ts b/src/label/labelLayoutHelper.ts index d22bb77894..2f42db5c7c 100644 --- a/src/label/labelLayoutHelper.ts +++ b/src/label/labelLayoutHelper.ts @@ -24,12 +24,12 @@ import type Element from 'zrender/src/Element'; interface LabelLayoutListPrepareInput { label: ZRText - labelLine: Polyline - computedLayoutOption: LabelLayoutOption + labelLine?: Polyline + computedLayoutOption?: LabelLayoutOption priority: number defaultAttr: { ignore: boolean - labelGuideIgnore: boolean + labelGuideIgnore?: boolean } } @@ -44,7 +44,7 @@ export interface LabelLayoutInfo { layoutOption: LabelLayoutOption defaultAttr: { ignore: boolean - labelGuideIgnore: boolean + labelGuideIgnore?: boolean } transform: number[] } From 090efb2bd120dc0157478cdd8444f3f879152247 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Tue, 24 Aug 2021 13:40:07 +0800 Subject: [PATCH 03/40] fix(polar): wrong sector clockwise when previous data is 0 #15517 --- src/chart/bar/BarView.ts | 2 +- test/line-animation.html | 62 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index e4be916699..e790bbc57e 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -750,7 +750,7 @@ const elementCreator: { // direction. Notice that if clockwise is true (by default), the sector // will always draw clockwisely, no matter whether endAngle is greater // or less than startAngle. - const clockwise = layout.startAngle < layout.endAngle; + const clockwise = layout.startAngle <= layout.endAngle; const ShapeClass = (!isRadial && roundCap) ? Sausage : Sector; diff --git a/test/line-animation.html b/test/line-animation.html index 011fd69d83..fd9cdeca2f 100644 --- a/test/line-animation.html +++ b/test/line-animation.html @@ -49,6 +49,8 @@ } +
+
@@ -400,6 +402,66 @@

Label Animation with animationDelay callback

+ + \ No newline at end of file From 29a1a27c9e3c3d7eb14dce948e41a458f3f8184b Mon Sep 17 00:00:00 2001 From: Ovilia Date: Tue, 24 Aug 2021 13:46:45 +0800 Subject: [PATCH 04/40] test(polar): update test case --- test/bar-polar-basic.html | 10 ++++++- test/line-animation.html | 62 --------------------------------------- 2 files changed, 9 insertions(+), 63 deletions(-) diff --git a/test/bar-polar-basic.html b/test/bar-polar-basic.html index 3dab721de3..aefe933fa9 100644 --- a/test/bar-polar-basic.html +++ b/test/bar-polar-basic.html @@ -59,7 +59,7 @@

click axis labe should console log

tooltip: {}, series: [{ type: 'bar', - data: [1, 2, 4, 3, 6, 5, 7], + data: [1, 2, 0, 3, 6, 5, 7], coordinateSystem: 'polar', itemStyle: { normal: { @@ -70,6 +70,14 @@

click axis labe should console log

}] }); + setTimeout(function () { + chart.setOption({ + series: [{ + data: [1, 2, 4, 3, 6, 5, 7] + }] + }); + }); + chart.on('click', function (params) { console.log(params); }); diff --git a/test/line-animation.html b/test/line-animation.html index fd9cdeca2f..011fd69d83 100644 --- a/test/line-animation.html +++ b/test/line-animation.html @@ -49,8 +49,6 @@ } -
-
@@ -402,66 +400,6 @@

Label Animation with animationDelay callback

- - \ No newline at end of file From ec9b3fc3ea5e69315e2a1c3e009f9991e10f3c4a Mon Sep 17 00:00:00 2001 From: Savas Vedova Date: Tue, 24 Aug 2021 16:22:27 +0300 Subject: [PATCH 05/40] Use tick level to determine the priority --- src/component/axis/AxisBuilder.ts | 20 ++++++++++++-------- src/coord/axisTickLabelBuilder.ts | 2 ++ src/util/types.ts | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index eb7c2ca973..b9b8ed7e2f 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -349,15 +349,17 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection); - const labelList = prepareLayoutList(labelEls.map(label => ({ - label, - priority: label.style.text?.includes('primary') ? 1 : 0, - defaultAttr: { - ignore: label.ignore - } - }))); + if (axisModel.type === 'xAxis.time') { + const labelList = prepareLayoutList(labelEls.map(label => ({ + label, + priority: label.zlevel, + defaultAttr: { + ignore: label.ignore + } + }))); - hideOverlap(labelList); + hideOverlap(labelList); + } }, axisName(opt, axisModel, group, transformGroup) { @@ -820,6 +822,8 @@ function buildAxisLabel( transformGroup.add(textEl); textEl.updateTransform(); + textEl.zlevel = labelItem.level; + labelEls.push(textEl); group.add(textEl); diff --git a/src/coord/axisTickLabelBuilder.ts b/src/coord/axisTickLabelBuilder.ts index 332e542e83..fbc2e5c975 100644 --- a/src/coord/axisTickLabelBuilder.ts +++ b/src/coord/axisTickLabelBuilder.ts @@ -62,6 +62,7 @@ const inner = makeInner(); export function createAxisLabels(axis: Axis): { labels: { + level?: number, formattedLabel: string, rawLabel: string, tickValue: number @@ -176,6 +177,7 @@ function makeRealNumberLabels(axis: Axis) { return { labels: zrUtil.map(ticks, function (tick, idx) { return { + level: tick.level, formattedLabel: labelFormatter(tick, idx), rawLabel: axis.scale.getLabel(tick), tickValue: tick.value diff --git a/src/util/types.ts b/src/util/types.ts index ab1a6b1b2b..1686e56d45 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -377,6 +377,7 @@ export type ParsedValueNumeric = number | OrdinalNumber; export type ScaleDataValue = ParsedValueNumeric | OrdinalRawValue | Date; export interface ScaleTick { + level?: number, value: number }; export interface TimeScaleTick extends ScaleTick { From 7d33cfb062d7035c5c3bce61bcb5a269d0762daf Mon Sep 17 00:00:00 2001 From: Savas Vedova Date: Tue, 24 Aug 2021 16:24:59 +0300 Subject: [PATCH 06/40] Add comment to describe the fix --- src/component/axis/AxisBuilder.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index b9b8ed7e2f..4d2b4977eb 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -349,6 +349,8 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection); + // This bit fixes the label overlap issue for the Time chart. + // See https://github.com/apache/echarts/issues/14266 for more. if (axisModel.type === 'xAxis.time') { const labelList = prepareLayoutList(labelEls.map(label => ({ label, From cffa3806a4392259a62fdb915d5b91bc71695377 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Wed, 25 Aug 2021 11:01:20 +0800 Subject: [PATCH 07/40] fix(line): fix line chart animation #15581 --- src/chart/line/LineView.ts | 15 ++++++++++++--- test/line-animation.html | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index 9cabed1302..6103b32802 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -691,9 +691,18 @@ class LineView extends ChartView { } // Update clipPath - lineGroup.setClipPath( - createLineClipPath(this, coordSys, false, seriesModel) - ); + const oldClipPath = lineGroup.getClipPath(); + if (oldClipPath) { + const newClipPath = createLineClipPath(this, coordSys, false, seriesModel); + graphic.initProps(oldClipPath, { + shape: newClipPath.shape + }, seriesModel); + } + else { + lineGroup.setClipPath( + createLineClipPath(this, coordSys, true, seriesModel) + ); + } // Always update, or it is wrong in the case turning on legend // because points are not changed diff --git a/test/line-animation.html b/test/line-animation.html index 011fd69d83..853e3b8154 100644 --- a/test/line-animation.html +++ b/test/line-animation.html @@ -49,6 +49,8 @@ } +
+
@@ -400,6 +402,42 @@

Label Animation with animationDelay callback

+ + \ No newline at end of file From 319ac07d0604b4914809cb27ec142baf0de033e1 Mon Sep 17 00:00:00 2001 From: Savas Vedova Date: Wed, 25 Aug 2021 20:55:25 +0300 Subject: [PATCH 08/40] Use z2 instead of zlevel for priority --- src/component/axis/AxisBuilder.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index 4d2b4977eb..31d6a9c8bb 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -351,10 +351,10 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu // This bit fixes the label overlap issue for the Time chart. // See https://github.com/apache/echarts/issues/14266 for more. - if (axisModel.type === 'xAxis.time') { + if (axisModel.get('type') === 'time') { const labelList = prepareLayoutList(labelEls.map(label => ({ label, - priority: label.zlevel, + priority: label.z2, defaultAttr: { ignore: label.ignore } @@ -781,7 +781,7 @@ function buildAxisLabel( y: opt.labelOffset + opt.labelDirection * labelMargin, rotation: labelLayout.rotation, silent: silent, - z2: 10, + z2: labelItem.level, style: createTextStyle(itemLabelModel, { text: formattedLabel, align: itemLabelModel.getShallow('align', true) @@ -824,8 +824,6 @@ function buildAxisLabel( transformGroup.add(textEl); textEl.updateTransform(); - textEl.zlevel = labelItem.level; - labelEls.push(textEl); group.add(textEl); From 563fc01a1aec3a9859943e7bc11ecddc3a457fcf Mon Sep 17 00:00:00 2001 From: Savas Vedova Date: Thu, 26 Aug 2021 12:48:42 +0300 Subject: [PATCH 09/40] Use map and have a fallback z2 value --- src/component/axis/AxisBuilder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index 31d6a9c8bb..6fad867a6a 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -17,7 +17,7 @@ * under the License. */ -import {retrieve, defaults, extend, each, isObject} from 'zrender/src/core/util'; +import {retrieve, defaults, extend, each, isObject, map} from 'zrender/src/core/util'; import * as graphic from '../../util/graphic'; import {getECData} from '../../util/innerStore'; import {createTextStyle} from '../../label/labelStyle'; @@ -352,7 +352,7 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu // This bit fixes the label overlap issue for the Time chart. // See https://github.com/apache/echarts/issues/14266 for more. if (axisModel.get('type') === 'time') { - const labelList = prepareLayoutList(labelEls.map(label => ({ + const labelList = prepareLayoutList(map(labelEls, label => ({ label, priority: label.z2, defaultAttr: { @@ -781,7 +781,7 @@ function buildAxisLabel( y: opt.labelOffset + opt.labelDirection * labelMargin, rotation: labelLayout.rotation, silent: silent, - z2: labelItem.level, + z2: 10 + (labelItem.level || 0), style: createTextStyle(itemLabelModel, { text: formattedLabel, align: itemLabelModel.getShallow('align', true) From 6b488a8d29055f184960e3b29410bf5e23d8e33e Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 2 Sep 2021 09:50:16 +0800 Subject: [PATCH 10/40] chore: add nightly publish for next branch --- .asf.yaml | 33 ++++++++++++++++++++++ .github/workflows/nightly-next.yml | 37 +++++++++++++++++++++++++ build/prepareNightly.js | 44 ++++++++++++++++++------------ 3 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/nightly-next.yml diff --git a/.asf.yaml b/.asf.yaml index c35ff79788..63abb9c295 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -28,3 +28,36 @@ github: - data-viz - canvas - svg + protected_branches: + master: + required_status_checks: + # strict means "Require branches to be up to date before merging". + strict: false + # contexts are the names of checks that must pass + # contexts: + # - gh-infra/jenkins + required_pull_request_reviews: + dismiss_stale_reviews: true + require_code_owner_reviews: false + required_approving_review_count: 1 + required_linear_history: false + required_signatures: false + release: + required_status_checks: + strict: false + required_pull_request_reviews: + dismiss_stale_reviews: true + require_code_owner_reviews: false + required_approving_review_count: 1 + required_linear_history: false + required_signatures: false + next: + required_status_checks: + strict: false + required_pull_request_reviews: + dismiss_stale_reviews: true + require_code_owner_reviews: false + required_approving_review_count: 1 + required_linear_history: false + required_signatures: false + diff --git a/.github/workflows/nightly-next.yml b/.github/workflows/nightly-next.yml new file mode 100644 index 0000000000..7028c1db06 --- /dev/null +++ b/.github/workflows/nightly-next.yml @@ -0,0 +1,37 @@ +name: Publish Nightly Next + +on: + schedule: + - cron: '0 9 * * *' # After zrender nightly published + # committers can manually trigger with workflow_dispatch + workflow_dispatch: {} + repository_dispatch: + types: publish-nightly-next + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - uses: actions/checkout@v2 + with: + ref: next + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + registry-url: https://registry.npmjs.org/ + - name: Setup and publish nightly + run: | + npm ci + npm run release + npm run test + npm run test:dts + node build/prepareNightly.js --next + npm publish --tag next + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/build/prepareNightly.js b/build/prepareNightly.js index 442d3d508f..44d20ccec1 100644 --- a/build/prepareNightly.js +++ b/build/prepareNightly.js @@ -23,26 +23,36 @@ const packageJsonPath = __dirname + '/../package.json'; const nightlyPackageName = 'echarts-nightly'; const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); -const version = packageJson.version; -const parts = /(\d+)\.(\d+)\.(\d+)($|\-.*)/.exec(version); -if (!parts) { - throw new Error(`Invalid version number ${version}`); -} -// Add date to version. -const major = +parts[1]; -const minor = +parts[2]; -let patch = +parts[3]; -const notDev = !(parts[4] && parts[4].includes('-dev')); -if (notDev) { - // It's previous stable or rc version. Dev version should be higher. - patch++; -} -const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8); -const nightlyVersion = `${major}.${minor}.${patch}-dev.${date}`; +function updateVersion(version) { + const isNext = process.argv.includes('--next'); + const parts = /(\d+)\.(\d+)\.(\d+)($|\-)/.exec(version); + if (!parts) { + throw new Error(`Invalid version number ${version}`); + } + // Add date to version. + const major = +parts[1]; + let minor = +parts[2]; + let patch = +parts[3]; + const isStable = !parts[4]; + if (isStable) { + // It's previous stable version. Dev version should be higher. + if (isNext) { + // Increase minor version for next branch. + minor++; + } + else { + // Increase main version for master branch. + patch++; + } + } + + const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8); + return `${major}.${minor}.${patch}-dev.${date}`; +} packageJson.name = nightlyPackageName; -packageJson.version = nightlyVersion; +packageJson.version = updateVersion(packageJson.version); fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8'); From 42d08f74b9308b0b5fe0fcd56b4084b5a6f90fc5 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 14:21:33 +0800 Subject: [PATCH 11/40] chore: update stale action --- .github/stale.yml | 60 ------------------------------------- .github/workflows/stale.yml | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 60 deletions(-) delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 6d589b6763..0000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,60 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale - -# Number of days of inactivity before an Issue or Pull Request becomes stale -daysUntilStale: 731 # two years - -# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. -# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -daysUntilClose: 7 - -# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) -onlyLabels: [] - -# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable -exemptLabels: - - "maybe-later" - - "priority: high" - -# Set to true to ignore issues in a project (defaults to false) -exemptProjects: true - -# Set to true to ignore issues in a milestone (defaults to false) -exemptMilestones: false - -# Set to true to ignore issues with an assignee (defaults to false) -exemptAssignees: false - -# Label to use when marking as stale -staleLabel: stale - -# Comment to post when marking as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. - -# Comment to post when removing the stale label. -unmarkComment: > - This issue is marked to be `stale` and is going to be closed within a week. If you think it shouldn't be closed, please leave a comment. - -# Comment to post when closing a stale Issue or Pull Request. -# closeComment: > -# Your comment here. - -# Limit the number of actions per hour, from 1-30. Default is 30 -limitPerRun: 30 - -# Limit to only `issues` or `pulls` -# only: issues - -# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': -# pulls: -# daysUntilStale: 30 -# markComment: > -# This pull request has been automatically marked as stale because it has not had -# recent activity. It will be closed if no further activity occurs. Thank you -# for your contributions. - -# issues: -# exemptLabels: -# - confirmed diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..45f7273329 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,30 @@ +name: Closing Stale Issues + +permissions: + issues: write + pull-requests: write + +on: + schedule: + - cron: '0 21 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - name: Close Stale Issues + uses: actions/stale@v4.0.0 + with: + days-before-stale: 730 + days-before-close: 7 + stale-issue-label: stale + stale-pr-label: stale + stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.' + close-issue-message: 'This issue has been automatically closed because it has not had recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' + stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.' + close-pr-message: 'This PR has been automatically closed because it has not had recent activity. Sorry for that and we are looking forward to your next contribution.' + exempt-issue-labels: + - 'FAQ' + - 'priority: high' + operations-per-run: 50 + ascending: true From f82379cfe57cfb67103c235c00043dbd6888443e Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 14:33:06 +0800 Subject: [PATCH 12/40] chore: test and run now --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 45f7273329..523206e6e7 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,7 @@ permissions: on: schedule: - - cron: '0 21 * * *' + - cron: '40 * * * *' jobs: stale: From eea9770e05f8075dd7914d903a1036402795010a Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 14:44:25 +0800 Subject: [PATCH 13/40] chore: update test time --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 523206e6e7..8967fe5eca 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,7 @@ permissions: on: schedule: - - cron: '40 * * * *' + - cron: '50 * * * *' jobs: stale: From 2c1a4fb4e6f4118a22d2bc498869fcaa4296bbf6 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 14:59:57 +0800 Subject: [PATCH 14/40] chore: fix stale config --- .github/workflows/stale.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 8967fe5eca..b10ee489a4 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,7 @@ permissions: on: schedule: - - cron: '50 * * * *' + - cron: '10 * * * *' jobs: stale: @@ -23,8 +23,6 @@ jobs: close-issue-message: 'This issue has been automatically closed because it has not had recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.' close-pr-message: 'This PR has been automatically closed because it has not had recent activity. Sorry for that and we are looking forward to your next contribution.' - exempt-issue-labels: - - 'FAQ' - - 'priority: high' + exempt-issue-labels: 'FAQ,priority: high' operations-per-run: 50 ascending: true From b87a5dbb2a17868d9c4fff28120dd9f5608b3b40 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 16:34:20 +0800 Subject: [PATCH 15/40] chore: update stale action period --- .github/workflows/stale.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b10ee489a4..ec70f38760 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,7 @@ permissions: on: schedule: - - cron: '10 * * * *' + - cron: '0 21 * * *' jobs: stale: @@ -19,10 +19,10 @@ jobs: days-before-close: 7 stale-issue-label: stale stale-pr-label: stale - stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.' - close-issue-message: 'This issue has been automatically closed because it has not had recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' + stale-issue-message: 'This issue has been automatically marked as stale because it does not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.' + close-issue-message: 'This issue has been automatically closed because it does not had recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.' close-pr-message: 'This PR has been automatically closed because it has not had recent activity. Sorry for that and we are looking forward to your next contribution.' exempt-issue-labels: 'FAQ,priority: high' - operations-per-run: 50 + operations-per-run: 500 ascending: true From ea06e74e7d95b4f51de3ad7981db6770cee4f2e8 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 3 Sep 2021 16:36:14 +0800 Subject: [PATCH 16/40] chore: fix gramma --- .github/workflows/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index ec70f38760..18f55567c5 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -19,8 +19,8 @@ jobs: days-before-close: 7 stale-issue-label: stale stale-pr-label: stale - stale-issue-message: 'This issue has been automatically marked as stale because it does not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.' - close-issue-message: 'This issue has been automatically closed because it does not had recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' + stale-issue-message: 'This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.' + close-issue-message: 'This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!' stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.' close-pr-message: 'This PR has been automatically closed because it has not had recent activity. Sorry for that and we are looking forward to your next contribution.' exempt-issue-labels: 'FAQ,priority: high' From 06b33ad9337c5e0583143c07afcc2a3f9fbe9b8d Mon Sep 17 00:00:00 2001 From: pissang Date: Sun, 5 Sep 2021 11:33:34 +0800 Subject: [PATCH 17/40] fix(type): improve some types --- index.d.ts | 5 ++++- src/chart/candlestick/CandlestickSeries.ts | 6 +++--- src/chart/line/LineSeries.ts | 2 +- src/chart/lines/LinesSeries.ts | 7 ++++++- src/coord/radar/RadarModel.ts | 1 + src/data/helper/transform.ts | 2 +- src/util/format.ts | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 20195af345..1941965fbe 100644 --- a/index.d.ts +++ b/index.d.ts @@ -17,4 +17,7 @@ * under the License. */ -export * from './types/dist/echarts'; \ No newline at end of file +import * as echarts from './types/dist/echarts'; +// Export for UMD module. +export as namespace echarts +export = echarts; \ No newline at end of file diff --git a/src/chart/candlestick/CandlestickSeries.ts b/src/chart/candlestick/CandlestickSeries.ts index d71cecd57d..e9079ca37b 100644 --- a/src/chart/candlestick/CandlestickSeries.ts +++ b/src/chart/candlestick/CandlestickSeries.ts @@ -28,17 +28,17 @@ import { ColorString, SeriesLabelOption, SeriesLargeOptionMixin, - OptionDataValueNumeric, StatesOptionMixin, SeriesEncodeOptionMixin, - DefaultEmphasisFocus + DefaultEmphasisFocus, + OptionDataValue } from '../../util/types'; import SeriesData from '../../data/SeriesData'; import Cartesian2D from '../../coord/cartesian/Cartesian2D'; import { BrushCommonSelectorsForSeries } from '../../component/brush/selector'; import { mixin } from 'zrender/src/core/util'; -type CandlestickDataValue = OptionDataValueNumeric[]; +type CandlestickDataValue = OptionDataValue[]; interface CandlestickItemStyleOption extends ItemStyleOption { color0?: ZRColor diff --git a/src/chart/line/LineSeries.ts b/src/chart/line/LineSeries.ts index a836132e4d..9114ee69f8 100644 --- a/src/chart/line/LineSeries.ts +++ b/src/chart/line/LineSeries.ts @@ -115,7 +115,7 @@ export interface LineSeriesOption extends SeriesOption, LinesStateOption, diff --git a/src/coord/radar/RadarModel.ts b/src/coord/radar/RadarModel.ts index 070892f064..1144ab07c8 100644 --- a/src/coord/radar/RadarModel.ts +++ b/src/coord/radar/RadarModel.ts @@ -42,6 +42,7 @@ function defaultsShow(opt: object, show: boolean) { } export interface RadarIndicatorOption { + name?: string text?: string min?: number max?: number diff --git a/src/data/helper/transform.ts b/src/data/helper/transform.ts index 78c1a70754..6e5181f140 100644 --- a/src/data/helper/transform.ts +++ b/src/data/helper/transform.ts @@ -42,7 +42,7 @@ export type DataTransformConfig = unknown; export interface DataTransformOption { type: DataTransformType; - config: DataTransformConfig; + config?: DataTransformConfig; // Print the result via `console.log` when transform performed. Only work in dev mode for debug. print?: boolean; } diff --git a/src/util/format.ts b/src/util/format.ts index c4950201d9..1f9749edc7 100644 --- a/src/util/format.ts +++ b/src/util/format.ts @@ -260,7 +260,7 @@ export function getTooltipMarker(inOpt: ColorString | GetTooltipMarkerOpt, extra * and `module:echarts/util/number#parseDate`. * @inner */ -export function formatTime(tpl: string, value: unknown, isUTC: boolean) { +export function formatTime(tpl: string, value: unknown, isUTC?: boolean) { if (__DEV__) { deprecateReplaceLog('echarts.format.formatTime', 'echarts.time.format'); } From 75aac8cfeea9ec09e71565ef401ff36d118d1ad1 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Mon, 6 Sep 2021 14:46:12 +0800 Subject: [PATCH 18/40] fix(polar): fix when angleAxis is inverse --- src/chart/bar/BarView.ts | 15 ++++----------- src/layout/barPolar.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index e790bbc57e..fba170ed47 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -238,6 +238,7 @@ class BarView extends ChartView { .add(function (dataIndex) { const itemModel = data.getItemModel(dataIndex); const layout = getLayout[coord.type](data, dataIndex, itemModel); + // console.log('get', layout.clockwise); if (drawBackground) { createBackground(dataIndex); @@ -746,18 +747,9 @@ const elementCreator: { seriesModel, data, newIndex, layout: SectorLayout, isRadial: boolean, animationModel, axisModel, isUpdate, roundCap ) { - // Keep the same logic with bar in catesion: use end value to control - // direction. Notice that if clockwise is true (by default), the sector - // will always draw clockwisely, no matter whether endAngle is greater - // or less than startAngle. - const clockwise = layout.startAngle <= layout.endAngle; - const ShapeClass = (!isRadial && roundCap) ? Sausage : Sector; - const sector = new ShapeClass({ - shape: defaults({ - clockwise: clockwise - }, layout), + shape: layout, z2: 1 }); @@ -909,7 +901,8 @@ const getLayout: { r0: layout.r0, r: layout.r, startAngle: layout.startAngle, - endAngle: layout.endAngle + endAngle: layout.endAngle, + clockwise: layout.clockwise } as SectorLayout; } }; diff --git a/src/layout/barPolar.ts b/src/layout/barPolar.ts index 081d884634..bc63fcba99 100644 --- a/src/layout/barPolar.ts +++ b/src/layout/barPolar.ts @@ -183,7 +183,15 @@ function barLayoutPolar(seriesType: string, ecModel: GlobalModel, api: Extension // Consider that positive angle is anti-clockwise, // while positive radian of sector is clockwise startAngle: -startAngle * Math.PI / 180, - endAngle: -endAngle * Math.PI / 180 + endAngle: -endAngle * Math.PI / 180, + + /** + * Keep the same logic with bar in catesion: use end value to + * control direction. Notice that if clockwise is true (by + * default), the sector will always draw clockwisely, no matter + * whether endAngle is greater or less than startAngle. + */ + clockwise: startAngle >= endAngle }); } From 2b46ae9799ae60dde965fc3bfde9ef192d1b83a3 Mon Sep 17 00:00:00 2001 From: plainheart Date: Tue, 7 Sep 2021 09:32:27 +0800 Subject: [PATCH 19/40] fix(test): use simpleRequire for tooltip-lag-glitch.html. --- test/tooltip-lag-glitch.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tooltip-lag-glitch.html b/test/tooltip-lag-glitch.html index c721f41aac..21176a8c98 100644 --- a/test/tooltip-lag-glitch.html +++ b/test/tooltip-lag-glitch.html @@ -23,7 +23,7 @@ - + From f4590f1d711747b141c71cd8419fd63cfe73494d Mon Sep 17 00:00:00 2001 From: plainheart Date: Tue, 7 Sep 2021 09:40:34 +0800 Subject: [PATCH 20/40] fix(test): fix typos in tooltip-lag-glitch.html. --- test/tooltip-lag-glitch.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tooltip-lag-glitch.html b/test/tooltip-lag-glitch.html index 21176a8c98..d5cf6a0874 100644 --- a/test/tooltip-lag-glitch.html +++ b/test/tooltip-lag-glitch.html @@ -97,7 +97,7 @@ var chart1 = testHelper.create(echarts, 'main0', { title: [ - 'Tooltip shouldn\'t shakes or lags', + 'Tooltip shouldn\'t shake or lag', '1) Chrome with the devtools open', '2) Firefox' ], @@ -106,7 +106,7 @@ var chart2 = testHelper.create(echarts, 'main1', { title: [ - 'Tooltip shouldn\'t shakes or lags', + 'Tooltip shouldn\'t shake or lag', '1) Chrome with the devtools open', '2) Firefox' ], From ef1d850d886028cc4c7b259be04aa03fa0873fcf Mon Sep 17 00:00:00 2001 From: sushuang Date: Tue, 7 Sep 2021 20:19:55 +0800 Subject: [PATCH 21/40] fix: Fix MarkLine/MarkPoint/MarkArea do not work on time axis if input string time format. fix #15675 --- src/component/marker/MarkAreaView.ts | 42 +++++----- src/component/marker/MarkLineView.ts | 9 ++- src/component/marker/MarkPointView.ts | 12 ++- src/component/marker/markerHelper.ts | 35 +++++--- test/marker-case.html | 111 ++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 44 deletions(-) create mode 100644 test/marker-case.html diff --git a/src/component/marker/MarkAreaView.ts b/src/component/marker/MarkAreaView.ts index e23403cbfe..f9b762cf1e 100644 --- a/src/component/marker/MarkAreaView.ts +++ b/src/component/marker/MarkAreaView.ts @@ -27,7 +27,7 @@ import { enableHoverEmphasis, setStatesStylesFromModel } from '../../util/states import * as markerHelper from './markerHelper'; import MarkerView from './MarkerView'; import { retrieve, mergeAll, map, curry, filter, HashMap, extend } from 'zrender/src/core/util'; -import { ScaleDataValue, ParsedValue, ZRColor } from '../../util/types'; +import { ParsedValue, ScaleDataValue, ZRColor } from '../../util/types'; import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem'; import MarkAreaModel, { MarkArea2DDataItemOption } from './MarkAreaModel'; import SeriesModel from '../../model/Series'; @@ -41,6 +41,7 @@ import { getVisualFromData } from '../../visual/helper'; import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle'; import { getECData } from '../../util/innerStore'; import Axis2D from '../../coord/cartesian/Axis2D'; +import { parseDataValue } from '../../data/helper/dataValueHelper'; interface MarkAreaDrawGroup { group: graphic.Group @@ -362,11 +363,11 @@ function createList( maModel: MarkAreaModel ) { - let coordDimsInfos: SeriesDimensionDefine[]; let areaData: SeriesData; + let dataDims: SeriesDimensionDefine[]; const dims = ['x0', 'y0', 'x1', 'y1']; if (coordSys) { - coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) { + const coordDimsInfos: SeriesDimensionDefine[] = map(coordSys && coordSys.dimensions, function (coordDim) { const data = seriesModel.getData(); const info = data.getDimensionInfo( data.mapDimension(coordDim) @@ -378,19 +379,18 @@ function createList( ordinalMeta: null }); }); - areaData = new SeriesData(map(dims, function (dim, idx) { - return { - name: dim, - type: coordDimsInfos[idx % 2].type - }; - }), maModel); + dataDims = map(dims, (dim, idx) => ({ + name: dim, + type: coordDimsInfos[idx % 2].type + })); + areaData = new SeriesData(dataDims, maModel); } else { - coordDimsInfos = [{ + dataDims = [{ name: 'value', type: 'float' }]; - areaData = new SeriesData(coordDimsInfos, maModel); + areaData = new SeriesData(dataDims, maModel); } let optData = map(maModel.get('data'), curry( @@ -402,17 +402,15 @@ function createList( ); } - const dimValueGetter = coordSys ? function ( - item: MarkAreaMergedItemOption, - dimName: string, - dataIndex: number, - dimIndex: number - ) { - // TODO should convert to ParsedValue? - return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2] as ParsedValue; - } : function (item: MarkAreaMergedItemOption) { - return item.value; - }; + const dimValueGetter: markerHelper.MarkerDimValueGetter = coordSys + ? function (item, dimName, dataIndex, dimIndex) { + // TODO should convert to ParsedValue? + const rawVal = item.coord[Math.floor(dimIndex / 2)][dimIndex % 2]; + return parseDataValue(rawVal, dataDims[dimIndex]); + } + : function (item, dimName, dataIndex, dimIndex) { + return parseDataValue(item.value, dataDims[dimIndex]); + }; areaData.initData(optData, null, dimValueGetter); areaData.hasItemOption = true; return areaData; diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts index 212ce68ced..7c651b6bd7 100644 --- a/src/component/marker/MarkLineView.ts +++ b/src/component/marker/MarkLineView.ts @@ -50,6 +50,7 @@ import { makeInner } from '../../util/model'; import { LineDataVisual } from '../../visual/commonVisualTypes'; import { getVisualFromData } from '../../visual/helper'; import Axis2D from '../../coord/cartesian/Axis2D'; +import SeriesDimensionDefine from '../../data/SeriesDimensionDefine'; // Item option for configuring line and each end of symbol. // Line option. be merged from configuration of two ends. @@ -435,7 +436,7 @@ class MarkLineView extends MarkerView { function createList(coordSys: CoordinateSystem, seriesModel: SeriesModel, mlModel: MarkLineModel) { - let coordDimsInfos; + let coordDimsInfos: SeriesDimensionDefine[]; if (coordSys) { coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) { const info = seriesModel.getData().getDimensionInfo( @@ -469,9 +470,9 @@ function createList(coordSys: CoordinateSystem, seriesModel: SeriesModel, mlMode optData, curry(markLineFilter, coordSys) ); } - const dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item: MarkLineMergedItemOption) { - return item.value; - }; + + const dimValueGetter = markerHelper.createMarkerDimValueGetter(!!coordSys, coordDimsInfos); + fromData.initData( map(optData, function (item) { return item[0]; diff --git a/src/component/marker/MarkPointView.ts b/src/component/marker/MarkPointView.ts index f0693da1fe..d5e4fc1fa7 100644 --- a/src/component/marker/MarkPointView.ts +++ b/src/component/marker/MarkPointView.ts @@ -29,10 +29,11 @@ import MarkPointModel, {MarkPointDataItemOption} from './MarkPointModel'; import GlobalModel from '../../model/Global'; import MarkerModel from './MarkerModel'; import ExtensionAPI from '../../core/ExtensionAPI'; -import { HashMap, isFunction, map, defaults, filter, curry, extend } from 'zrender/src/core/util'; +import { HashMap, isFunction, map, filter, curry, extend } from 'zrender/src/core/util'; import { getECData } from '../../util/innerStore'; import { getVisualFromData } from '../../visual/helper'; import { ZRColor } from '../../util/types'; +import SeriesDimensionDefine from '../../data/SeriesDimensionDefine'; function updateMarkerLayout( mpData: SeriesData, @@ -180,7 +181,7 @@ function createData( seriesModel: SeriesModel, mpModel: MarkPointModel ) { - let coordDimsInfos; + let coordDimsInfos: SeriesDimensionDefine[]; if (coordSys) { coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) { const info = seriesModel.getData().getDimensionInfo( @@ -211,11 +212,8 @@ function createData( ); } - mpData.initData(dataOpt, null, - coordSys ? markerHelper.dimValueGetter : function (item: MarkPointDataItemOption) { - return item.value; - } - ); + const dimValueGetter = markerHelper.createMarkerDimValueGetter(!!coordSys, coordDimsInfos); + mpData.initData(dataOpt, null, dimValueGetter); return mpData; } diff --git a/src/component/marker/markerHelper.ts b/src/component/marker/markerHelper.ts index 0987473a59..f0394b7f6a 100644 --- a/src/component/marker/markerHelper.ts +++ b/src/component/marker/markerHelper.ts @@ -26,6 +26,8 @@ import { indexOf, curry, clone, isArray } from 'zrender/src/core/util'; import Axis from '../../coord/Axis'; import { CoordinateSystem } from '../../coord/CoordinateSystem'; import { ScaleDataValue, ParsedValue, DimensionLoose, DimensionName } from '../../util/types'; +import { parseDataValue } from '../../data/helper/dataValueHelper'; +import SeriesDimensionDefine from '../../data/SeriesDimensionDefine'; interface MarkerAxisInfo { valueDataDim: DimensionName @@ -34,6 +36,13 @@ interface MarkerAxisInfo { baseDataDim: DimensionName } +export type MarkerDimValueGetter = ( + item: TMarkerItemOption, + dimName: string, + dataIndex: number, + dimIndex: number +) => ParsedValue; + function hasXOrY(item: MarkerPositionOption) { return !(isNaN(parseFloat(item.x as string)) && isNaN(parseFloat(item.y as string))); } @@ -187,17 +196,21 @@ export function dataFilter( ? coordSys.containData(item.coord) : true; } -export function dimValueGetter( - item: MarkerPositionOption, - dimName: string, - dataIndex: number, - dimIndex: number -) { - // x, y, radius, angle - if (dimIndex < 2) { - return item.coord && item.coord[dimIndex] as ParsedValue; - } - return item.value; +export function createMarkerDimValueGetter( + inCoordSys: boolean, + dims: SeriesDimensionDefine[] +): MarkerDimValueGetter { + return inCoordSys + ? function (item, dimName, dataIndex, dimIndex) { + const rawVal = dimIndex < 2 + // x, y, radius, angle + ? (item.coord && item.coord[dimIndex]) + : item.value; + return parseDataValue(rawVal, dims[dimIndex]); + } + : function (item, dimName, dataIndex, dimIndex) { + return parseDataValue(item.value, dims[dimIndex]); + }; } export function numCalculate( diff --git a/test/marker-case.html b/test/marker-case.html new file mode 100644 index 0000000000..756fa49dda --- /dev/null +++ b/test/marker-case.html @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + From 754f6765e63773ff4f4261cfd09a9b4c794a0a30 Mon Sep 17 00:00:00 2001 From: pissang Date: Wed, 8 Sep 2021 13:17:15 +0800 Subject: [PATCH 22/40] fix(type): more precise axis types --- src/component/marker/MarkLineView.ts | 1 - src/coord/Axis.ts | 4 +- src/coord/AxisBaseModel.ts | 6 +- src/coord/axisCommonTypes.ts | 141 ++++++++++++++++----------- src/coord/axisHelper.ts | 18 +++- src/coord/axisModelCreator.ts | 14 +-- src/coord/cartesian/AxisModel.ts | 14 +-- src/coord/cartesian/Grid.ts | 4 +- src/coord/parallel/AxisModel.ts | 6 +- src/coord/parallel/Parallel.ts | 5 +- src/coord/polar/AxisModel.ts | 12 +-- src/coord/polar/polarCreator.ts | 5 +- src/coord/radar/RadarModel.ts | 9 +- src/coord/scaleRawExtentInfo.ts | 4 +- src/coord/single/AxisModel.ts | 6 +- src/coord/single/Single.ts | 4 +- src/scale/Ordinal.ts | 4 +- 17 files changed, 151 insertions(+), 106 deletions(-) diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts index 212ce68ced..07335a1de8 100644 --- a/src/component/marker/MarkLineView.ts +++ b/src/component/marker/MarkLineView.ts @@ -41,7 +41,6 @@ import { logError, merge, map, - defaults, curry, filter, HashMap diff --git a/src/coord/Axis.ts b/src/coord/Axis.ts index a2f3e0ae89..7a334a0a4b 100644 --- a/src/coord/Axis.ts +++ b/src/coord/Axis.ts @@ -28,7 +28,7 @@ import Scale from '../scale/Scale'; import { DimensionName, ScaleDataValue, ScaleTick } from '../util/types'; import OrdinalScale from '../scale/Ordinal'; import Model from '../model/Model'; -import { AxisBaseOption, OptionAxisType } from './axisCommonTypes'; +import { AxisBaseOption, CategoryAxisBaseOption, OptionAxisType } from './axisCommonTypes'; import { AxisBaseModel } from './AxisBaseModel'; const NORMALIZED_EXTENT = [0, 1] as [number, number]; @@ -63,7 +63,7 @@ class Axis { // Injected outside model: AxisBaseModel; - onBand: AxisBaseOption['boundaryGap'] = false; + onBand: CategoryAxisBaseOption['boundaryGap'] = false; inverse: AxisBaseOption['inverse'] = false; diff --git a/src/coord/AxisBaseModel.ts b/src/coord/AxisBaseModel.ts index 18cd29a292..9b482f0cb0 100644 --- a/src/coord/AxisBaseModel.ts +++ b/src/coord/AxisBaseModel.ts @@ -20,16 +20,16 @@ /** * Base Axis Model for xAxis, yAxis, angleAxis, radiusAxis. singleAxis */ -import { AxisBaseOption } from './axisCommonTypes'; +import { AxisBaseOptionCommon } from './axisCommonTypes'; import ComponentModel from '../model/Component'; import { AxisModelCommonMixin } from './axisModelCommonMixin'; import { AxisModelExtendedInCreator } from './axisModelCreator'; import Axis from './Axis'; -export interface AxisBaseModel +export interface AxisBaseModel extends ComponentModel, AxisModelCommonMixin, - AxisModelExtendedInCreator { + AxisModelExtendedInCreator { axis: Axis } \ No newline at end of file diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 9d9bf1117a..3fe8999d98 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -20,16 +20,15 @@ import { TextCommonOption, LineStyleOption, OrdinalRawValue, ZRColor, AreaStyleOption, ComponentOption, ColorString, - AnimationOptionMixin, Dictionary, ScaleDataValue + AnimationOptionMixin, Dictionary, ScaleDataValue, CommonAxisPointerOption } from '../util/types'; export const AXIS_TYPES = {value: 1, category: 1, time: 1, log: 1} as const; export type OptionAxisType = keyof typeof AXIS_TYPES; - -export interface AxisBaseOption extends ComponentOption, - AnimationOptionMixin { // Support transition animation +export interface AxisBaseOptionCommon extends ComponentOption, + AnimationOptionMixin { type?: OptionAxisType; show?: boolean; // Inverse the axis. @@ -55,21 +54,16 @@ export interface AxisBaseOption extends ComponentOption, show?: boolean; }; - axisPointer?: any; // FIXME:TS axisPointerOption type? + axisLabel?: AxisLabelBaseOption; + + axisPointer?: CommonAxisPointerOption; axisLine?: AxisLineOption; axisTick?: AxisTickOption; - axisLabel?: AxisLabelOption; minorTick?: MinorTickOption; splitLine?: SplitLineOption; minorSplitLine?: MinorSplitLineOption; splitArea?: SplitAreaOption; - // The gap at both ends of the axis. - // For category axis: boolean. - // For value axis: [GAP, GAP], where - // `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`) - boundaryGap?: boolean | [number | string, number | string]; - // Min value of the axis. can be: // + ScaleDataValue // + 'dataMin': use the min value in data. @@ -85,43 +79,74 @@ export interface AxisBaseOption extends ComponentOption, // + `true`: the extent do not consider value 0. scale?: boolean; +} - // -------------------------------------------- - // [Properties below only for 'category' axis]: - - // Set false to faster category collection. - // Only usefull in the case like: category is - // ['2012-01-01', '2012-01-02', ...], where the input - // data has been ensured not duplicate and is large data. - // null means "auto": - // if axis.data provided, do not deduplication, - // else do deduplication. - deduplication?: boolean; - data?: (OrdinalRawValue | { - value: OrdinalRawValue; - textStyle?: TextCommonOption; - })[]; - - - // ------------------------------------------------------ - // [Properties below only for 'value'/'log'/'time' axes]: - - // AxisTick and axisLabel and splitLine are caculated based on splitNumber. +interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon { + /* + * The gap at both ends of the axis. + * [GAP, GAP], where + * `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`) + */ + boundaryGap?: [number | string, number | string] + + /** + * AxisTick and axisLabel and splitLine are caculated based on splitNumber. + */ splitNumber?: number; - // Interval specifies the span of the ticks is mandatorily. + /** + * Interval specifies the span of the ticks is mandatorily. + */ interval?: number; - // Specify min interval when auto calculate tick interval. + /** + * Specify min interval when auto calculate tick interval. + */ minInterval?: number; - // Specify max interval when auto calculate tick interval. + /** + * Specify max interval when auto calculate tick interval. + */ maxInterval?: number; +} +export interface CategoryAxisBaseOption extends AxisBaseOptionCommon { + type?: 'category'; + boundaryGap?: boolean + axisLabel?: AxisLabelOption<'category'> & { + interval?: 'auto' | number | ((index: number, value: string) => boolean) + }; + data?: (OrdinalRawValue | { + value: OrdinalRawValue; + textStyle?: TextCommonOption; + })[]; + /* + * Set false to faster category collection. + * Only usefull in the case like: category is + * ['2012-01-01', '2012-01-02', ...], where the input + * data has been ensured not duplicate and is large data. + * null means "auto": + * if axis.data provided, do not deduplication, + * else do deduplication. + */ + deduplication?: boolean; - // --------------------------------------- - // [Properties below only for 'log' axis]: - + axisTick?: AxisBaseOptionCommon['axisTick'] & { + // If tick is align with label when boundaryGap is true + alignWithLabel?: boolean, + interval?: 'auto' | number | ((index: number, value: string) => boolean) + } +} +export interface ValueAxisBaseOption extends NumericAxisBaseOptionCommon { + type?: 'value'; + axisLabel?: AxisLabelOption<'value'>; +} +export interface LogAxisBaseOption extends NumericAxisBaseOptionCommon { + type?: 'log'; + axisLabel?: AxisLabelOption<'log'>; logBase?: number; } - +export interface TimeAxisBaseOption extends NumericAxisBaseOptionCommon { + type?: 'time'; + axisLabel?: AxisLabelOption<'time'>; +} interface AxisNameTextStyleOption extends TextCommonOption { rich?: Dictionary } @@ -147,15 +172,13 @@ interface AxisTickOption { // -------------------------------------------- // [Properties below only for 'category' axis]: - - // If tick is align with label when boundaryGap is true - alignWithLabel?: boolean, - interval?: 'auto' | number | ((index: number, value: string) => boolean) } -export type AxisLabelFormatterOption = string | ((value: OrdinalRawValue | number, index: number) => string); +type AxisLabelValueFormatter = (value: number, index: number) => string; +type AxisLabelCategoryFormatter = (value: string, index: number) => string; -type TimeAxisLabelUnitFormatter = AxisLabelFormatterOption | string[]; +// export type AxisLabelFormatterOption = string | ((value: OrdinalRawValue | number, index: number) => string); +type TimeAxisLabelUnitFormatter = AxisLabelValueFormatter | string[] | string; export type TimeAxisLabelFormatterOption = string | ((value: number, index: number, extra: {level: number}) => string) @@ -171,7 +194,14 @@ export type TimeAxisLabelFormatterOption = string inherit?: boolean }; -interface AxisLabelOption extends Omit { +type LabelFormatters = { + value: AxisLabelValueFormatter | string + log: AxisLabelValueFormatter | string + category: AxisLabelCategoryFormatter | string + time: TimeAxisLabelFormatterOption +}; + +interface AxisLabelBaseOption extends Omit { show?: boolean, // Whether axisLabel is inside the grid or outside the grid. inside?: boolean, @@ -181,18 +211,13 @@ interface AxisLabelOption extends Omit { // true | false | null/undefined (auto) showMaxLabel?: boolean, margin?: number, - // value is supposed to be OptionDataPrimitive but for time axis, it is time stamp. - formatter?: AxisLabelFormatterOption | TimeAxisLabelFormatterOption, - - // -------------------------------------------- - // [Properties below only for 'category' axis]: - - interval?: 'auto' | number | ((index: number, value: string) => boolean) + rich?: Dictionary // Color can be callback color?: ColorString | ((value?: string | number, index?: number) => ColorString) - - rich?: Dictionary +} +interface AxisLabelOption extends AxisLabelBaseOption { + formatter?: LabelFormatters[TType] } interface MinorTickOption { @@ -220,3 +245,7 @@ interface SplitAreaOption { // colors will display in turn areaStyle?: AreaStyleOption } + + +export type AxisBaseOption = ValueAxisBaseOption | LogAxisBaseOption + | CategoryAxisBaseOption | TimeAxisBaseOption | AxisBaseOptionCommon; diff --git a/src/coord/axisHelper.ts b/src/coord/axisHelper.ts index d058db3ad1..53a60b6f5b 100644 --- a/src/coord/axisHelper.ts +++ b/src/coord/axisHelper.ts @@ -33,7 +33,13 @@ import Model from '../model/Model'; import { AxisBaseModel } from './AxisBaseModel'; import LogScale from '../scale/Log'; import Axis from './Axis'; -import { AxisBaseOption, TimeAxisLabelFormatterOption } from './axisCommonTypes'; +import { + AxisBaseOption, + CategoryAxisBaseOption, + LogAxisBaseOption, + TimeAxisLabelFormatterOption, + ValueAxisBaseOption +} from './axisCommonTypes'; import type CartesianAxisModel from './cartesian/AxisModel'; import SeriesData from '../data/SeriesData'; import { getStackedDimension } from '../data/helper/dataStackHelper'; @@ -143,7 +149,8 @@ function adjustScaleForOverflow( // Precondition of calling this method: // The scale extent has been initailized using series data extent via // `scale.setExtent` or `scale.unionExtentFromData`; -export function niceScaleExtent(scale: Scale, model: AxisBaseModel) { +export function niceScaleExtent(scale: Scale, inModel: AxisBaseModel) { + const model = inModel as AxisBaseModel; const extentInfo = getScaleExtent(scale, model); const extent = extentInfo.extent; const splitNumber = model.get('splitNumber'); @@ -221,7 +228,8 @@ export function ifAxisCrossZero(axis: Axis) { * return: {string} label string. */ export function makeLabelFormatter(axis: Axis): (tick: ScaleTick, idx?: number) => string { - const labelFormatter = axis.getLabelModel().get('formatter'); + const labelFormatter = (axis.getLabelModel() as Model) + .get('formatter'); const categoryTickStart = axis.type === 'category' ? axis.scale.getExtent()[0] : null; if (axis.scale.type === 'time') { @@ -263,7 +271,7 @@ export function makeLabelFormatter(axis: Axis): (tick: ScaleTick, idx?: number) } : null ); }; - })(labelFormatter); + })(labelFormatter as (...args: any[]) => string); } else { return function (tick: ScaleTick) { @@ -347,7 +355,7 @@ function rotateTextRect(textRect: RectLike, rotate: number) { * @return {number|String} Can be null|'auto'|number|function */ export function getOptionCategoryInterval(model: Model) { - const interval = model.get('interval'); + const interval = (model as Model).get('interval'); return interval == null ? 'auto' : interval; } diff --git a/src/coord/axisModelCreator.ts b/src/coord/axisModelCreator.ts index 5d275ee459..f7d80720cb 100644 --- a/src/coord/axisModelCreator.ts +++ b/src/coord/axisModelCreator.ts @@ -26,7 +26,7 @@ import { } from '../util/layout'; import OrdinalMeta from '../data/OrdinalMeta'; import { DimensionName, BoxLayoutOptionMixin, OrdinalRawValue } from '../util/types'; -import { AxisBaseOption, AXIS_TYPES } from './axisCommonTypes'; +import { AxisBaseOption, AXIS_TYPES, CategoryAxisBaseOption } from './axisCommonTypes'; import GlobalModel from '../model/Global'; import { each, merge } from 'zrender/src/core/util'; import { EChartsExtensionInstallRegisters } from '../extension'; @@ -34,8 +34,8 @@ import { EChartsExtensionInstallRegisters } from '../extension'; type Constructor = new (...args: any[]) => T; -export interface AxisModelExtendedInCreator { - getCategories(rawData?: boolean): OrdinalRawValue[] | Opt['data'] +export interface AxisModelExtendedInCreator { + getCategories(rawData?: boolean): OrdinalRawValue[] | CategoryAxisBaseOption['data'] getOrdinalMeta(): OrdinalMeta } @@ -60,7 +60,7 @@ export default function axisModelCreator< extraDefaultOption, true ); - class AxisModel extends BaseAxisModelClass implements AxisModelExtendedInCreator { + class AxisModel extends BaseAxisModelClass implements AxisModelExtendedInCreator { static type = axisName + 'Axis.' + axisType; type = axisName + 'Axis.' + axisType; @@ -97,13 +97,13 @@ export default function axisModelCreator< * Should not be called before all of 'getInitailData' finished. * Because categories are collected during initializing data. */ - getCategories(rawData?: boolean): OrdinalRawValue[] | AxisBaseOption['data'] { + getCategories(rawData?: boolean): OrdinalRawValue[] | CategoryAxisBaseOption['data'] { const option = this.option; // FIXME // warning if called before all of 'getInitailData' finished. if (option.type === 'category') { if (rawData) { - return option.data as AxisBaseOption['data']; + return (option as CategoryAxisBaseOption).data; } return this.__ordinalMeta.categories; } @@ -125,5 +125,5 @@ export default function axisModelCreator< function getAxisType(option: AxisBaseOption) { // Default axis with data is category axis - return option.type || (option.data ? 'category' : 'value'); + return option.type || ((option as CategoryAxisBaseOption).data ? 'category' : 'value'); } diff --git a/src/coord/cartesian/AxisModel.ts b/src/coord/cartesian/AxisModel.ts index 076b1c142f..726e0fa798 100644 --- a/src/coord/cartesian/AxisModel.ts +++ b/src/coord/cartesian/AxisModel.ts @@ -31,21 +31,21 @@ import { SINGLE_REFERRING } from '../../util/model'; export type CartesianAxisPosition = 'top' | 'bottom' | 'left' | 'right'; -export interface CartesianAxisOption extends AxisBaseOption { +export type CartesianAxisOption = AxisBaseOption & { gridIndex?: number; gridId?: string; position?: CartesianAxisPosition; // Offset is for multiple axis on the same position. offset?: number; categorySortInfo?: OrdinalSortInfo; -} +}; -export interface XAXisOption extends CartesianAxisOption { +export type XAXisOption = CartesianAxisOption & { mainType?: 'xAxis' -} -export interface YAXisOption extends CartesianAxisOption { +}; +export type YAXisOption = CartesianAxisOption & { mainType?: 'yAxis' -} +}; export class CartesianAxisModel extends ComponentModel implements AxisBaseModel { @@ -60,7 +60,7 @@ export class CartesianAxisModel extends ComponentModel } export interface CartesianAxisModel extends AxisModelCommonMixin, - AxisModelExtendedInCreator {} + AxisModelExtendedInCreator {} zrUtil.mixin(CartesianAxisModel, AxisModelCommonMixin); diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 6eef23eac1..aba0b732c0 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -47,6 +47,8 @@ import { ScaleDataValue } from '../../util/types'; import SeriesData from '../../data/SeriesData'; import OrdinalScale from '../../scale/Ordinal'; import { isCartesian2DSeries, findAxisModels } from './cartesianAxisHelper'; +import { CategoryAxisBaseOption } from '../axisCommonTypes'; +import { AxisBaseModel } from '../AxisBaseModel'; type Cartesian2DDimensionName = 'x' | 'y'; @@ -388,7 +390,7 @@ class Grid implements CoordinateSystemMaster { ); const isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.onBand = isCategory && (axisModel as AxisBaseModel).get('boundaryGap'); axis.inverse = axisModel.get('inverse'); // Inject axis into axisModel diff --git a/src/coord/parallel/AxisModel.ts b/src/coord/parallel/AxisModel.ts index 31beb29f8a..877dbaec85 100644 --- a/src/coord/parallel/AxisModel.ts +++ b/src/coord/parallel/AxisModel.ts @@ -40,7 +40,7 @@ export type ParallelAreaSelectStyleProps = Pick { @@ -140,7 +140,7 @@ class ParallelAxisModel extends ComponentModel { } interface ParallelAxisModel extends AxisModelCommonMixin, - AxisModelExtendedInCreator {} + AxisModelExtendedInCreator {} zrUtil.mixin(ParallelAxisModel, AxisModelCommonMixin); diff --git a/src/coord/parallel/Parallel.ts b/src/coord/parallel/Parallel.ts index e22cf9a8d7..f8c472dad1 100644 --- a/src/coord/parallel/Parallel.ts +++ b/src/coord/parallel/Parallel.ts @@ -38,6 +38,8 @@ import { Dictionary, DimensionName, ScaleDataValue } from '../../util/types'; import { CoordinateSystem, CoordinateSystemMaster } from '../CoordinateSystem'; import ParallelAxisModel, { ParallelActiveState } from './AxisModel'; import SeriesData from '../../data/SeriesData'; +import { AxisBaseModel } from '../AxisBaseModel'; +import { CategoryAxisBaseOption } from '../axisCommonTypes'; const each = zrUtil.each; const mathMin = Math.min; @@ -131,7 +133,8 @@ class Parallel implements CoordinateSystemMaster, CoordinateSystem { )); const isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.onBand = isCategory + && (axisModel as AxisBaseModel).get('boundaryGap'); axis.inverse = axisModel.get('inverse'); // Injection diff --git a/src/coord/polar/AxisModel.ts b/src/coord/polar/AxisModel.ts index 2afbc3c11e..af2414a673 100644 --- a/src/coord/polar/AxisModel.ts +++ b/src/coord/polar/AxisModel.ts @@ -27,7 +27,7 @@ import RadiusAxis from './RadiusAxis'; import { AxisBaseModel } from '../AxisBaseModel'; import { SINGLE_REFERRING } from '../../util/model'; -export interface AngleAxisOption extends AxisBaseOption { +export type AngleAxisOption = AxisBaseOption & { mainType?: 'angleAxis'; /** * Index of host polar component @@ -41,12 +41,10 @@ export interface AngleAxisOption extends AxisBaseOption { startAngle?: number; clockwise?: boolean; - splitNumber?: number; - axisLabel?: AxisBaseOption['axisLabel'] -} +}; -export interface RadiusAxisOption extends AxisBaseOption { +export type RadiusAxisOption = AxisBaseOption & { mainType?: 'radiusAxis'; /** * Index of host polar component @@ -56,7 +54,7 @@ export interface RadiusAxisOption extends AxisBaseOption { * Id of host polar component */ polarId?: string; -} +}; type PolarAxisOption = AngleAxisOption | RadiusAxisOption; @@ -72,7 +70,7 @@ class PolarAxisModel extends Compon } interface PolarAxisModel - extends AxisModelCommonMixin, AxisModelExtendedInCreator {} + extends AxisModelCommonMixin, AxisModelExtendedInCreator {} zrUtil.mixin(PolarAxisModel, AxisModelCommonMixin); diff --git a/src/coord/polar/polarCreator.ts b/src/coord/polar/polarCreator.ts index 69feeca425..4df310c1d4 100644 --- a/src/coord/polar/polarCreator.ts +++ b/src/coord/polar/polarCreator.ts @@ -38,6 +38,8 @@ import { PolarAxisModel, AngleAxisModel, RadiusAxisModel } from './AxisModel'; import SeriesModel from '../../model/Series'; import { SeriesOption } from '../../util/types'; import { SINGLE_REFERRING } from '../../util/model'; +import { AxisBaseModel } from '../AxisBaseModel'; +import { CategoryAxisBaseOption } from '../axisCommonTypes'; /** * Resize method bound to the polar @@ -115,7 +117,8 @@ function isAngleAxisModel(axisModel: AngleAxisModel | PolarAxisModel): axisModel function setAxis(axis: RadiusAxis | AngleAxis, axisModel: PolarAxisModel) { axis.type = axisModel.get('type'); axis.scale = createScaleByModel(axisModel); - axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category'; + axis.onBand = (axisModel as AxisBaseModel).get('boundaryGap') + && axis.type === 'category'; axis.inverse = axisModel.get('inverse'); if (isAngleAxisModel(axisModel)) { diff --git a/src/coord/radar/RadarModel.ts b/src/coord/radar/RadarModel.ts index 1144ab07c8..cdcd3e8181 100644 --- a/src/coord/radar/RadarModel.ts +++ b/src/coord/radar/RadarModel.ts @@ -28,7 +28,7 @@ import { LabelOption, ColorString } from '../../util/types'; -import { AxisBaseOption } from '../axisCommonTypes'; +import { AxisBaseOption, CategoryAxisBaseOption, ValueAxisBaseOption } from '../axisCommonTypes'; import { AxisBaseModel } from '../AxisBaseModel'; import Radar from './Radar'; import {CoordinateSystemHostModel} from '../../coord/CoordinateSystem'; @@ -79,15 +79,16 @@ export interface RadarOption extends ComponentOption, CircleLayoutOptionMixin { scale?: boolean splitNumber?: number - boundaryGap?: AxisBaseOption['boundaryGap'] + boundaryGap?: CategoryAxisBaseOption['boundaryGap'] + | ValueAxisBaseOption['boundaryGap'] indicator?: RadarIndicatorOption[] } -export interface InnerIndicatorAxisOption extends AxisBaseOption { +export type InnerIndicatorAxisOption = AxisBaseOption & { // TODO Use type? // axisType?: 'value' | 'log' -} +}; class RadarModel extends ComponentModel implements CoordinateSystemHostModel { static readonly type = 'radar'; diff --git a/src/coord/scaleRawExtentInfo.ts b/src/coord/scaleRawExtentInfo.ts index 5a0abb67d2..45d2dc7d43 100644 --- a/src/coord/scaleRawExtentInfo.ts +++ b/src/coord/scaleRawExtentInfo.ts @@ -21,7 +21,7 @@ import { assert, isArray, eqNaN, isFunction } from 'zrender/src/core/util'; import Scale from '../scale/Scale'; import { AxisBaseModel } from './AxisBaseModel'; import { parsePercent } from 'zrender/src/contain/text'; -import { AxisBaseOption } from './axisCommonTypes'; +import { AxisBaseOption, CategoryAxisBaseOption } from './axisCommonTypes'; import { ScaleDataValue } from '../util/types'; @@ -129,7 +129,7 @@ export class ScaleRawExtentInfo { this._axisDataLen = model.getCategories().length; } else { - const boundaryGap = model.get('boundaryGap'); + const boundaryGap = (model as AxisBaseModel).get('boundaryGap'); const boundaryGapArr = isArray(boundaryGap) ? boundaryGap : [boundaryGap || 0, boundaryGap || 0]; diff --git a/src/coord/single/AxisModel.ts b/src/coord/single/AxisModel.ts index 7f761387b9..bcd85268fd 100644 --- a/src/coord/single/AxisModel.ts +++ b/src/coord/single/AxisModel.ts @@ -29,11 +29,11 @@ import { mixin } from 'zrender/src/core/util'; export type SingleAxisPosition = 'top' | 'bottom' | 'left' | 'right'; -export interface SingleAxisOption extends AxisBaseOption, BoxLayoutOptionMixin { +export type SingleAxisOption = AxisBaseOption & BoxLayoutOptionMixin & { mainType?: 'singleAxis' position?: SingleAxisPosition orient?: LayoutOrient -} +}; class SingleAxisModel extends ComponentModel implements AxisBaseModel { @@ -102,7 +102,7 @@ class SingleAxisModel extends ComponentModel } interface SingleAxisModel extends AxisModelCommonMixin, - AxisModelExtendedInCreator {} + AxisModelExtendedInCreator {} mixin(SingleAxisModel, AxisModelCommonMixin.prototype); diff --git a/src/coord/single/Single.ts b/src/coord/single/Single.ts index 5ad403169e..4632190e41 100644 --- a/src/coord/single/Single.ts +++ b/src/coord/single/Single.ts @@ -32,6 +32,8 @@ import BoundingRect from 'zrender/src/core/BoundingRect'; import SingleAxisModel from './AxisModel'; import { ParsedModelFinder, ParsedModelFinderKnown } from '../../util/model'; import { ScaleDataValue } from '../../util/types'; +import { AxisBaseModel } from '../AxisBaseModel'; +import { CategoryAxisBaseOption } from '../axisCommonTypes'; export const singleDimensions = ['single']; /** @@ -80,7 +82,7 @@ class Single implements CoordinateSystem, CoordinateSystemMaster { ); const isCategory = axis.type === 'category'; - axis.onBand = isCategory && axisModel.get('boundaryGap'); + axis.onBand = isCategory && (axisModel as AxisBaseModel).get('boundaryGap'); axis.inverse = axisModel.get('inverse'); axis.orient = axisModel.get('orient'); diff --git a/src/scale/Ordinal.ts b/src/scale/Ordinal.ts index 7f23c2d4cc..01139da56c 100644 --- a/src/scale/Ordinal.ts +++ b/src/scale/Ordinal.ts @@ -36,11 +36,11 @@ import { OrdinalScaleTick, ScaleTick } from '../util/types'; -import { AxisBaseOption } from '../coord/axisCommonTypes'; +import { CategoryAxisBaseOption } from '../coord/axisCommonTypes'; import { isArray, map, isObject } from 'zrender/src/core/util'; type OrdinalScaleSetting = { - ordinalMeta?: OrdinalMeta | AxisBaseOption['data']; + ordinalMeta?: OrdinalMeta | CategoryAxisBaseOption['data']; extent?: [number, number]; }; From 97358af3b8a18b2b7b8e3a89b17ef2f2d9314558 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Wed, 8 Sep 2021 13:55:43 +0800 Subject: [PATCH 23/40] test(polar): update visual test --- src/chart/bar/BarView.ts | 1 - test/bar-polar-basic.html | 103 +++++++++++++++++------------ test/runTest/actions/__meta__.json | 1 + 3 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index fba170ed47..dce754a46c 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -238,7 +238,6 @@ class BarView extends ChartView { .add(function (dataIndex) { const itemModel = data.getItemModel(dataIndex); const layout = getLayout[coord.type](data, dataIndex, itemModel); - // console.log('get', layout.clockwise); if (drawBackground) { createBackground(dataIndex); diff --git a/test/bar-polar-basic.html b/test/bar-polar-basic.html index aefe933fa9..d799c3fbbf 100644 --- a/test/bar-polar-basic.html +++ b/test/bar-polar-basic.html @@ -27,62 +27,79 @@ -

click axis labe should console log

-
+

click axis label should console log

+

click update button, sectors should be in the same order

+ +
+

clockwise: true

+
+
+
+

clockwise: false

+
+
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 28341e7bd1..5e26a0a452 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -21,6 +21,7 @@ "bar-label-rotation": 2, "bar-large": 2, "bar-overflow-time-plot": 3, + "bar-polar-basic": 1, "bar-polar-multi-series": 1, "bar-polar-multi-series-radial": 1, "bar-polar-null-data-radial": 1, From fcb66e2f191ad4d8c0fc0eaf559a108642dfa2fd Mon Sep 17 00:00:00 2001 From: pissang Date: Wed, 8 Sep 2021 17:01:21 +0800 Subject: [PATCH 24/40] fix(type): fix other states types may be any. --- src/chart/bar/BarSeries.ts | 14 +++++-- src/chart/bar/BaseBarSeries.ts | 4 +- .../effectScatter/EffectScatterSeries.ts | 14 +++++-- src/chart/funnel/FunnelSeries.ts | 11 +++-- src/chart/gauge/GaugeSeries.ts | 11 +++-- src/chart/graph/GraphSeries.ts | 12 +++--- src/chart/heatmap/HeatmapSeries.ts | 11 +++-- src/chart/helper/LineDraw.ts | 6 ++- src/chart/line/LineSeries.ts | 6 +-- src/chart/lines/LinesSeries.ts | 13 ++++-- src/chart/map/MapSeries.ts | 7 ++-- src/chart/parallel/ParallelSeries.ts | 12 ++++-- src/chart/parallel/ParallelView.ts | 4 +- src/chart/pie/PieSeries.ts | 1 - src/chart/radar/RadarSeries.ts | 11 +++-- src/chart/scatter/ScatterSeries.ts | 7 ++-- src/chart/sunburst/SunburstSeries.ts | 9 ++-- src/chart/tree/TreeSeries.ts | 10 ++--- src/component/marker/MarkAreaModel.ts | 8 ++-- src/component/marker/MarkLineModel.ts | 9 ++-- src/component/marker/MarkPointModel.ts | 7 ++-- src/coord/axisCommonTypes.ts | 3 -- src/coord/geo/GeoModel.ts | 7 ++-- src/label/labelGuideHelper.ts | 2 +- src/label/labelStyle.ts | 2 +- src/util/types.ts | 42 +++++++++++-------- test/types/basic.ts | 7 +++- 27 files changed, 158 insertions(+), 92 deletions(-) diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts index 8c97a8b616..57323c5368 100644 --- a/src/chart/bar/BarSeries.ts +++ b/src/chart/bar/BarSeries.ts @@ -26,7 +26,8 @@ import { OptionDataItemObject, SeriesSamplingOptionMixin, SeriesLabelOption, - SeriesEncodeOptionMixin + SeriesEncodeOptionMixin, + DefaultStatesMixinEmpasis } from '../../util/types'; import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; import createSeriesData from '../helper/createSeriesData'; @@ -46,16 +47,21 @@ export interface BarStateOption { label?: BarSeriesLabelOption } +interface BarStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} + export interface BarItemStyleOption extends ItemStyleOption { // Border radius is not supported for bar on polar borderRadius?: number | number[] } -export interface BarDataItemOption extends BarStateOption, StatesOptionMixin, +export interface BarDataItemOption extends BarStateOption, + StatesOptionMixin, OptionDataItemObject { cursor?: string } -export interface BarSeriesOption extends BaseBarSeriesOption, BarStateOption, +export interface BarSeriesOption extends BaseBarSeriesOption, BarStateOption, SeriesStackOptionMixin, SeriesSamplingOptionMixin, SeriesEncodeOptionMixin { type?: 'bar' @@ -151,7 +157,7 @@ class BarSeriesModel extends BaseBarSeriesModel { }, realtimeSort: false - }); + } as BarSeriesOption); } diff --git a/src/chart/bar/BaseBarSeries.ts b/src/chart/bar/BaseBarSeries.ts index d4c3fa5d19..e94e53d7e6 100644 --- a/src/chart/bar/BaseBarSeries.ts +++ b/src/chart/bar/BaseBarSeries.ts @@ -24,14 +24,14 @@ import { SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, ScaleDataValue, - DefaultExtraStateOpts + DefaultStatesMixin } from '../../util/types'; import GlobalModel from '../../model/Global'; import Cartesian2D from '../../coord/cartesian/Cartesian2D'; import SeriesData from '../../data/SeriesData'; -export interface BaseBarSeriesOption +export interface BaseBarSeriesOption extends SeriesOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin { diff --git a/src/chart/effectScatter/EffectScatterSeries.ts b/src/chart/effectScatter/EffectScatterSeries.ts index 9632e400bf..8e936b3eea 100644 --- a/src/chart/effectScatter/EffectScatterSeries.ts +++ b/src/chart/effectScatter/EffectScatterSeries.ts @@ -32,7 +32,8 @@ import { SeriesLabelOption, StatesOptionMixin, SeriesEncodeOptionMixin, - CallbackDataParams + CallbackDataParams, + DefaultEmphasisFocus } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -41,6 +42,12 @@ import { BrushCommonSelectorsForSeries } from '../../component/brush/selector'; type ScatterDataValue = OptionDataValue | OptionDataValue[]; +interface EffectScatterStatesOptionMixin { + emphasis?: { + focus?: DefaultEmphasisFocus + scale?: boolean + } +} export interface EffectScatterStateOption { itemStyle?: ItemStyleOption label?: SeriesLabelOption @@ -48,7 +55,7 @@ export interface EffectScatterStateOption { export interface EffectScatterDataItemOption extends SymbolOptionMixin, EffectScatterStateOption, - StatesOptionMixin { + StatesOptionMixin { name?: string value?: ScatterDataValue @@ -56,7 +63,8 @@ export interface EffectScatterDataItemOption extends SymbolOptionMixin, rippleEffect?: SymbolDrawItemModelOption['rippleEffect'] } -export interface EffectScatterSeriesOption extends SeriesOption, EffectScatterStateOption, +export interface EffectScatterSeriesOption + extends SeriesOption, EffectScatterStateOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SymbolOptionMixin, SeriesEncodeOptionMixin { diff --git a/src/chart/funnel/FunnelSeries.ts b/src/chart/funnel/FunnelSeries.ts index 6abe848f0a..8ac6fcf4c2 100644 --- a/src/chart/funnel/FunnelSeries.ts +++ b/src/chart/funnel/FunnelSeries.ts @@ -36,7 +36,8 @@ import { LayoutOrient, VerticalAlign, SeriesLabelOption, - SeriesEncodeOptionMixin + SeriesEncodeOptionMixin, + DefaultStatesMixinEmpasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -46,6 +47,10 @@ type FunnelLabelOption = Omit & { | 'outer' | 'inner' | 'center' | 'rightTop' | 'rightBottom' | 'leftTop' | 'leftBottom' }; +interface FunnelStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} + export interface FunnelStateOption { itemStyle?: ItemStyleOption label?: FunnelLabelOption @@ -53,7 +58,7 @@ export interface FunnelStateOption { } export interface FunnelDataItemOption - extends FunnelStateOption, StatesOptionMixin, + extends FunnelStateOption, StatesOptionMixin, OptionDataItemObject { itemStyle?: ItemStyleOption & { @@ -62,7 +67,7 @@ export interface FunnelDataItemOption } } -export interface FunnelSeriesOption extends SeriesOption, FunnelStateOption, +export interface FunnelSeriesOption extends SeriesOption, FunnelStateOption, BoxLayoutOptionMixin, SeriesEncodeOptionMixin { type?: 'funnel' diff --git a/src/chart/gauge/GaugeSeries.ts b/src/chart/gauge/GaugeSeries.ts index 729af9463d..b861bf708c 100644 --- a/src/chart/gauge/GaugeSeries.ts +++ b/src/chart/gauge/GaugeSeries.ts @@ -28,7 +28,8 @@ import { ItemStyleOption, OptionDataValueNumeric, StatesOptionMixin, - SeriesEncodeOptionMixin + SeriesEncodeOptionMixin, + DefaultStatesMixinEmpasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -102,11 +103,15 @@ interface DetailOption extends LabelOption { valueAnimation?: boolean } +interface GaugeStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} export interface GaugeStateOption { itemStyle?: ItemStyleOption } -export interface GaugeDataItemOption extends GaugeStateOption, StatesOptionMixin { +export interface GaugeDataItemOption extends GaugeStateOption, + StatesOptionMixin { name?: string value?: OptionDataValueNumeric pointer?: PointerOption @@ -114,7 +119,7 @@ export interface GaugeDataItemOption extends GaugeStateOption, StatesOptionMixin title?: TitleOption detail?: DetailOption } -export interface GaugeSeriesOption extends SeriesOption, GaugeStateOption, +export interface GaugeSeriesOption extends SeriesOption, GaugeStateOption, CircleLayoutOptionMixin, SeriesEncodeOptionMixin { type?: 'gauge' diff --git a/src/chart/graph/GraphSeries.ts b/src/chart/graph/GraphSeries.ts index 42b833d9c9..eb034015d9 100644 --- a/src/chart/graph/GraphSeries.ts +++ b/src/chart/graph/GraphSeries.ts @@ -71,16 +71,16 @@ export interface GraphNodeStateOption { interface ExtraEmphasisState { focus?: DefaultEmphasisFocus | 'adjacency' } -interface ExtraNodeStateOption { +interface GraphNodeStatesMixin { emphasis?: ExtraEmphasisState } -interface ExtraEdgeStateOption { +interface GraphEdgeStatesMixin { emphasis?: ExtraEmphasisState } export interface GraphNodeItemOption extends SymbolOptionMixin, GraphNodeStateOption, - GraphNodeStateOption, StatesOptionMixin { + GraphNodeStateOption, StatesOptionMixin { id?: string name?: string @@ -114,7 +114,7 @@ export interface GraphEdgeStateOption { } export interface GraphEdgeItemOption extends GraphEdgeStateOption, - StatesOptionMixin, + StatesOptionMixin, GraphEdgeItemObject { value?: number @@ -130,13 +130,13 @@ export interface GraphEdgeItemOption extends } export interface GraphCategoryItemOption extends SymbolOptionMixin, - GraphNodeStateOption, StatesOptionMixin { + GraphNodeStateOption, StatesOptionMixin { name?: string value?: OptionDataValue } -export interface GraphSeriesOption extends SeriesOption, +export interface GraphSeriesOption extends SeriesOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SymbolOptionMixin, diff --git a/src/chart/heatmap/HeatmapSeries.ts b/src/chart/heatmap/HeatmapSeries.ts index 80fbb72dd4..3a785697d0 100644 --- a/src/chart/heatmap/HeatmapSeries.ts +++ b/src/chart/heatmap/HeatmapSeries.ts @@ -29,7 +29,8 @@ import { OptionDataValue, StatesOptionMixin, SeriesEncodeOptionMixin, - SeriesOnCalendarOptionMixin + SeriesOnCalendarOptionMixin, + DefaultStatesMixinEmpasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -45,11 +46,15 @@ export interface HeatmapStateOption { label?: SeriesLabelOption } -export interface HeatmapDataItemOption extends HeatmapStateOption, StatesOptionMixin { +interface FunnelStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} +export interface HeatmapDataItemOption extends HeatmapStateOption, + StatesOptionMixin { value: HeatmapDataValue } -export interface HeatmapSeriesOption extends SeriesOption, HeatmapStateOption, +export interface HeatmapSeriesOption extends SeriesOption, HeatmapStateOption, SeriesOnCartesianOptionMixin, SeriesOnGeoOptionMixin, SeriesOnCalendarOptionMixin, SeriesEncodeOptionMixin { type?: 'heatmap' diff --git a/src/chart/helper/LineDraw.ts b/src/chart/helper/LineDraw.ts index 60317bc7f1..5f5ff61f37 100644 --- a/src/chart/helper/LineDraw.ts +++ b/src/chart/helper/LineDraw.ts @@ -29,7 +29,8 @@ import { ZRStyleProps, StatesOptionMixin, DisplayState, - LabelOption + LabelOption, + StatesMixinBase } from '../../util/types'; import Displayable from 'zrender/src/graphic/Displayable'; import Model from '../../model/Model'; @@ -50,7 +51,8 @@ interface LineDrawStateOption { label?: LineLabelOption } -export interface LineDrawModelOption extends LineDrawStateOption, StatesOptionMixin { +export interface LineDrawModelOption extends LineDrawStateOption, + StatesOptionMixin { // If has effect effect?: { show?: boolean diff --git a/src/chart/line/LineSeries.ts b/src/chart/line/LineSeries.ts index 9114ee69f8..5c569e646a 100644 --- a/src/chart/line/LineSeries.ts +++ b/src/chart/line/LineSeries.ts @@ -45,7 +45,7 @@ import {LegendIconParams} from '../../component/legend/LegendModel'; type LineDataValue = OptionDataValue | OptionDataValue[]; -interface ExtraStateOption { +interface LineStateOptionMixin { emphasis?: { focus?: DefaultEmphasisFocus scale?: boolean @@ -59,7 +59,7 @@ export interface LineStateOption { } export interface LineDataItemOption extends SymbolOptionMixin, - LineStateOption, StatesOptionMixin { + LineStateOption, StatesOptionMixin { name?: string value?: LineDataValue @@ -70,7 +70,7 @@ export interface LineEndLabelOption extends SeriesLabelOption { } -export interface LineSeriesOption extends SeriesOption { +export interface LinesDataItemOption extends LinesStateOption, + StatesOptionMixin { name?: string fromName?: string @@ -105,8 +110,8 @@ export interface LinesDataItemOption extends LinesStateOption, StatesOptionMixin dimensions?: DimensionDefinitionLoose } -export interface LinesSeriesOption extends SeriesOption, LinesStateOption, - +export interface LinesSeriesOption + extends SeriesOption, LinesStateOption, SeriesOnCartesianOptionMixin, SeriesOnGeoOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesLargeOptionMixin { diff --git a/src/chart/map/MapSeries.ts b/src/chart/map/MapSeries.ts index 2081886e31..d146f113b8 100644 --- a/src/chart/map/MapSeries.ts +++ b/src/chart/map/MapSeries.ts @@ -32,7 +32,8 @@ import { ParsedValue, SeriesOnGeoOptionMixin, StatesOptionMixin, - SeriesLabelOption + SeriesLabelOption, + StatesMixinBase } from '../../util/types'; import { Dictionary } from 'zrender/src/core/types'; import GeoModel, { GeoCommonOptionMixin, GeoItemStyleOption } from '../../coord/geo/GeoModel'; @@ -48,7 +49,7 @@ export interface MapStateOption { itemStyle?: GeoItemStyleOption label?: SeriesLabelOption } -export interface MapDataItemOption extends MapStateOption, StatesOptionMixin, +export interface MapDataItemOption extends MapStateOption, StatesOptionMixin, OptionDataItemObject { cursor?: string } @@ -56,7 +57,7 @@ export interface MapDataItemOption extends MapStateOption, StatesOptionMixin, MapStateOption, + SeriesOption, MapStateOption, GeoCommonOptionMixin, // If `geoIndex` is not specified, a exclusive geo will be diff --git a/src/chart/parallel/ParallelSeries.ts b/src/chart/parallel/ParallelSeries.ts index c75ea4e8fd..4b44d79791 100644 --- a/src/chart/parallel/ParallelSeries.ts +++ b/src/chart/parallel/ParallelSeries.ts @@ -32,7 +32,8 @@ import { StatesOptionMixin, OptionEncodeValue, Dictionary, - OptionEncode + OptionEncode, + DefaultStatesMixinEmpasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -42,17 +43,20 @@ import ParallelModel from '../../coord/parallel/ParallelModel'; type ParallelSeriesDataValue = OptionDataValue[]; +interface ParallelStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} export interface ParallelStateOption { lineStyle?: LineStyleOption label?: SeriesLabelOption } -export interface ParallelSeriesDataItemOption extends ParallelStateOption, StatesOptionMixin { +export interface ParallelSeriesDataItemOption extends ParallelStateOption, + StatesOptionMixin { value?: ParallelSeriesDataValue[] } - export interface ParallelSeriesOption extends - SeriesOption, ParallelStateOption, + SeriesOption, ParallelStateOption, SeriesEncodeOptionMixin { type?: 'parallel'; diff --git a/src/chart/parallel/ParallelView.ts b/src/chart/parallel/ParallelView.ts index 1704b09c90..f3b478c401 100644 --- a/src/chart/parallel/ParallelView.ts +++ b/src/chart/parallel/ParallelView.ts @@ -172,7 +172,9 @@ function createLinePoints(data: SeriesData, dataIndex: number, dimensions: strin return points; } -function addEl(data: SeriesData, dataGroup: graphic.Group, dataIndex: number, dimensions: string[], coordSys: Parallel) { +function addEl( + data: SeriesData, dataGroup: graphic.Group, dataIndex: number, dimensions: string[], coordSys: Parallel +) { const points = createLinePoints(data, dataIndex, dimensions, coordSys); const line = new graphic.Polyline({ shape: {points: points}, diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts index b68726285e..de283ad04f 100644 --- a/src/chart/pie/PieSeries.ts +++ b/src/chart/pie/PieSeries.ts @@ -91,7 +91,6 @@ interface ExtraStateOption { export interface PieDataItemOption extends OptionDataItemObject, PieStateOption, StatesOptionMixin { - cursor?: string } export interface PieSeriesOption extends diff --git a/src/chart/radar/RadarSeries.ts b/src/chart/radar/RadarSeries.ts index ffc8ea47d1..25829dbc5a 100644 --- a/src/chart/radar/RadarSeries.ts +++ b/src/chart/radar/RadarSeries.ts @@ -32,7 +32,8 @@ import { StatesOptionMixin, OptionDataItemObject, SeriesEncodeOptionMixin, - CallbackDataParams + CallbackDataParams, + DefaultStatesMixinEmpasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -43,6 +44,9 @@ import { type RadarSeriesDataValue = OptionDataValue[]; +interface RadarStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} export interface RadarSeriesStateOption { lineStyle?: LineStyleOption areaStyle?: AreaStyleOption @@ -50,11 +54,12 @@ export interface RadarSeriesStateOption { itemStyle?: ItemStyleOption } export interface RadarSeriesDataItemOption extends SymbolOptionMixin, - RadarSeriesStateOption, StatesOptionMixin, + RadarSeriesStateOption, StatesOptionMixin, OptionDataItemObject { } -export interface RadarSeriesOption extends SeriesOption, RadarSeriesStateOption, +export interface RadarSeriesOption + extends SeriesOption, RadarSeriesStateOption, SymbolOptionMixin, SeriesEncodeOptionMixin { type?: 'radar' coordinateSystem?: 'radar' diff --git a/src/chart/scatter/ScatterSeries.ts b/src/chart/scatter/ScatterSeries.ts index 40c4c73256..f2b148202d 100644 --- a/src/chart/scatter/ScatterSeries.ts +++ b/src/chart/scatter/ScatterSeries.ts @@ -47,7 +47,7 @@ interface ScatterStateOption { label?: SeriesLabelOption } -interface ExtraStateOption { +interface ScatterStatesOptionMixin { emphasis?: { focus?: DefaultEmphasisFocus scale?: boolean @@ -55,11 +55,12 @@ interface ExtraStateOption { } export interface ScatterDataItemOption extends SymbolOptionMixin, - ScatterStateOption, StatesOptionMixin, + ScatterStateOption, StatesOptionMixin, OptionDataItemObject { } -export interface ScatterSeriesOption extends SeriesOption, ScatterStateOption, +export interface ScatterSeriesOption + extends SeriesOption, ScatterStateOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SeriesLargeOptionMixin, SeriesStackOptionMixin, diff --git a/src/chart/sunburst/SunburstSeries.ts b/src/chart/sunburst/SunburstSeries.ts index f53b7c3150..afbe542d91 100644 --- a/src/chart/sunburst/SunburstSeries.ts +++ b/src/chart/sunburst/SunburstSeries.ts @@ -65,7 +65,7 @@ interface SunburstDataParams extends CallbackDataParams { }[] } -interface ExtraStateOption { +interface SunburstStatesMixin { emphasis?: { focus?: DefaultEmphasisFocus | 'descendant' | 'ancestor' } @@ -77,7 +77,7 @@ export interface SunburstStateOption { } export interface SunburstSeriesNodeItemOption extends - SunburstStateOption, StatesOptionMixin, + SunburstStateOption, StatesOptionMixin, OptionDataItemObject { nodeClick?: 'rootToNode' | 'link' @@ -91,7 +91,8 @@ export interface SunburstSeriesNodeItemOption extends cursor?: string } -export interface SunburstSeriesLevelOption extends SunburstStateOption, StatesOptionMixin { +export interface SunburstSeriesLevelOption + extends SunburstStateOption, StatesOptionMixin { highlight?: { itemStyle?: SunburstItemStyleOption label?: SunburstLabelOption @@ -105,7 +106,7 @@ interface SortParam { getValue(): number } export interface SunburstSeriesOption extends - SeriesOption, SunburstStateOption, + SeriesOption, SunburstStateOption, SunburstColorByMixin, CircleLayoutOptionMixin { diff --git a/src/chart/tree/TreeSeries.ts b/src/chart/tree/TreeSeries.ts index 118ffb2fad..c51181f61a 100644 --- a/src/chart/tree/TreeSeries.ts +++ b/src/chart/tree/TreeSeries.ts @@ -53,7 +53,7 @@ export interface TreeSeriesStateOption { label?: SeriesLabelOption } -interface ExtraStateOption { +interface TreeStatesMixin { emphasis?: { focus?: DefaultEmphasisFocus | 'ancestor' | 'descendant' scale?: boolean @@ -61,7 +61,7 @@ interface ExtraStateOption { } export interface TreeSeriesNodeItemOption extends SymbolOptionMixin, - TreeSeriesStateOption, StatesOptionMixin, + TreeSeriesStateOption, StatesOptionMixin, OptionDataItemObject { children?: TreeSeriesNodeItemOption[] @@ -75,12 +75,12 @@ export interface TreeSeriesNodeItemOption extends SymbolOptionMixin { - +export interface TreeSeriesLeavesOption + extends TreeSeriesStateOption, StatesOptionMixin { } export interface TreeSeriesOption extends - SeriesOption, TreeSeriesStateOption, + SeriesOption, TreeSeriesStateOption, SymbolOptionMixin, BoxLayoutOptionMixin, RoamOptionMixin { type?: 'tree' diff --git a/src/component/marker/MarkAreaModel.ts b/src/component/marker/MarkAreaModel.ts index 9136c66bda..ec2a651ffc 100644 --- a/src/component/marker/MarkAreaModel.ts +++ b/src/component/marker/MarkAreaModel.ts @@ -18,7 +18,7 @@ */ import MarkerModel, { MarkerOption, MarkerStatisticType, MarkerPositionOption } from './MarkerModel'; -import { SeriesLabelOption, ItemStyleOption, StatesOptionMixin } from '../../util/types'; +import { SeriesLabelOption, ItemStyleOption, StatesOptionMixin, StatesMixinBase } from '../../util/types'; import GlobalModel from '../../model/Global'; @@ -27,7 +27,8 @@ interface MarkAreaStateOption { label?: SeriesLabelOption } -interface MarkAreaDataItemOptionBase extends MarkAreaStateOption, StatesOptionMixin { +interface MarkAreaDataItemOptionBase extends MarkAreaStateOption, + StatesOptionMixin { name?: string } @@ -55,7 +56,8 @@ export type MarkArea2DDataItemOption = [ MarkArea2DDataItemDimOption ]; -export interface MarkAreaOption extends MarkerOption, MarkAreaStateOption, StatesOptionMixin { +export interface MarkAreaOption extends MarkerOption, MarkAreaStateOption, + StatesOptionMixin { mainType?: 'markArea' precision?: number diff --git a/src/component/marker/MarkLineModel.ts b/src/component/marker/MarkLineModel.ts index 0c27667345..9cde9e024d 100644 --- a/src/component/marker/MarkLineModel.ts +++ b/src/component/marker/MarkLineModel.ts @@ -24,7 +24,8 @@ import { SeriesLineLabelOption, SymbolOptionMixin, ItemStyleOption, - StatesOptionMixin + StatesOptionMixin, + StatesMixinBase } from '../../util/types'; interface MarkLineStateOption { @@ -35,7 +36,8 @@ interface MarkLineStateOption { itemStyle?: ItemStyleOption label?: SeriesLineLabelOption } -interface MarkLineDataItemOptionBase extends MarkLineStateOption, StatesOptionMixin { +interface MarkLineDataItemOptionBase extends MarkLineStateOption, + StatesOptionMixin { name?: string } @@ -79,7 +81,8 @@ export type MarkLine2DDataItemOption = [ ]; export interface MarkLineOption extends MarkerOption, - MarkLineStateOption, StatesOptionMixin { + MarkLineStateOption, + StatesOptionMixin { mainType?: 'markLine' symbol?: string[] | string diff --git a/src/component/marker/MarkPointModel.ts b/src/component/marker/MarkPointModel.ts index db5f1663eb..3fef1b30db 100644 --- a/src/component/marker/MarkPointModel.ts +++ b/src/component/marker/MarkPointModel.ts @@ -24,7 +24,8 @@ import { ItemStyleOption, SeriesLabelOption, CallbackDataParams, - StatesOptionMixin + StatesOptionMixin, + StatesMixinBase } from '../../util/types'; // interface MarkPointCallbackDataParams extends CallbackDataParams { @@ -37,7 +38,7 @@ interface MarkPointStateOption { label?: SeriesLabelOption } export interface MarkPointDataItemOption extends - MarkPointStateOption, StatesOptionMixin, + MarkPointStateOption, StatesOptionMixin, // TODO should not support callback in data SymbolOptionMixin, MarkerPositionOption { @@ -46,7 +47,7 @@ export interface MarkPointDataItemOption extends export interface MarkPointOption extends MarkerOption, SymbolOptionMixin, - StatesOptionMixin, MarkPointStateOption { + StatesOptionMixin, MarkPointStateOption { mainType?: 'markPoint' precision?: number diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 3fe8999d98..0997f6716e 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -169,9 +169,6 @@ interface AxisTickOption { // The length of axisTick. length?: number, lineStyle?: LineStyleOption - - // -------------------------------------------- - // [Properties below only for 'category' axis]: } type AxisLabelValueFormatter = (value: number, index: number) => string; diff --git a/src/coord/geo/GeoModel.ts b/src/coord/geo/GeoModel.ts index f65553ca02..4f89d40b29 100644 --- a/src/coord/geo/GeoModel.ts +++ b/src/coord/geo/GeoModel.ts @@ -35,7 +35,8 @@ import { AnimationOptionMixin, StatesOptionMixin, Dictionary, - CommonTooltipOption + CommonTooltipOption, + StatesMixinBase } from '../../util/types'; import { NameMap } from './geoTypes'; import GlobalModel from '../../model/Global'; @@ -58,7 +59,7 @@ interface GeoLabelFormatterDataParams { status: DisplayState; } -export interface RegoinOption extends GeoStateOption, StatesOptionMixin { +export interface RegoinOption extends GeoStateOption, StatesOptionMixin { name?: string selected?: boolean tooltip?: CommonTooltipOption @@ -102,7 +103,7 @@ export interface GeoOption extends // For lens animation on geo. AnimationOptionMixin, GeoCommonOptionMixin, - StatesOptionMixin, GeoStateOption { + StatesOptionMixin, GeoStateOption { mainType?: 'geo'; show?: boolean; diff --git a/src/label/labelGuideHelper.ts b/src/label/labelGuideHelper.ts index ce53732d7b..c9a4b5bdb2 100644 --- a/src/label/labelGuideHelper.ts +++ b/src/label/labelGuideHelper.ts @@ -661,7 +661,7 @@ export function setLabelLineStyle( export function getLabelLineStatesModels( - itemModel: Model & Partial>>, + itemModel: Model & Partial>>, labelLineName?: LabelName ): Record { labelLineName = (labelLineName || 'labelLine') as LabelName; diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts index e63a35117e..eb601ed5f9 100644 --- a/src/label/labelStyle.ts +++ b/src/label/labelStyle.ts @@ -293,7 +293,7 @@ function setLabelStyle( export { setLabelStyle }; export function getLabelStatesModels( - itemModel: Model & Partial>>, + itemModel: Model & Partial>>, labelName?: LabelName ): Record { labelName = (labelName || 'label') as LabelName; diff --git a/src/util/types.ts b/src/util/types.ts index 1686e56d45..a484f425bd 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -965,6 +965,10 @@ export interface ItemStyleOption extends ShadowOptionMixin, BorderOptionMixin { decal?: DecalObject | 'none' } +export interface SeriesItemStyleOption extends Omit { + color?: ZRColor | ((params: TParams) => string) +} + /** * ItemStyleOption is a option set to control styles on lines. * Used in the components or series like `line`, `axis` @@ -1499,15 +1503,16 @@ export type BlurScope = 'coordinateSystem' | 'series' | 'global'; */ export type InnerFocus = DefaultEmphasisFocus | ArrayLike | Dictionary>; -export interface DefaultExtraStateOpts { - emphasis: any - select: any - blur: any +export interface DefaultStatesMixin { + // FIXME + emphasis?: any + select?: any + blur?: any } export type DefaultEmphasisFocus = 'none' | 'self' | 'series'; -export interface DefaultExtraEmpasisState { +export interface DefaultStatesMixinEmpasis { /** * self: Focus self and blur all others. * series: Focus series and blur all other series. @@ -1515,19 +1520,20 @@ export interface DefaultExtraEmpasisState { focus?: DefaultEmphasisFocus } -interface ExtraStateOptsBase { - emphasis?: { - focus?: string - }, - select?: any - blur?: any +export interface StatesMixinBase { + emphasis?: unknown + select?: unknown + blur?: unknown } -export interface StatesOptionMixin { +export interface StatesOptionMixin< + StateOption, + StatesMixin extends StatesMixinBase +> { /** * Emphasis states */ - emphasis?: StateOption & ExtraStateOpts['emphasis'] & { + emphasis?: StateOption & StatesMixin['emphasis'] & { /** * Scope of blurred element when focus. * @@ -1542,11 +1548,11 @@ export interface StatesOptionMixin extends + StateOption = unknown, + StatesMixin extends StatesMixinBase = DefaultStatesMixin +> extends ComponentOption, AnimationOptionMixin, ColorPaletteOptionMixin, - StatesOptionMixin + StatesOptionMixin { mainType?: 'series' diff --git a/test/types/basic.ts b/test/types/basic.ts index 19bfa6761f..fd39e4d0f4 100644 --- a/test/types/basic.ts +++ b/test/types/basic.ts @@ -26,7 +26,12 @@ const chart: echarts.EChartsType = echarts.init(dom); const option: echarts.EChartsOption = { series: [{ - type: 'bar' + type: 'bar', + emphasis: { + itemStyle: { + color: 'red' + } + } }] }; chart.setOption(option); \ No newline at end of file From 0779757dd37bbda7598754b963138425ac3ce592 Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 9 Sep 2021 10:16:40 +0800 Subject: [PATCH 25/40] fix(type): fix callback type in itemStyle.color #14279 --- src/chart/bar/BarSeries.ts | 13 ++++++++----- src/chart/boxplot/BoxplotSeries.ts | 12 +++++++----- .../effectScatter/EffectScatterSeries.ts | 7 ++++--- src/chart/funnel/FunnelSeries.ts | 18 ++++++++++++------ src/chart/gauge/GaugeSeries.ts | 12 +++++++----- src/chart/graph/GraphSeries.ts | 9 +++++---- src/chart/heatmap/HeatmapSeries.ts | 19 ++++++++++++++----- src/chart/line/LineSeries.ts | 8 ++++---- src/chart/lines/LinesSeries.ts | 14 ++++++++------ src/chart/map/MapSeries.ts | 14 ++++++++------ src/chart/parallel/ParallelSeries.ts | 16 ++++++++-------- src/chart/pie/PieSeries.ts | 17 +++++++++++------ src/chart/radar/RadarSeries.ts | 10 ++++++---- src/chart/sankey/SankeySeries.ts | 13 +++++++------ src/chart/scatter/ScatterSeries.ts | 7 ++++--- src/chart/sunburst/SunburstSeries.ts | 9 +++++---- src/chart/themeRiver/ThemeRiverSeries.ts | 15 +++++++++++---- src/chart/tree/TreeSeries.ts | 7 ++++--- src/chart/treemap/TreemapSeries.ts | 13 ++++++------- src/coord/geo/GeoModel.ts | 2 +- src/util/types.ts | 18 +++++++----------- 21 files changed, 147 insertions(+), 106 deletions(-) diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts index 57323c5368..d2b76ab3a7 100644 --- a/src/chart/bar/BarSeries.ts +++ b/src/chart/bar/BarSeries.ts @@ -27,7 +27,8 @@ import { SeriesSamplingOptionMixin, SeriesLabelOption, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + CallbackDataParams } from '../../util/types'; import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; import createSeriesData from '../helper/createSeriesData'; @@ -42,8 +43,8 @@ export type PolarBarLabelPosition = SeriesLabelOption['position'] export type BarSeriesLabelOption = Omit & {position?: PolarBarLabelPosition | 'outside'}; -export interface BarStateOption { - itemStyle?: BarItemStyleOption +export interface BarStateOption { + itemStyle?: BarItemStyleOption label?: BarSeriesLabelOption } @@ -51,7 +52,7 @@ interface BarStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface BarItemStyleOption extends ItemStyleOption { +export interface BarItemStyleOption extends ItemStyleOption { // Border radius is not supported for bar on polar borderRadius?: number | number[] } @@ -61,7 +62,9 @@ export interface BarDataItemOption extends BarStateOption, cursor?: string } -export interface BarSeriesOption extends BaseBarSeriesOption, BarStateOption, +export interface BarSeriesOption + extends BaseBarSeriesOption, BarStatesMixin>, + BarStateOption, SeriesStackOptionMixin, SeriesSamplingOptionMixin, SeriesEncodeOptionMixin { type?: 'bar' diff --git a/src/chart/boxplot/BoxplotSeries.ts b/src/chart/boxplot/BoxplotSeries.ts index 60cbc41871..b87276b39b 100644 --- a/src/chart/boxplot/BoxplotSeries.ts +++ b/src/chart/boxplot/BoxplotSeries.ts @@ -28,7 +28,8 @@ import { OptionDataValueNumeric, StatesOptionMixin, SeriesEncodeOptionMixin, - DefaultEmphasisFocus + DefaultEmphasisFocus, + CallbackDataParams } from '../../util/types'; import type Axis2D from '../../coord/cartesian/Axis2D'; import Cartesian2D from '../../coord/cartesian/Cartesian2D'; @@ -37,9 +38,8 @@ import { mixin } from 'zrender/src/core/util'; // [min, Q1, median (or Q2), Q3, max] type BoxplotDataValue = OptionDataValueNumeric[]; - -export interface BoxplotStateOption { - itemStyle?: ItemStyleOption +export interface BoxplotStateOption { + itemStyle?: ItemStyleOption label?: SeriesLabelOption } @@ -55,7 +55,9 @@ interface ExtraStateOption { } } -export interface BoxplotSeriesOption extends SeriesOption, BoxplotStateOption, +export interface BoxplotSeriesOption + extends SeriesOption, ExtraStateOption>, + BoxplotStateOption, SeriesOnCartesianOptionMixin, SeriesEncodeOptionMixin { type?: 'boxplot' diff --git a/src/chart/effectScatter/EffectScatterSeries.ts b/src/chart/effectScatter/EffectScatterSeries.ts index 8e936b3eea..19a468c5c1 100644 --- a/src/chart/effectScatter/EffectScatterSeries.ts +++ b/src/chart/effectScatter/EffectScatterSeries.ts @@ -48,8 +48,8 @@ interface EffectScatterStatesOptionMixin { scale?: boolean } } -export interface EffectScatterStateOption { - itemStyle?: ItemStyleOption +export interface EffectScatterStateOption { + itemStyle?: ItemStyleOption label?: SeriesLabelOption } @@ -64,7 +64,8 @@ export interface EffectScatterDataItemOption extends SymbolOptionMixin, } export interface EffectScatterSeriesOption - extends SeriesOption, EffectScatterStateOption, + extends SeriesOption, EffectScatterStatesOptionMixin>, + EffectScatterStateOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SymbolOptionMixin, SeriesEncodeOptionMixin { diff --git a/src/chart/funnel/FunnelSeries.ts b/src/chart/funnel/FunnelSeries.ts index 8ac6fcf4c2..f102f793cb 100644 --- a/src/chart/funnel/FunnelSeries.ts +++ b/src/chart/funnel/FunnelSeries.ts @@ -37,7 +37,8 @@ import { VerticalAlign, SeriesLabelOption, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -51,8 +52,11 @@ interface FunnelStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface FunnelStateOption { - itemStyle?: ItemStyleOption +export interface FunnelCallbackDataParams extends CallbackDataParams { + percent: number +} +export interface FunnelStateOption { + itemStyle?: ItemStyleOption label?: FunnelLabelOption labelLine?: LabelLineOption } @@ -67,7 +71,9 @@ export interface FunnelDataItemOption } } -export interface FunnelSeriesOption extends SeriesOption, FunnelStateOption, +export interface FunnelSeriesOption + extends SeriesOption, FunnelStatesMixin>, + FunnelStateOption, BoxLayoutOptionMixin, SeriesEncodeOptionMixin { type?: 'funnel' @@ -128,9 +134,9 @@ class FunnelSeriesModel extends SeriesModel { } // Overwrite - getDataParams(dataIndex: number) { + getDataParams(dataIndex: number): FunnelCallbackDataParams { const data = this.getData(); - const params = super.getDataParams(dataIndex); + const params = super.getDataParams(dataIndex) as FunnelCallbackDataParams; const valueDim = data.mapDimension('value'); const sum = data.getSum(valueDim); // Percent is 0 if sum is 0 diff --git a/src/chart/gauge/GaugeSeries.ts b/src/chart/gauge/GaugeSeries.ts index b861bf708c..c444a6e082 100644 --- a/src/chart/gauge/GaugeSeries.ts +++ b/src/chart/gauge/GaugeSeries.ts @@ -29,7 +29,8 @@ import { OptionDataValueNumeric, StatesOptionMixin, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -106,12 +107,12 @@ interface DetailOption extends LabelOption { interface GaugeStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface GaugeStateOption { - itemStyle?: ItemStyleOption +export interface GaugeStateOption { + itemStyle?: ItemStyleOption } export interface GaugeDataItemOption extends GaugeStateOption, - StatesOptionMixin { + StatesOptionMixin, GaugeStatesMixin> { name?: string value?: OptionDataValueNumeric pointer?: PointerOption @@ -119,7 +120,8 @@ export interface GaugeDataItemOption extends GaugeStateOption, title?: TitleOption detail?: DetailOption } -export interface GaugeSeriesOption extends SeriesOption, GaugeStateOption, +export interface GaugeSeriesOption extends SeriesOption, + GaugeStateOption, CircleLayoutOptionMixin, SeriesEncodeOptionMixin { type?: 'gauge' diff --git a/src/chart/graph/GraphSeries.ts b/src/chart/graph/GraphSeries.ts index eb034015d9..a3241c0951 100644 --- a/src/chart/graph/GraphSeries.ts +++ b/src/chart/graph/GraphSeries.ts @@ -62,8 +62,8 @@ interface GraphEdgeLineStyleOption extends LineStyleOption { curveness?: number } -export interface GraphNodeStateOption { - itemStyle?: ItemStyleOption +export interface GraphNodeStateOption { + itemStyle?: ItemStyleOption label?: SeriesLabelOption } @@ -136,7 +136,8 @@ export interface GraphCategoryItemOption extends SymbolOptionMixin, value?: OptionDataValue } -export interface GraphSeriesOption extends SeriesOption, +export interface GraphSeriesOption + extends SeriesOption, GraphNodeStatesMixin>, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SymbolOptionMixin, @@ -177,7 +178,7 @@ export interface GraphSeriesOption extends SeriesOption lineStyle?: GraphEdgeLineStyleOption emphasis?: { diff --git a/src/chart/heatmap/HeatmapSeries.ts b/src/chart/heatmap/HeatmapSeries.ts index 3a785697d0..7fcd89f918 100644 --- a/src/chart/heatmap/HeatmapSeries.ts +++ b/src/chart/heatmap/HeatmapSeries.ts @@ -30,7 +30,8 @@ import { StatesOptionMixin, SeriesEncodeOptionMixin, SeriesOnCalendarOptionMixin, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -40,9 +41,9 @@ import type Calendar from '../../coord/calendar/Calendar'; type HeatmapDataValue = OptionDataValue[]; -export interface HeatmapStateOption { +export interface HeatmapStateOption { // Available on cartesian2d coordinate system - itemStyle?: ItemStyleOption + itemStyle?: ItemStyleOption label?: SeriesLabelOption } @@ -54,8 +55,14 @@ export interface HeatmapDataItemOption extends HeatmapStateOption, value: HeatmapDataValue } -export interface HeatmapSeriesOption extends SeriesOption, HeatmapStateOption, - SeriesOnCartesianOptionMixin, SeriesOnGeoOptionMixin, SeriesOnCalendarOptionMixin, SeriesEncodeOptionMixin { +export interface HeatmapSeriesOption + extends SeriesOption, FunnelStatesMixin>, + HeatmapStateOption, + SeriesOnCartesianOptionMixin, + SeriesOnGeoOptionMixin, + SeriesOnCalendarOptionMixin, + SeriesEncodeOptionMixin { + type?: 'heatmap' coordinateSystem?: 'cartesian2d' | 'geo' | 'calendar' @@ -69,6 +76,8 @@ export interface HeatmapSeriesOption extends SeriesOption { static readonly type = 'series.heatmap'; readonly type = HeatmapSeriesModel.type; diff --git a/src/chart/line/LineSeries.ts b/src/chart/line/LineSeries.ts index 5c569e646a..1b572b5a20 100644 --- a/src/chart/line/LineSeries.ts +++ b/src/chart/line/LineSeries.ts @@ -52,8 +52,8 @@ interface LineStateOptionMixin { } } -export interface LineStateOption { - itemStyle?: ItemStyleOption +export interface LineStateOption { + itemStyle?: ItemStyleOption label?: SeriesLabelOption endLabel?: LineEndLabelOption } @@ -70,7 +70,7 @@ export interface LineEndLabelOption extends SeriesLabelOption { } -export interface LineSeriesOption extends SeriesOption, LineStateOptionMixin & { emphasis?: { lineStyle?: LineStyleOption | { width?: 'bolder' @@ -81,7 +81,7 @@ export interface LineSeriesOption extends SeriesOption, LineStateOption, +}>, LineStateOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesStackOptionMixin, diff --git a/src/chart/lines/LinesSeries.ts b/src/chart/lines/LinesSeries.ts index 61e4d444c9..b762fe1c9e 100644 --- a/src/chart/lines/LinesSeries.ts +++ b/src/chart/lines/LinesSeries.ts @@ -35,7 +35,9 @@ import { StatesOptionMixin, SeriesLineLabelOption, DimensionDefinitionLoose, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + ZRColor, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import type { LineDrawModelOption } from '../helper/LineDraw'; @@ -73,7 +75,7 @@ type LinesCoords = number[][]; type LinesValue = OptionDataValue | OptionDataValue[]; -interface LinesLineStyleOption extends LineStyleOption { +interface LinesLineStyleOption extends LineStyleOption { curveness?: number } @@ -86,13 +88,13 @@ interface LegacyDataItemOption { interface LinesStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface LinesStateOption { - lineStyle?: LinesLineStyleOption +export interface LinesStateOption { + lineStyle?: LinesLineStyleOption ZRColor> label?: SeriesLineLabelOption } -export interface LinesDataItemOption extends LinesStateOption, - StatesOptionMixin { +export interface LinesDataItemOption extends LinesStateOption, + StatesOptionMixin, LinesStatesMixin> { name?: string fromName?: string diff --git a/src/chart/map/MapSeries.ts b/src/chart/map/MapSeries.ts index d146f113b8..4aab23a2f7 100644 --- a/src/chart/map/MapSeries.ts +++ b/src/chart/map/MapSeries.ts @@ -33,7 +33,8 @@ import { SeriesOnGeoOptionMixin, StatesOptionMixin, SeriesLabelOption, - StatesMixinBase + StatesMixinBase, + CallbackDataParams } from '../../util/types'; import { Dictionary } from 'zrender/src/core/types'; import GeoModel, { GeoCommonOptionMixin, GeoItemStyleOption } from '../../coord/geo/GeoModel'; @@ -45,11 +46,12 @@ import {createSymbol, ECSymbol} from '../../util/symbol'; import {LegendIconParams} from '../../component/legend/LegendModel'; import {Group} from '../../util/graphic'; -export interface MapStateOption { - itemStyle?: GeoItemStyleOption +export interface MapStateOption { + itemStyle?: GeoItemStyleOption label?: SeriesLabelOption } -export interface MapDataItemOption extends MapStateOption, StatesOptionMixin, +export interface MapDataItemOption extends MapStateOption, + StatesOptionMixin, OptionDataItemObject { cursor?: string } @@ -57,8 +59,8 @@ export interface MapDataItemOption extends MapStateOption, StatesOptionMixin, MapStateOption, - + SeriesOption, StatesMixinBase>, + MapStateOption, GeoCommonOptionMixin, // If `geoIndex` is not specified, a exclusive geo will be // created. Otherwise use the specified geo component, and diff --git a/src/chart/parallel/ParallelSeries.ts b/src/chart/parallel/ParallelSeries.ts index 4b44d79791..9a8f68e67a 100644 --- a/src/chart/parallel/ParallelSeries.ts +++ b/src/chart/parallel/ParallelSeries.ts @@ -33,7 +33,9 @@ import { OptionEncodeValue, Dictionary, OptionEncode, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmpasis, + ZRColor, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -46,8 +48,8 @@ type ParallelSeriesDataValue = OptionDataValue[]; interface ParallelStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface ParallelStateOption { - lineStyle?: LineStyleOption +export interface ParallelStateOption { + lineStyle?: LineStyleOption ZRColor> label?: SeriesLabelOption } @@ -56,7 +58,8 @@ export interface ParallelSeriesDataItemOption extends ParallelStateOption, value?: ParallelSeriesDataValue[] } export interface ParallelSeriesOption extends - SeriesOption, ParallelStateOption, + SeriesOption, ParallelStatesMixin>, + ParallelStateOption, SeriesEncodeOptionMixin { type?: 'parallel'; @@ -74,14 +77,11 @@ export interface ParallelSeriesOption extends parallelAxisDefault?: ParallelAxisOption; - emphasis?: { - label?: SeriesLabelOption; - lineStyle?: LineStyleOption; - } data?: (ParallelSeriesDataValue | ParallelSeriesDataItemOption)[] } + class ParallelSeriesModel extends SeriesModel { static type = 'series.parallel'; diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts index de283ad04f..efa5bda315 100644 --- a/src/chart/pie/PieSeries.ts +++ b/src/chart/pie/PieSeries.ts @@ -40,7 +40,7 @@ import { } from '../../util/types'; import SeriesData from '../../data/SeriesData'; -interface PieItemStyleOption extends ItemStyleOption { +interface PieItemStyleOption extends ItemStyleOption { // can be 10 // which means that both innerCornerRadius and outerCornerRadius are 10 // can also be an array [20, 10] @@ -52,9 +52,13 @@ interface PieItemStyleOption extends ItemStyleOption { borderRadius?: (number | string)[] | number | string } -export interface PieStateOption { +export interface PieCallbackDataParams extends CallbackDataParams { + percent: number +} + +export interface PieStateOption { // TODO: TYPE Color Callback - itemStyle?: PieItemStyleOption + itemStyle?: PieItemStyleOption label?: PieLabelOption labelLine?: PieLabelLineOption } @@ -94,7 +98,8 @@ export interface PieDataItemOption extends cursor?: string } export interface PieSeriesOption extends - Omit, 'labelLine'>, PieStateOption, + Omit, ExtraStateOption>, 'labelLine'>, + PieStateOption, CircleLayoutOptionMixin, BoxLayoutOptionMixin, SeriesEncodeOptionMixin { @@ -163,9 +168,9 @@ class PieSeriesModel extends SeriesModel { /** * @overwrite */ - getDataParams(dataIndex: number): CallbackDataParams { + getDataParams(dataIndex: number): PieCallbackDataParams { const data = this.getData(); - const params = super.getDataParams(dataIndex); + const params = super.getDataParams(dataIndex) as PieCallbackDataParams; // FIXME toFixed? const valueList: number[] = []; diff --git a/src/chart/radar/RadarSeries.ts b/src/chart/radar/RadarSeries.ts index 25829dbc5a..c6f9bc5f62 100644 --- a/src/chart/radar/RadarSeries.ts +++ b/src/chart/radar/RadarSeries.ts @@ -47,19 +47,21 @@ type RadarSeriesDataValue = OptionDataValue[]; interface RadarStatesMixin { emphasis?: DefaultStatesMixinEmpasis } -export interface RadarSeriesStateOption { +export interface RadarSeriesStateOption { lineStyle?: LineStyleOption areaStyle?: AreaStyleOption label?: SeriesLabelOption - itemStyle?: ItemStyleOption + itemStyle?: ItemStyleOption } export interface RadarSeriesDataItemOption extends SymbolOptionMixin, - RadarSeriesStateOption, StatesOptionMixin, + RadarSeriesStateOption, + StatesOptionMixin, RadarStatesMixin>, OptionDataItemObject { } export interface RadarSeriesOption - extends SeriesOption, RadarSeriesStateOption, + extends SeriesOption, + RadarSeriesStateOption, SymbolOptionMixin, SeriesEncodeOptionMixin { type?: 'radar' coordinateSystem?: 'radar' diff --git a/src/chart/sankey/SankeySeries.ts b/src/chart/sankey/SankeySeries.ts index 6131f56e1a..0479035203 100644 --- a/src/chart/sankey/SankeySeries.ts +++ b/src/chart/sankey/SankeySeries.ts @@ -33,7 +33,8 @@ import { OptionDataItemObject, GraphEdgeItemObject, OptionDataValueNumeric, - DefaultEmphasisFocus + DefaultEmphasisFocus, + CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -43,17 +44,16 @@ import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup'; type FocusNodeAdjacency = boolean | 'inEdges' | 'outEdges' | 'allEdges'; -export interface SankeyNodeStateOption { +export interface SankeyNodeStateOption { label?: SeriesLabelOption - itemStyle?: ItemStyleOption + itemStyle?: ItemStyleOption } export interface SankeyEdgeStateOption { lineStyle?: SankeyEdgeStyleOption } -interface SankeyBothStateOption extends SankeyNodeStateOption, SankeyEdgeStateOption { -} +interface SankeyBothStateOption extends SankeyNodeStateOption, SankeyEdgeStateOption {} interface SankeyEdgeStyleOption extends LineStyleOption { curveness?: number @@ -92,7 +92,8 @@ export interface SankeyLevelOption extends SankeyNodeStateOption, SankeyEdgeStat } export interface SankeySeriesOption - extends SeriesOption, SankeyBothStateOption, + extends SeriesOption, ExtraStateOption>, + SankeyBothStateOption, BoxLayoutOptionMixin { type?: 'sankey' diff --git a/src/chart/scatter/ScatterSeries.ts b/src/chart/scatter/ScatterSeries.ts index f2b148202d..f79f42281e 100644 --- a/src/chart/scatter/ScatterSeries.ts +++ b/src/chart/scatter/ScatterSeries.ts @@ -42,8 +42,8 @@ import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; import { BrushCommonSelectorsForSeries } from '../../component/brush/selector'; -interface ScatterStateOption { - itemStyle?: ItemStyleOption +interface ScatterStateOption { + itemStyle?: ItemStyleOption label?: SeriesLabelOption } @@ -60,7 +60,8 @@ export interface ScatterDataItemOption extends SymbolOptionMixin, } export interface ScatterSeriesOption - extends SeriesOption, ScatterStateOption, + extends SeriesOption, ScatterStatesOptionMixin>, + ScatterStateOption, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SeriesLargeOptionMixin, SeriesStackOptionMixin, diff --git a/src/chart/sunburst/SunburstSeries.ts b/src/chart/sunburst/SunburstSeries.ts index afbe542d91..f7d801c0a9 100644 --- a/src/chart/sunburst/SunburstSeries.ts +++ b/src/chart/sunburst/SunburstSeries.ts @@ -38,7 +38,7 @@ import SeriesData from '../../data/SeriesData'; import Model from '../../model/Model'; import enableAriaDecalForTree from '../helper/enableAriaDecalForTree'; -interface SunburstItemStyleOption extends ItemStyleOption { +interface SunburstItemStyleOption extends ItemStyleOption { // can be 10 // which means that both innerCornerRadius and outerCornerRadius are 10 // can also be an array [20, 10] @@ -71,13 +71,14 @@ interface SunburstStatesMixin { } } -export interface SunburstStateOption { - itemStyle?: SunburstItemStyleOption +export interface SunburstStateOption { + itemStyle?: SunburstItemStyleOption label?: SunburstLabelOption } export interface SunburstSeriesNodeItemOption extends - SunburstStateOption, StatesOptionMixin, + SunburstStateOption, + StatesOptionMixin, SunburstStatesMixin>, OptionDataItemObject { nodeClick?: 'rootToNode' | 'link' diff --git a/src/chart/themeRiver/ThemeRiverSeries.ts b/src/chart/themeRiver/ThemeRiverSeries.ts index 4cd6c57fa2..2e05a9a826 100644 --- a/src/chart/themeRiver/ThemeRiverSeries.ts +++ b/src/chart/themeRiver/ThemeRiverSeries.ts @@ -33,7 +33,9 @@ import { BoxLayoutOptionMixin, ZRColor, Dictionary, - SeriesLabelOption + SeriesLabelOption, + CallbackDataParams, + DefaultStatesMixinEmpasis } from '../../util/types'; import SingleAxis from '../../coord/single/SingleAxis'; import GlobalModel from '../../model/Global'; @@ -48,12 +50,17 @@ interface ThemeRiverSeriesLabelOption extends SeriesLabelOption { type ThemerRiverDataItem = [OptionDataValueDate, OptionDataValueNumeric, string]; -export interface ThemeRiverStateOption { +interface ThemeRiverStatesMixin { + emphasis?: DefaultStatesMixinEmpasis +} +export interface ThemeRiverStateOption { label?: ThemeRiverSeriesLabelOption - itemStyle?: ItemStyleOption + itemStyle?: ItemStyleOption } -export interface ThemeRiverSeriesOption extends SeriesOption, ThemeRiverStateOption, +export interface ThemeRiverSeriesOption + extends SeriesOption, ThemeRiverStatesMixin>, + ThemeRiverStateOption, SeriesOnSingleOptionMixin, BoxLayoutOptionMixin { type?: 'themeRiver' diff --git a/src/chart/tree/TreeSeries.ts b/src/chart/tree/TreeSeries.ts index c51181f61a..5d7b8f5ef4 100644 --- a/src/chart/tree/TreeSeries.ts +++ b/src/chart/tree/TreeSeries.ts @@ -44,8 +44,8 @@ interface CurveLineStyleOption extends LineStyleOption{ curveness?: number } -export interface TreeSeriesStateOption { - itemStyle?: ItemStyleOption +export interface TreeSeriesStateOption { + itemStyle?: ItemStyleOption /** * Line style of the edge between node and it's parent. */ @@ -61,7 +61,8 @@ interface TreeStatesMixin { } export interface TreeSeriesNodeItemOption extends SymbolOptionMixin, - TreeSeriesStateOption, StatesOptionMixin, + TreeSeriesStateOption, + StatesOptionMixin, TreeStatesMixin>, OptionDataItemObject { children?: TreeSeriesNodeItemOption[] diff --git a/src/chart/treemap/TreemapSeries.ts b/src/chart/treemap/TreemapSeries.ts index 287540e9c4..043018c671 100644 --- a/src/chart/treemap/TreemapSeries.ts +++ b/src/chart/treemap/TreemapSeries.ts @@ -36,8 +36,7 @@ import { DecalObject, SeriesLabelOption, DefaultEmphasisFocus, - AriaOptionMixin, - ColorBy + AriaOptionMixin } from '../../util/types'; import GlobalModel from '../../model/Global'; import { LayoutRect } from '../../util/layout'; @@ -59,7 +58,7 @@ interface TreemapSeriesLabelOption extends SeriesLabelOption { formatter?: string | ((params: CallbackDataParams) => string) } -interface TreemapSeriesItemStyleOption extends ItemStyleOption { +interface TreemapSeriesItemStyleOption extends ItemStyleOption { borderRadius?: number | number[] colorAlpha?: number @@ -91,8 +90,8 @@ interface ExtraStateOption { } } -export interface TreemapStateOption { - itemStyle?: TreemapSeriesItemStyleOption +export interface TreemapStateOption { + itemStyle?: TreemapSeriesItemStyleOption label?: TreemapSeriesLabelOption upperLabel?: TreemapSeriesLabelOption } @@ -149,8 +148,8 @@ export interface TreemapSeriesNodeItemOption extends TreemapSeriesVisualOption, } export interface TreemapSeriesOption - extends SeriesOption, - TreemapStateOption, + extends SeriesOption, ExtraStateOption>, + TreemapStateOption, BoxLayoutOptionMixin, RoamOptionMixin, TreemapSeriesVisualOption { diff --git a/src/coord/geo/GeoModel.ts b/src/coord/geo/GeoModel.ts index 4f89d40b29..adbafee13a 100644 --- a/src/coord/geo/GeoModel.ts +++ b/src/coord/geo/GeoModel.ts @@ -43,7 +43,7 @@ import GlobalModel from '../../model/Global'; import geoSourceManager from './geoSourceManager'; -export interface GeoItemStyleOption extends ItemStyleOption { +export interface GeoItemStyleOption extends ItemStyleOption { areaColor?: ZRColor; }; interface GeoLabelOption extends LabelOption { diff --git a/src/util/types.ts b/src/util/types.ts index a484f425bd..e6ccb589fa 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -938,37 +938,33 @@ export type SymbolOffsetCallback = (rawValue: any, params: T) => string | num * Mixin of option set to control the element symbol. * Include type of symbol, and size of symbol. */ -export interface SymbolOptionMixin { +export interface SymbolOptionMixin { /** * type of symbol, like `cirlce`, `rect`, or custom path and image. */ - symbol?: string | (unknown extends T ? never : SymbolCallback) + symbol?: string | (T extends never ? never : SymbolCallback) /** * Size of symbol. */ - symbolSize?: number | number[] | (unknown extends T ? never : SymbolSizeCallback) + symbolSize?: number | number[] | (T extends never ? never : SymbolSizeCallback) - symbolRotate?: number | (unknown extends T ? never : SymbolRotateCallback) + symbolRotate?: number | (T extends never ? never : SymbolRotateCallback) symbolKeepAspect?: boolean - symbolOffset?: string | number | (string | number)[] | (unknown extends T ? never : SymbolOffsetCallback) + symbolOffset?: string | number | (string | number)[] | (T extends never ? never : SymbolOffsetCallback) } /** * ItemStyleOption is a most common used set to config element styles. * It includes both fill and stroke style. */ -export interface ItemStyleOption extends ShadowOptionMixin, BorderOptionMixin { - color?: ZRColor +export interface ItemStyleOption extends ShadowOptionMixin, BorderOptionMixin { + color?: ZRColor | (TCbParams extends never ? never : ((params: TCbParams) => ZRColor)) opacity?: number decal?: DecalObject | 'none' } -export interface SeriesItemStyleOption extends Omit { - color?: ZRColor | ((params: TParams) => string) -} - /** * ItemStyleOption is a option set to control styles on lines. * Used in the components or series like `line`, `axis` From 179b20ad52c3a0d9428a0cf93315369b10f39416 Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 9 Sep 2021 10:48:16 +0800 Subject: [PATCH 26/40] fix(type): fix some type errors in custom series --- src/chart/custom/CustomSeries.ts | 32 ++++++++++++++++++++++++-------- src/chart/custom/CustomView.ts | 18 +++++++++--------- src/layout/barGrid.ts | 10 +++++----- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts index 2b8bb3c9b2..c34cbdf148 100644 --- a/src/chart/custom/CustomSeries.ts +++ b/src/chart/custom/CustomSeries.ts @@ -335,13 +335,8 @@ type CustomSeriesRenderItem = ( api: CustomSeriesRenderItemAPI ) => CustomElementOption; -interface CustomSeriesStateOption { - itemStyle?: ItemStyleOption; - label?: LabelOption; -} - export interface CustomSeriesOption extends - SeriesOption, // don't support StateOption in custom series. + SeriesOption, // don't support StateOption in custom series. SeriesEncodeOptionMixin, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, @@ -356,12 +351,33 @@ export interface CustomSeriesOption extends renderItem?: CustomSeriesRenderItem; + /** + * @deprecated + */ + itemStyle?: ItemStyleOption; + /** + * @deprecated + */ + label?: LabelOption; + + /** + * @deprecated + */ + emphasis?: { + /** + * @deprecated + */ + itemStyle?: ItemStyleOption; + /** + * @deprecated + */ + label?: LabelOption; + } + // Only works on polar and cartesian2d coordinate system. clip?: boolean; } -export interface LegacyCustomSeriesOption extends SeriesOption, CustomSeriesStateOption {} - export const customInnerStore = makeInner<{ info: CustomExtraElementInfo; customPathData: string; diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts index 1ba6d86b05..ae042b7f22 100644 --- a/src/chart/custom/CustomView.ts +++ b/src/chart/custom/CustomView.ts @@ -82,7 +82,6 @@ import CustomSeriesModel, { CustomDisplayableOption, CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams, - LegacyCustomSeriesOption, CustomGroupOption, WrapEncodeDefRet, NonStyleVisualProps, @@ -102,6 +101,7 @@ import { prepareTransformTransitionFrom } from './prepare'; import { PatternObject } from 'zrender/src/graphic/Pattern'; +import { CustomSeriesOption } from '../../export/option'; const transformPropNamesStr = keys(TRANSFORM_PROPS).join(', '); @@ -879,23 +879,23 @@ function makeRenderItem( // Do not support call `api` asynchronously without dataIndexInside input. let currDataIndexInside: number; - let currItemModel: Model; - let currItemStyleModels: Partial>> = {}; - let currLabelModels: Partial>> = {}; + let currItemModel: Model; + let currItemStyleModels: Partial>> = {}; + let currLabelModels: Partial>> = {}; - const seriesItemStyleModels = {} as Record>; + const seriesItemStyleModels = {} as Record>; - const seriesLabelModels = {} as Record>; + const seriesLabelModels = {} as Record>; for (let i = 0; i < STATES.length; i++) { const stateName = STATES[i]; - seriesItemStyleModels[stateName] = (customSeries as Model) + seriesItemStyleModels[stateName] = (customSeries as Model) .getModel(PATH_ITEM_STYLE[stateName]); - seriesLabelModels[stateName] = (customSeries as Model) + seriesLabelModels[stateName] = (customSeries as Model) .getModel(PATH_LABEL[stateName]); } - function getItemModel(dataIndexInside: number): Model { + function getItemModel(dataIndexInside: number): Model { return dataIndexInside === currDataIndexInside ? (currItemModel || (currItemModel = data.getItemModel(dataIndexInside))) : data.getItemModel(dataIndexInside); diff --git a/src/layout/barGrid.ts b/src/layout/barGrid.ts index 4a7c90887f..9c7807656c 100644 --- a/src/layout/barGrid.ts +++ b/src/layout/barGrid.ts @@ -77,11 +77,11 @@ type BarWidthAndOffset = Dictionary Date: Thu, 9 Sep 2021 11:16:45 +0800 Subject: [PATCH 27/40] fix(type): fix some type errors --- src/chart/lines/LinesSeries.ts | 6 +++--- src/chart/parallel/ParallelSeries.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chart/lines/LinesSeries.ts b/src/chart/lines/LinesSeries.ts index b762fe1c9e..7598626b65 100644 --- a/src/chart/lines/LinesSeries.ts +++ b/src/chart/lines/LinesSeries.ts @@ -89,7 +89,7 @@ interface LinesStatesMixin { emphasis?: DefaultStatesMixinEmpasis } export interface LinesStateOption { - lineStyle?: LinesLineStyleOption ZRColor> + lineStyle?: LinesLineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor> label?: SeriesLineLabelOption } @@ -108,8 +108,6 @@ export interface LinesDataItemOption extends LinesStateOption + + dimensions?: DimensionDefinitionLoose | DimensionDefinitionLoose[] } class LinesSeriesModel extends SeriesModel { diff --git a/src/chart/parallel/ParallelSeries.ts b/src/chart/parallel/ParallelSeries.ts index 9a8f68e67a..0b727eef0a 100644 --- a/src/chart/parallel/ParallelSeries.ts +++ b/src/chart/parallel/ParallelSeries.ts @@ -49,7 +49,7 @@ interface ParallelStatesMixin { emphasis?: DefaultStatesMixinEmpasis } export interface ParallelStateOption { - lineStyle?: LineStyleOption ZRColor> + lineStyle?: LineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor> label?: SeriesLabelOption } From 3f520525e4c7189fc6db670ae273fe2f4facbc40 Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 9 Sep 2021 13:00:28 +0800 Subject: [PATCH 28/40] fix(type): expose more type from custom series --- src/chart/custom/CustomSeries.ts | 45 +++++++++++++++++++------------- src/chart/custom/CustomView.ts | 5 ++-- src/export/option.ts | 13 +++++++-- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts index c34cbdf148..7167274ad9 100644 --- a/src/chart/custom/CustomSeries.ts +++ b/src/chart/custom/CustomSeries.ts @@ -158,9 +158,6 @@ export interface CustomBaseElementOption extends Partial & TransitionAnyOption; // updateDuringAnimation during?(params: CustomBaseDuringAPI): void; - - focus?: 'none' | 'self' | 'series' | ArrayLike - blurScope?: BlurScope }; export interface CustomDisplayableOption extends CustomBaseElementOption, Partial @@ -204,17 +201,17 @@ export interface CustomBaseZRPathOption + rect: Partial + sector: Partial + poygon: Partial + polyline: Partial + line: Partial + arc: Partial + bezierCurve: Partial + ring: Partial + ellipse: Partial + compoundPath: Partial } interface CustomSVGPathShapeOption { @@ -270,7 +267,10 @@ export type CustomElementOption = CustomPathOption | CustomGroupOption; // Can only set focus, blur on the root element. -export type CustomChildElementOption = Omit; +export type CustomRootElementOption = CustomElementOption & { + focus?: 'none' | 'self' | 'series' | ArrayLike + blurScope?: BlurScope +}; export type CustomElementOptionOnState = CustomDisplayableOptionOnState | CustomImageOptionOnState; @@ -287,7 +287,13 @@ export interface CustomSeriesRenderItemAPI extends value(dim: DimensionLoose, dataIndexInside?: number): ParsedValue; ordinalRawValue(dim: DimensionLoose, dataIndexInside?: number): ParsedValue | OrdinalRawValue; + /** + * @deprecated + */ style(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps; + /** + * @deprecated + */ styleEmphasis(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps; visual( visualType: VT, @@ -310,7 +316,7 @@ export interface CustomSeriesRenderItemCoordinateSystemAPI { ): number[]; size?( dataSize: OptionDataValue | OptionDataValue[], - dataItem: OptionDataValue | OptionDataValue[] + dataItem?: OptionDataValue | OptionDataValue[] ): number | number[]; } @@ -330,6 +336,9 @@ export interface CustomSeriesRenderItemParams { actionType?: string; } + +export type CustomSeriesRenderItemReturn = CustomRootElementOption; + type CustomSeriesRenderItem = ( params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI @@ -354,7 +363,7 @@ export interface CustomSeriesOption extends /** * @deprecated */ - itemStyle?: ItemStyleOption; + itemStyle?: ItemStyleOption; /** * @deprecated */ diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts index ae042b7f22..f084d84228 100644 --- a/src/chart/custom/CustomView.ts +++ b/src/chart/custom/CustomView.ts @@ -91,7 +91,8 @@ import CustomSeriesModel, { customInnerStore, LooseElementProps, PrepareCustomInfo, - CustomPathOption + CustomPathOption, + CustomRootElementOption } from './CustomSeries'; import { prepareShapeOrExtraAllPropsFinal, @@ -1148,7 +1149,7 @@ function createOrUpdateItem( api: ExtensionAPI, existsEl: Element, dataIndex: number, - elOption: CustomElementOption, + elOption: CustomRootElementOption, seriesModel: CustomSeriesModel, group: ViewRootGroup, data: SeriesData diff --git a/src/export/option.ts b/src/export/option.ts index 7ed1b4b35e..c3256c3f22 100644 --- a/src/export/option.ts +++ b/src/export/option.ts @@ -86,7 +86,12 @@ import type {HeatmapSeriesOption as HeatmapSeriesOptionInner} from '../chart/hea import type {PictorialBarSeriesOption as PictorialBarSeriesOptionInner} from '../chart/bar/PictorialBarSeries'; import type {ThemeRiverSeriesOption as ThemeRiverSeriesOptionInner} from '../chart/themeRiver/ThemeRiverSeries'; import type {SunburstSeriesOption as SunburstSeriesOptionInner} from '../chart/sunburst/SunburstSeries'; -import type {CustomSeriesOption as CustomSeriesOptionInner} from '../chart/custom/CustomSeries'; +import type { + CustomSeriesOption as CustomSeriesOptionInner, + CustomSeriesRenderItemAPI, + CustomSeriesRenderItemParams, + CustomSeriesRenderItemReturn +} from '../chart/custom/CustomSeries'; import type { GraphicComponentLooseOption as GraphicComponentOption } from '../component/graphic/install'; import type { DatasetOption as DatasetComponentOption } from '../component/dataset/install'; @@ -264,5 +269,9 @@ export { TooltipFormatterCallback as TooltipComponentFormatterCallback, TopLevelFormatterParams as TooltipComponentFormatterCallbackParams, TooltipPositionCallback as TooltipComponentPositionCallback, - TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams + TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams, + + CustomSeriesRenderItemParams, + CustomSeriesRenderItemAPI, + CustomSeriesRenderItemReturn }; From a7e1e7fcb12e803d61ede99127fd3d8ebda9d2d4 Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 9 Sep 2021 13:21:07 +0800 Subject: [PATCH 29/40] fix(type): optimize custom renderItem return type. expose renderItem type --- src/chart/custom/CustomSeries.ts | 8 ++++---- src/export/option.ts | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts index 7167274ad9..8fa8285c77 100644 --- a/src/chart/custom/CustomSeries.ts +++ b/src/chart/custom/CustomSeries.ts @@ -204,7 +204,7 @@ interface BuiltinShapes { circle: Partial rect: Partial sector: Partial - poygon: Partial + polygon: Partial polyline: Partial line: Partial arc: Partial @@ -337,12 +337,12 @@ export interface CustomSeriesRenderItemParams { actionType?: string; } -export type CustomSeriesRenderItemReturn = CustomRootElementOption; +export type CustomSeriesRenderItemReturn = CustomRootElementOption | undefined | null; -type CustomSeriesRenderItem = ( +export type CustomSeriesRenderItem = ( params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI -) => CustomElementOption; +) => CustomSeriesRenderItemReturn; export interface CustomSeriesOption extends SeriesOption, // don't support StateOption in custom series. diff --git a/src/export/option.ts b/src/export/option.ts index c3256c3f22..4980e4304f 100644 --- a/src/export/option.ts +++ b/src/export/option.ts @@ -90,7 +90,8 @@ import type { CustomSeriesOption as CustomSeriesOptionInner, CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams, - CustomSeriesRenderItemReturn + CustomSeriesRenderItemReturn, + CustomSeriesRenderItem } from '../chart/custom/CustomSeries'; import type { GraphicComponentLooseOption as GraphicComponentOption } from '../component/graphic/install'; @@ -273,5 +274,6 @@ export { CustomSeriesRenderItemParams, CustomSeriesRenderItemAPI, - CustomSeriesRenderItemReturn + CustomSeriesRenderItemReturn, + CustomSeriesRenderItem }; From 8e4fbc983989c02f23d3116814b5d6eaf3f941ed Mon Sep 17 00:00:00 2001 From: pissang Date: Thu, 9 Sep 2021 14:03:56 +0800 Subject: [PATCH 30/40] style: fix missing comma --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 1941965fbe..811908a873 100644 --- a/index.d.ts +++ b/index.d.ts @@ -19,5 +19,5 @@ import * as echarts from './types/dist/echarts'; // Export for UMD module. -export as namespace echarts +export as namespace echarts; export = echarts; \ No newline at end of file From c5fcf823c94fab88739ed91ba6546da375c8e6ed Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 10 Sep 2021 13:12:38 +0800 Subject: [PATCH 31/40] fix(sunburst): radius in levels --- src/chart/sunburst/SunburstSeries.ts | 19 +++++++++++++++- src/chart/sunburst/sunburstLayout.ts | 33 +++++++++++++++++++--------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/chart/sunburst/SunburstSeries.ts b/src/chart/sunburst/SunburstSeries.ts index f7d801c0a9..06ba99abc2 100644 --- a/src/chart/sunburst/SunburstSeries.ts +++ b/src/chart/sunburst/SunburstSeries.ts @@ -94,6 +94,17 @@ export interface SunburstSeriesNodeItemOption extends } export interface SunburstSeriesLevelOption extends SunburstStateOption, StatesOptionMixin { + + radius?: number | number[] + /** + * @deprecated use radius instead + */ + r?: number + /** + * @deprecated use radius instead + */ + r0?: number + highlight?: { itemStyle?: SunburstItemStyleOption label?: SunburstLabelOption @@ -152,6 +163,7 @@ class SunburstSeriesModel extends SeriesModel { ignoreStyleOnData = true; private _viewRoot: TreeNode; + private _levelModels: Model[]; getInitialData(option: SunburstSeriesOption, ecModel: GlobalModel) { // Create a virtual root. @@ -159,9 +171,10 @@ class SunburstSeriesModel extends SeriesModel { completeTreeValue(root); - const levelModels = zrUtil.map(option.levels || [], function (levelDefine) { + this._levelModels = zrUtil.map(option.levels || [], function (levelDefine) { return new Model(levelDefine, this, ecModel); }, this); + const levelModels = this._levelModels; // Make sure always a new tree is created when setOption, // in TreemapView, we check whether oldTree === newTree @@ -195,6 +208,10 @@ class SunburstSeriesModel extends SeriesModel { return params; } + getLevelModel(node: TreeNode) { + return this._levelModels && this._levelModels[node.depth]; + } + static defaultOption: SunburstSeriesOption = { zlevel: 0, z: 2, diff --git a/src/chart/sunburst/sunburstLayout.ts b/src/chart/sunburst/sunburstLayout.ts index b2a15e86c5..f6c2c97c97 100644 --- a/src/chart/sunburst/sunburstLayout.ts +++ b/src/chart/sunburst/sunburstLayout.ts @@ -23,6 +23,7 @@ import GlobalModel from '../../model/Global'; import ExtensionAPI from '../../core/ExtensionAPI'; import SunburstSeriesModel, { SunburstSeriesNodeItemOption, SunburstSeriesOption } from './SunburstSeries'; import { TreeNode } from '../../data/Tree'; +import SeriesModel from '../../model/Series'; // let PI2 = Math.PI * 2; const RADIAN = Math.PI / 180; @@ -119,16 +120,28 @@ export default function sunburstLayout( let rStart = r0 + rPerLevel * depth; let rEnd = r0 + rPerLevel * (depth + 1); - const itemModel = node.getModel(); - // @ts-ignore. TODO this is not provided to developer yet. Rename it. - if (itemModel.get('r0') != null) { - // @ts-ignore - rStart = parsePercent(itemModel.get('r0'), size / 2); - } - // @ts-ignore - if (itemModel.get('r') != null) { - // @ts-ignore - rEnd = parsePercent(itemModel.get('r'), size / 2); + const levelModel = seriesModel.getLevelModel(node); + if (levelModel) { + const r0 = levelModel.get('r0', true); + if (r0 != null) { + // Compatible with deprecated r0 + rStart = parsePercent(r0, size / 2); + } + const r = levelModel.get('r', true); + if (r != null) { + // Compatible with deprecated r + rEnd = parsePercent(r, size / 2); + } + + // level-specific radius should override that of series + let radius: number | number[] = levelModel.get('radius', true); + if (radius != null) { + if (typeof radius === 'number') { + radius = [radius, radius]; + } + rStart = parsePercent(radius[0], size / 2); + rEnd = parsePercent(radius[1], size / 2); + } } node.setLayout({ From dd1890b851a35f6357096957068962bf278f81eb Mon Sep 17 00:00:00 2001 From: Ovilia Date: Fri, 10 Sep 2021 14:08:22 +0800 Subject: [PATCH 32/40] fix(sunburst): improve code --- src/chart/sunburst/SunburstSeries.ts | 14 +++++++------- src/chart/sunburst/sunburstLayout.ts | 25 ++++++++----------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/chart/sunburst/SunburstSeries.ts b/src/chart/sunburst/SunburstSeries.ts index 06ba99abc2..344cbc6e4d 100644 --- a/src/chart/sunburst/SunburstSeries.ts +++ b/src/chart/sunburst/SunburstSeries.ts @@ -95,15 +95,15 @@ export interface SunburstSeriesNodeItemOption extends export interface SunburstSeriesLevelOption extends SunburstStateOption, StatesOptionMixin { - radius?: number | number[] + radius?: (number | string)[] /** * @deprecated use radius instead */ - r?: number + r?: number | string /** * @deprecated use radius instead */ - r0?: number + r0?: number | string highlight?: { itemStyle?: SunburstItemStyleOption @@ -171,10 +171,10 @@ class SunburstSeriesModel extends SeriesModel { completeTreeValue(root); - this._levelModels = zrUtil.map(option.levels || [], function (levelDefine) { - return new Model(levelDefine, this, ecModel); - }, this); - const levelModels = this._levelModels; + const levelModels = this._levelModels + = zrUtil.map(option.levels || [], function (levelDefine) { + return new Model(levelDefine, this, ecModel); + }, this); // Make sure always a new tree is created when setOption, // in TreemapView, we check whether oldTree === newTree diff --git a/src/chart/sunburst/sunburstLayout.ts b/src/chart/sunburst/sunburstLayout.ts index f6c2c97c97..5578eadc9d 100644 --- a/src/chart/sunburst/sunburstLayout.ts +++ b/src/chart/sunburst/sunburstLayout.ts @@ -122,26 +122,17 @@ export default function sunburstLayout( const levelModel = seriesModel.getLevelModel(node); if (levelModel) { - const r0 = levelModel.get('r0', true); - if (r0 != null) { - // Compatible with deprecated r0 - rStart = parsePercent(r0, size / 2); - } - const r = levelModel.get('r', true); - if (r != null) { - // Compatible with deprecated r - rEnd = parsePercent(r, size / 2); - } + let r0 = levelModel.get('r0', true); + let r = levelModel.get('r', true); + let radius = levelModel.get('radius', true); - // level-specific radius should override that of series - let radius: number | number[] = levelModel.get('radius', true); if (radius != null) { - if (typeof radius === 'number') { - radius = [radius, radius]; - } - rStart = parsePercent(radius[0], size / 2); - rEnd = parsePercent(radius[1], size / 2); + r0 = radius[0]; + r = radius[1]; } + + (r0 != null) && (rStart = parsePercent(r0, size / 2)); + (r != null) && (rEnd = parsePercent(r, size / 2)); } node.setLayout({ From 344b648c479f648bdbd6c361b4a02715fc49c6b3 Mon Sep 17 00:00:00 2001 From: pissang Date: Mon, 13 Sep 2021 13:48:59 +0800 Subject: [PATCH 33/40] fix(line): soft clipping gradient. --- src/chart/line/LineView.ts | 97 +++++++++---- src/export/core.ts | 2 +- ...linear-gradient.html => line-visual2.html} | 131 +++++++++++++++++- test/runTest/actions/__meta__.json | 1 + test/runTest/actions/line-visual2.json | 1 + 5 files changed, 205 insertions(+), 27 deletions(-) rename test/{linear-gradient.html => line-visual2.html} (55%) create mode 100644 test/runTest/actions/line-visual2.json diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index 6103b32802..fa4b3a95a7 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -56,6 +56,7 @@ import {getDefaultLabel, getDefaultInterpolatedLabel} from '../helper/labelHelpe import { getECData } from '../../util/innerStore'; import { createFloat32Array } from '../../util/vendor'; import { convertToColorString } from '../../util/format'; +import { lerp } from 'zrender/src/tool/color'; type PolarArea = ReturnType; type Cartesian2DArea = ReturnType; @@ -191,9 +192,56 @@ function turnPointsIntoStep( return stepPoints; } +/** + * Clip color stops to edge. Avoid creating too large gradients. + * Which may lead to blurry when GPU acceleration is enabled. See #15680 + * + * The stops has been sorted from small to large. + */ +function clipColorStops(colorStops: ColorStop[], maxSize: number): ColorStop[] { + const newColorStops: ColorStop[] = []; + const len = colorStops.length; + // coord will always < 0 in prevOutOfRangeColorStop. + let prevOutOfRangeColorStop: ColorStop; + let prevInRangeColorStop: ColorStop; + + function lerpStop(stop0: ColorStop, stop1: ColorStop, clippedCoord: number) { + const coord0 = stop0.coord; + const p = (clippedCoord - coord0) / (stop1.coord - coord0); + const color = lerp(p, [stop0.color, stop1.color]) as string; + return { coord: clippedCoord, color } as ColorStop; + } + + for (let i = 0; i < len; i++) { + const stop = colorStops[i]; + const coord = stop.coord; + if (coord < 0) { + prevOutOfRangeColorStop = stop; + } + else if (coord > maxSize) { + if (prevInRangeColorStop) { + newColorStops.push(lerpStop(prevInRangeColorStop, stop, maxSize)); + } + // All following stop will be out of range. So just ignore them. + break; + } + else { + if (prevOutOfRangeColorStop) { + newColorStops.push(lerpStop(prevOutOfRangeColorStop, stop, 0)); + // Reset + prevOutOfRangeColorStop = null; + } + newColorStops.push(stop); + prevInRangeColorStop = stop; + } + } + return newColorStops; +} + function getVisualGradient( data: SeriesData, - coordSys: Cartesian2D | Polar + coordSys: Cartesian2D | Polar, + api: ExtensionAPI ) { const visualMetaList = data.getVisual('visualMeta'); if (!visualMetaList || !visualMetaList.length || !data.count()) { @@ -236,19 +284,14 @@ function getVisualGradient( // LinearGradient to render `outerColors`. const axis = coordSys.getAxis(coordDim); - const axisScaleExtent = axis.scale.getExtent(); // dataToCoord mapping may not be linear, but must be monotonic. const colorStops: ColorStop[] = zrUtil.map(visualMeta.stops, function (stop) { - let coord = axis.toGlobalCoord(axis.dataToCoord(stop.value)); - // normalize the infinite value - isNaN(coord) || isFinite(coord) - || (coord = axis.toGlobalCoord(axis.dataToCoord(axisScaleExtent[+(coord < 0)]))); + // offset will be calculated later. return { - offset: 0, - coord, + coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)), color: stop.color - }; + } as ColorStop; }); const stopLen = colorStops.length; const outerColors = visualMeta.outerColors.slice(); @@ -257,34 +300,40 @@ function getVisualGradient( colorStops.reverse(); outerColors.reverse(); } + const colorStopsInRange = clipColorStops( + colorStops, coordDim === 'x' ? api.getWidth() : api.getHeight() + ); + const inRangeStopLen = colorStopsInRange.length; + if (!inRangeStopLen && stopLen) { + // All stops are out of range. All will be the same color. + return colorStops[0].coord < 0 + ? (outerColors[1] ? outerColors[1] : colorStops[stopLen - 1].color) + : (outerColors[0] ? outerColors[0] : colorStops[0].color); + } - const tinyExtent = 10; // Arbitrary value: 10px - const minCoord = colorStops[0].coord - tinyExtent; - const maxCoord = colorStops[stopLen - 1].coord + tinyExtent; + const tinyExtent = 0; // Arbitrary value: 10px + const minCoord = colorStopsInRange[0].coord - tinyExtent; + const maxCoord = colorStopsInRange[inRangeStopLen - 1].coord + tinyExtent; const coordSpan = maxCoord - minCoord; if (coordSpan < 1e-3) { return 'transparent'; } - zrUtil.each(colorStops, function (stop) { + zrUtil.each(colorStopsInRange, function (stop) { stop.offset = (stop.coord - minCoord) / coordSpan; }); - colorStops.push({ - offset: stopLen ? colorStops[stopLen - 1].offset : 0.5, + colorStopsInRange.push({ + // NOTE: inRangeStopLen may still be 0 if stoplen is zero. + offset: inRangeStopLen ? colorStopsInRange[inRangeStopLen - 1].offset : 0.5, color: outerColors[1] || 'transparent' }); - colorStops.unshift({ // notice colorStops.length have been changed. - offset: stopLen ? colorStops[0].offset : 0.5, + colorStopsInRange.unshift({ // notice newColorStops.length have been changed. + offset: inRangeStopLen ? colorStopsInRange[0].offset : 0.5, color: outerColors[0] || 'transparent' }); - // zrUtil.each(colorStops, function (colorStop) { - // // Make sure each offset has rounded px to avoid not sharp edge - // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start); - // }); - - const gradient = new graphic.LinearGradient(0, 0, 0, 0, colorStops, true); + const gradient = new graphic.LinearGradient(0, 0, 0, 0, colorStopsInRange, true); gradient[coordDim] = minCoord; gradient[coordDim + '2' as 'x2' | 'y2'] = maxCoord; @@ -626,7 +675,7 @@ class LineView extends ChartView { } } this._clipShapeForSymbol = clipShapeForSymbol; - const visualColor = getVisualGradient(data, coordSys) + const visualColor = getVisualGradient(data, coordSys, api) || data.getVisual('style')[data.getVisual('drawType')]; // Initialization animation or coordinate system changed if ( diff --git a/src/export/core.ts b/src/export/core.ts index c1702f2154..d17b784b0e 100644 --- a/src/export/core.ts +++ b/src/export/core.ts @@ -24,7 +24,7 @@ export * from './api'; import { use } from '../extension'; // Import label layout by default. -// TODO remove +// TODO will be treeshaked. import {installLabelLayout} from '../label/installLabelLayout'; use(installLabelLayout); diff --git a/test/linear-gradient.html b/test/line-visual2.html similarity index 55% rename from test/linear-gradient.html rename to test/line-visual2.html index 5ec82008ac..44f2b9ba2d 100644 --- a/test/linear-gradient.html +++ b/test/line-visual2.html @@ -40,6 +40,7 @@
+
@@ -151,8 +152,7 @@ 'The series with log axis should be rendered without errors in console', 'https://github.com/apache/echarts/issues/14601' ], - option: option, - height: 600 + option: option }); }) @@ -367,6 +367,133 @@ + diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 28341e7bd1..54321c5bc5 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -114,6 +114,7 @@ "line-crash": 1, "line-endLabel": 1, "line-extraneous": 2, + "line-visual2": 1, "lines-bus": 1, "map": 3, "map-contour": 2, diff --git a/test/runTest/actions/line-visual2.json b/test/runTest/actions/line-visual2.json new file mode 100644 index 0000000000..f5286b345a --- /dev/null +++ b/test/runTest/actions/line-visual2.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousedown","time":425,"x":45,"y":185},{"type":"mouseup","time":524,"x":45,"y":185},{"time":525,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":737,"x":45,"y":185},{"type":"mousemove","time":937,"x":112,"y":182},{"type":"mousemove","time":1174,"x":116,"y":182},{"type":"mousedown","time":1709,"x":116,"y":182},{"type":"mouseup","time":1770,"x":116,"y":182},{"time":1771,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":2054,"x":116,"y":182},{"type":"mousemove","time":2254,"x":190,"y":179},{"type":"mousemove","time":2461,"x":223,"y":178},{"type":"mousedown","time":2963,"x":223,"y":178},{"type":"mouseup","time":3045,"x":223,"y":178},{"time":3046,"delay":400,"type":"screenshot-auto"}],"scrollY":1345,"scrollX":0,"timestamp":1631512007469}] \ No newline at end of file From 7dbf36c40a91e2ecf3a7af8a20ed029df9a76574 Mon Sep 17 00:00:00 2001 From: pissang Date: Mon, 13 Sep 2021 16:13:07 +0800 Subject: [PATCH 34/40] fix(time): add `axisLabel.hideOverlap` --- src/component/axis/AxisBuilder.ts | 4 ++-- src/coord/axisCommonTypes.ts | 25 ++++++++++++++++--------- test/timeScale.html | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index 6fad867a6a..d06c0b5710 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -349,9 +349,9 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection); - // This bit fixes the label overlap issue for the Time chart. + // This bit fixes the label overlap issue for the time chart. // See https://github.com/apache/echarts/issues/14266 for more. - if (axisModel.get('type') === 'time') { + if (axisModel.get(['axisLabel', 'hideOverlap'])) { const labelList = prepareLayoutList(map(labelEls, label => ({ label, priority: label.z2, diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 0997f6716e..509173c033 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -64,15 +64,19 @@ export interface AxisBaseOptionCommon extends ComponentOption, minorSplitLine?: MinorSplitLineOption; splitArea?: SplitAreaOption; - // Min value of the axis. can be: - // + ScaleDataValue - // + 'dataMin': use the min value in data. - // + null/undefined: auto decide min value (consider pretty look and boundaryGap). + /** + * Min value of the axis. can be: + * + ScaleDataValue + * + 'dataMin': use the min value in data. + * + null/undefined: auto decide min value (consider pretty look and boundaryGap). + */ min?: ScaleDataValue | 'dataMin' | ((extent: {min: number, max: number}) => ScaleDataValue); - // Max value of the axis. can be: - // + ScaleDataValue - // + 'dataMax': use the max value in data. - // + null/undefined: auto decide max value (consider pretty look and boundaryGap). + /** + * Max value of the axis. can be: + * + ScaleDataValue + * + 'dataMax': use the max value in data. + * + null/undefined: auto decide max value (consider pretty look and boundaryGap). + */ max?: ScaleDataValue | 'dataMax' | ((extent: {min: number, max: number}) => ScaleDataValue); // Optional value can be: // + `false`: always include value 0. @@ -209,7 +213,10 @@ interface AxisLabelBaseOption extends Omit { showMaxLabel?: boolean, margin?: number, rich?: Dictionary - + /** + * If hide overlapping labels. + */ + hideOverlap?: boolean; // Color can be callback color?: ColorString | ((value?: string | number, index?: number) => ColorString) } diff --git a/test/timeScale.html b/test/timeScale.html index cf9bfc2cbb..47370f0e8b 100644 --- a/test/timeScale.html +++ b/test/timeScale.html @@ -153,6 +153,7 @@ min: 'dataMin', max: 'dataMax', axisLabel: { + hideOverlap: true } } ], From fc507c0713faf53ce50a1bfffc1d2f0af587d366 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Mon, 13 Sep 2021 16:52:19 +0800 Subject: [PATCH 35/40] test(polar): update test case --- test/{bar-polar-basic.html => bar-polar-clockwise.html} | 0 test/runTest/actions/__meta__.json | 2 +- test/runTest/actions/bar-polar-clockwise.json | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) rename test/{bar-polar-basic.html => bar-polar-clockwise.html} (100%) create mode 100644 test/runTest/actions/bar-polar-clockwise.json diff --git a/test/bar-polar-basic.html b/test/bar-polar-clockwise.html similarity index 100% rename from test/bar-polar-basic.html rename to test/bar-polar-clockwise.html diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 5e26a0a452..fd4327a6f5 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -21,7 +21,7 @@ "bar-label-rotation": 2, "bar-large": 2, "bar-overflow-time-plot": 3, - "bar-polar-basic": 1, + "bar-polar-clockwise": 1, "bar-polar-multi-series": 1, "bar-polar-multi-series-radial": 1, "bar-polar-null-data-radial": 1, diff --git a/test/runTest/actions/bar-polar-clockwise.json b/test/runTest/actions/bar-polar-clockwise.json new file mode 100644 index 0000000000..9dbcc44e11 --- /dev/null +++ b/test/runTest/actions/bar-polar-clockwise.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousedown","time":1234,"x":34,"y":125},{"type":"mouseup","time":1393,"x":34,"y":125},{"time":1394,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1631523020115}] \ No newline at end of file From 3bea75a994ffb9ebb01ea1e6927c912b9cc9606a Mon Sep 17 00:00:00 2001 From: pissang Date: Tue, 14 Sep 2021 10:16:18 +0800 Subject: [PATCH 36/40] test: optimize test cases for visual regression test --- test/line-animation.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/line-animation.html b/test/line-animation.html index 853e3b8154..9ce3c38af2 100644 --- a/test/line-animation.html +++ b/test/line-animation.html @@ -49,8 +49,6 @@ } -
-
@@ -61,6 +59,8 @@

Default Label Animation

Label Animation with animationDelay callback

+

Line Animation should be continued when calling setOption again.

+
@@ -424,8 +424,8 @@

Label Animation with animationDelay callback

type: 'line', areaStyle: {} }], - animationDuration: 5000, - animationDurationUpdate: 5000 + animationDuration: 10000, + animationDurationUpdate: 10000 }; chart.setOption(option); From 35e35119b55cd36d1cb4936912ebeebe4e2cd78a Mon Sep 17 00:00:00 2001 From: pissang Date: Tue, 14 Sep 2021 15:02:54 +0800 Subject: [PATCH 37/40] fix(legend): add back symbolKeepAspect. optimize code logic. --- src/component/legend/LegendModel.ts | 32 ++++--- src/component/legend/LegendView.ts | 127 +++++++++++----------------- test/runTest/server.js | 2 +- 3 files changed, 64 insertions(+), 97 deletions(-) diff --git a/src/component/legend/LegendModel.ts b/src/component/legend/LegendModel.ts index 9026471423..855bcdd9ac 100644 --- a/src/component/legend/LegendModel.ts +++ b/src/component/legend/LegendModel.ts @@ -115,6 +115,11 @@ export interface LegendStyleOption { textStyle?: LabelOption symbolRotate?: number | 'inherit' + + /** + * @deprecated + */ + symbolKeepAspect?: boolean } interface DataItem extends LegendStyleOption { @@ -134,19 +139,20 @@ export interface LegendTooltipFormatterParams { } export interface LegendIconParams { - itemWidth: number, - itemHeight: number, + itemWidth: number + itemHeight: number /** * symbolType is from legend.icon, legend.data.icon, or series visual */ - icon: string, - iconRotate: number | 'inherit', - itemStyle: PathStyleProps, + icon: string + iconRotate: number | 'inherit' + symbolKeepAspect: boolean + itemStyle: PathStyleProps lineStyle: LineStyleProps } export interface LegendSymbolStyleOption { - itemStyle?: ItemStyleProps, + itemStyle?: ItemStyleProps lineStyle?: LineStyleProps } @@ -454,6 +460,7 @@ class LegendModel extends ComponentMode itemWidth: 25, itemHeight: 14, symbolRotate: 'inherit', + symbolKeepAspect: true, inactiveColor: '#ccc', inactiveBorderColor: '#ccc', @@ -462,11 +469,6 @@ class LegendModel extends ComponentMode itemStyle: { color: 'inherit', opacity: 'inherit', - decal: 'inherit', - shadowBlur: 0, - shadowColor: null, - shadowOffsetX: 0, - shadowOffsetY: 0, borderColor: 'inherit', borderWidth: 'auto', borderCap: 'inherit', @@ -485,11 +487,7 @@ class LegendModel extends ComponentMode cap: 'inherit', join: 'inherit', dashOffset: 'inherit', - miterLimit: 'inherit', - shadowBlur: 0, - shadowColor: null, - shadowOffsetX: 0, - shadowOffsetY: 0 + miterLimit: 'inherit' }, textStyle: { @@ -504,7 +502,7 @@ class LegendModel extends ComponentMode borderRadius: 10, padding: [3, 5, 3, 5], fontSize: 12, - fontFamily: ' sans-serif', + fontFamily: 'sans-serif', color: '#666', borderWidth: 1, borderColor: '#666' diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts index 5e064fd5fe..f7ce4f5126 100644 --- a/src/component/legend/LegendView.ts +++ b/src/component/legend/LegendView.ts @@ -347,16 +347,15 @@ class LegendView extends ComponentView { const itemHeight = legendModel.get('itemHeight'); const isSelected = legendModel.isSelected(name); - let iconRotate = legendItemModel.get('symbolRotate'); + const iconRotate = legendItemModel.get('symbolRotate'); + const symbolKeepAspect = legendItemModel.get('symbolKeepAspect'); const legendIconType = legendItemModel.get('icon'); legendIcon = legendIconType || legendIcon || 'roundRect'; - const legendLineStyle = legendModel.getModel('lineStyle'); const style = getLegendStyle( legendIcon, legendItemModel, - legendLineStyle, lineVisualStyle, itemVisualStyle, drawType, @@ -377,7 +376,8 @@ class LegendView extends ComponentView { icon: legendIcon, iconRotate: iconRotate, itemStyle: style.itemStyle, - lineStyle: style.lineStyle + lineStyle: style.lineStyle, + symbolKeepAspect })); } else { @@ -394,7 +394,8 @@ class LegendView extends ComponentView { icon: legendIcon, iconRotate: rotate, itemStyle: style.itemStyle, - lineStyle: style.lineStyle + lineStyle: style.lineStyle, + symbolKeepAspect })); } @@ -540,8 +541,7 @@ class LegendView extends ComponentView { function getLegendStyle( iconType: string, legendModel: LegendModel['_data'][number], - legendLineStyle: Model, - lineVisualStyle: LineStyleProps, + lineVisualStyle: PathStyleProps, itemVisualStyle: PathStyleProps, drawType: 'fill' | 'stroke', isSelected: boolean @@ -550,81 +550,49 @@ function getLegendStyle( * Use series style if is inherit; * elsewise, use legend style */ + function handleCommonProps(style: PathStyleProps, visualStyle: PathStyleProps) { + // If lineStyle.width is 'auto', it is set to be 2 if series has border + if ((style.lineWidth as any) === 'auto') { + style.lineWidth = (visualStyle.lineWidth > 0) ? 2 : 0; + } + + each(style, (propVal, propName) => { + style[propName] === 'inherit' && ((style as any)[propName] = visualStyle[propName]); + }); + } // itemStyle const legendItemModel = legendModel.getModel('itemStyle') as Model; - const itemProperties = ITEM_STYLE_KEY_MAP.concat([ - ['decal'] - ]); - const itemStyle: PathStyleProps = {}; - for (let i = 0; i < itemProperties.length; ++i) { - const propName = itemProperties[i][ - itemProperties[i].length - 1 - ] as keyof LegendItemStyleOption; - const visualName = itemProperties[i][0] as keyof PathStyleProps; - const value = legendItemModel.getShallow(propName) as LegendItemStyleOption[keyof LegendItemStyleOption]; - if (value === 'inherit') { - switch (visualName) { - case 'fill': - /** - * Series with visualDrawType as 'stroke' should have - * series stroke as legend fill - */ - itemStyle.fill = itemVisualStyle[drawType]; - break; - - case 'stroke': - /** - * icon type with "emptyXXX" should use fill color - * in visual style - */ - itemStyle.stroke = itemVisualStyle[ - iconType.lastIndexOf('empty', 0) === 0 ? 'fill' : 'stroke' - ]; - break; - - case 'opacity': - /** - * Use lineStyle.opacity if drawType is stroke - */ - itemStyle.opacity = (drawType === 'fill' ? itemVisualStyle : lineVisualStyle).opacity; - break; - - default: - (itemStyle as any)[visualName] = itemVisualStyle[visualName]; - } - } - else if (value === 'auto' && visualName === 'lineWidth') { - // If lineStyle.width is 'auto', it is set to be 2 if series has border - itemStyle.lineWidth = (itemVisualStyle.lineWidth > 0) ? 2 : 0; - } - else { - (itemStyle as any)[visualName] = value; - } + const itemStyle = legendItemModel.getItemStyle(); + const iconBrushType = iconType.lastIndexOf('empty', 0) === 0 ? 'fill' : 'stroke'; + + itemStyle.decal = itemVisualStyle.decal; + if (itemStyle.fill === 'inherit') { + /** + * Series with visualDrawType as 'stroke' should have + * series stroke as legend fill + */ + itemStyle.fill = itemVisualStyle[drawType]; } + if (itemStyle.stroke === 'inherit') { + /** + * icon type with "emptyXXX" should use fill color + * in visual style + */ + itemStyle.stroke = itemVisualStyle[iconBrushType]; + } + if ((itemStyle.opacity as any) === 'inherit') { + /** + * Use lineStyle.opacity if drawType is stroke + */ + itemStyle.opacity = (drawType === 'fill' ? itemVisualStyle : lineVisualStyle).opacity; + } + handleCommonProps(itemStyle, itemVisualStyle); // lineStyle const legendLineModel = legendModel.getModel('lineStyle') as Model; - const lineProperties = LINE_STYLE_KEY_MAP.concat([ - ['inactiveColor'], - ['inactiveWidth'] - ]); - const lineStyle: LineStyleProps = {}; - for (let i = 0; i < lineProperties.length; ++i) { - const propName = lineProperties[i][1] as keyof LegendLineStyleOption; - const visualName = lineProperties[i][0] as keyof LineStyleProps; - const value = legendLineModel.getShallow(propName) as LegendLineStyleOption[keyof LegendLineStyleOption]; - if (value === 'inherit') { - (lineStyle as any)[visualName] = lineVisualStyle[visualName]; - } - else if (value === 'auto' && visualName === 'lineWidth') { - // If lineStyle.width is 'auto', it is set to be 2 if series has border - lineStyle.lineWidth = lineVisualStyle.lineWidth > 0 ? 2 : 0; - } - else { - (lineStyle as any)[visualName] = value; - } - } + const lineStyle: LineStyleProps = legendLineModel.getLineStyle(); + handleCommonProps(lineStyle, lineVisualStyle); // Fix auto color to real color (itemStyle.fill === 'auto') && (itemStyle.fill = itemVisualStyle.fill); @@ -638,14 +606,14 @@ function getLegendStyle( * there is no border in series but border in legend, so we need to * use border only when series has border if is set to be auto */ - const visualHasBorder = itemStyle[iconType.indexOf('empty') > -1 ? 'fill' : 'stroke']; + const visualHasBorder = itemStyle[iconBrushType]; itemStyle.lineWidth = borderWidth === 'auto' ? (itemVisualStyle.lineWidth > 0 && visualHasBorder ? 2 : 0) : itemStyle.lineWidth; itemStyle.fill = legendModel.get('inactiveColor'); itemStyle.stroke = legendModel.get('inactiveBorderColor'); - lineStyle.stroke = legendLineStyle.get('inactiveColor'); - lineStyle.lineWidth = legendLineStyle.get('inactiveWidth'); + lineStyle.stroke = legendLineModel.get('inactiveColor'); + lineStyle.lineWidth = legendLineModel.get('inactiveWidth'); } return { itemStyle, lineStyle }; } @@ -658,7 +626,8 @@ function getDefaultLegendIcon(opt: LegendIconParams): ECSymbol { 0, opt.itemWidth, opt.itemHeight, - opt.itemStyle.fill + opt.itemStyle.fill, + opt.symbolKeepAspect ); icon.setStyle(opt.itemStyle); diff --git a/test/runTest/server.js b/test/runTest/server.js index 1e224ac22c..f74b001956 100644 --- a/test/runTest/server.js +++ b/test/runTest/server.js @@ -229,7 +229,7 @@ async function start() { let {io} = serve(); const stableVersions = await fetchVersions(false); - const nightlyVersions = await fetchVersions(true); + const nightlyVersions = (await fetchVersions(true)).slice(0, 100); stableVersions.unshift('local'); nightlyVersions.unshift('local'); From b98affc91ad4dae48b1fe51458da789641f2fab7 Mon Sep 17 00:00:00 2001 From: williamorim Date: Tue, 14 Sep 2021 16:45:28 -0300 Subject: [PATCH 38/40] Adding pt-BR lang file --- src/i18n/langPT-br.ts | 142 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 src/i18n/langPT-br.ts diff --git a/src/i18n/langPT-br.ts b/src/i18n/langPT-br.ts new file mode 100644 index 0000000000..8cdd26249f --- /dev/null +++ b/src/i18n/langPT-br.ts @@ -0,0 +1,142 @@ +/* +* 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. +*/ + +/** + * Language: Portuguese (Brazil). + */ + +export default { + time: { + month: [ + "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" + ], + monthAbbr: [ + "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", + "Jul", "Ago", "Set", "Out", "Nov", "Dez" + ], + dayOfWeek: [ + "Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", +"Quinta-feira", "Sexta-feira", "Sábado" + ], + dayOfWeekAbbr: [ + "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb" + ] + }, + legend: { + selector: { + all: 'Todas', + inverse: 'Inv' + } + }, + toolbox: { + brush: { + title: { + rect: 'Seleção retangular', + polygon: 'Seleção em laço', + lineX: 'Selecionar horizontalmente', + lineY: 'Selecionar verticalmente', + keep: 'Manter seleções', + clear: 'Limpar seleções' + } + }, + dataView: { + title: 'Exibição de dados', + lang: ['Exibição de dados', 'Fechar', 'Atualizar'] + }, + dataZoom: { + title: { + zoom: 'Zoom', + back: 'Restaurar Zoom' + } + }, + magicType: { + title: { + line: 'Trocar para gráfico de linhas', + bar: 'Trocar para gráfico de barras', + stack: 'Empilhar', + tiled: 'Tile' + } + }, + restore: { + title: 'Restore' + }, + saveAsImage: { + title: 'Salvar como imagem', + lang: ['Clique com o botão direito para salvar imagem'] + } + }, + series: { + typeNames: { + pie: 'Gráfico de pizza', + bar: 'Gráfico de barras', + line: 'Gráfico de linhas', + scatter: 'Gráfico de dispersão', + effectScatter: 'Gráfico de dispersão ondulado', + radar: 'Gráfico radar', + tree: 'Árvore', + treemap: 'Treemap', + boxplot: 'Boxplot', + candlestick: 'Candlestick', + k: 'Gráfico K line', + heatmap: 'Mapa de calor', + map: 'Mapa', + parallel: 'Coordenadas paralelas', + lines: 'Gráfico de linhas', + graph: 'Relationship graph', + sankey: 'Gráfico Sankey', + funnel: 'Gráfico de funil', + gauge: 'Gauge', + pictorialBar: 'Pictorial bar', + themeRiver: 'Theme River Map', + sunburst: 'Sunburst' + } + }, + aria: { + general: { + withTitle: 'Este é um gráfico entitulado "{title}"', + withoutTitle: 'Este é um gráfico' + }, + series: { + single: { + prefix: '', + withName: ' do tipo {seriesType} nomeada/nomeado como {seriesName}.', + withoutName: ' do tipo {seriesType}.' + }, + multiple: { + prefix: '. Consiste de {seriesCount} séries.', + withName: ' A {seriesId} série é um/uma {seriesType} representando {seriesName}.', + withoutName: ' A {seriesId} series é um/uma {seriesType}.', + separator: { + middle: '', + end: '' + } + } + }, + data: { + allData: 'Os dados são: ', + partialData: 'As primeiros {displayCnt} itens são: ', + withName: 'os dados para {name} são {value}', + withoutName: '{value}', + separator: { + middle: ', ', + end: '. ' + } + } + } +}; From add3f76d84e5795074a9ba0f4d927415fc74f4fc Mon Sep 17 00:00:00 2001 From: williamorim Date: Tue, 14 Sep 2021 16:53:06 -0300 Subject: [PATCH 39/40] chaging double quotes for single quotes --- src/i18n/langPT-br.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/i18n/langPT-br.ts b/src/i18n/langPT-br.ts index 8cdd26249f..bd8c988a64 100644 --- a/src/i18n/langPT-br.ts +++ b/src/i18n/langPT-br.ts @@ -24,18 +24,18 @@ export default { time: { month: [ - "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" + 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ], monthAbbr: [ - "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", - "Jul", "Ago", "Set", "Out", "Nov", "Dez" + 'Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', + 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez' ], dayOfWeek: [ - "Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", -"Quinta-feira", "Sexta-feira", "Sábado" + 'Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', +'Quinta-feira', 'Sexta-feira', 'Sábado' ], dayOfWeekAbbr: [ - "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb" + 'Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb' ] }, legend: { From 4824ada974e035f508fa3e7eb0c926dc2db7c7bf Mon Sep 17 00:00:00 2001 From: pissang Date: Wed, 15 Sep 2021 17:26:05 +0800 Subject: [PATCH 40/40] fix(line): fix animation is not stopped when direct update points. --- src/chart/line/LineView.ts | 5 +- src/i18n/langPT-br.ts | 3 +- ...aneous.html => line-animation-update.html} | 106 ++++++++++++++++++ test/line-case.html | 3 - test/runTest/actions/__meta__.json | 2 +- ...aneous.json => line-animation-update.json} | 2 +- 6 files changed, 112 insertions(+), 9 deletions(-) rename test/{line-extraneous.html => line-animation-update.html} (97%) rename test/runTest/actions/{line-extraneous.json => line-animation-update.json} (57%) diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index fa4b3a95a7..bb4dd76508 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -1290,17 +1290,18 @@ class LineView extends ChartView { next = turnPointsIntoStep(diff.next, coordSys, step); stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step); } - // Don't apply animation if diff is large. // For better result and avoid memory explosion problems like // https://github.com/apache/incubator-echarts/issues/12229 if (getBoundingDiff(current, next) > 3000 || (polygon && getBoundingDiff(stackedOnCurrent, stackedOnNext) > 3000) ) { + polyline.stopAnimation(); polyline.setShape({ points: next }); if (polygon) { + polygon.stopAnimation(); polygon.setShape({ points: next, stackedOnPoints: stackedOnNext @@ -1345,7 +1346,6 @@ class LineView extends ChartView { } } - const updatedDataInfo: { el: SymbolExtended, ptIdx: number @@ -1364,7 +1364,6 @@ class LineView extends ChartView { } } } - if (polyline.animators && polyline.animators.length) { polyline.animators[0].during(function () { polygon && polygon.dirtyShape(); diff --git a/src/i18n/langPT-br.ts b/src/i18n/langPT-br.ts index bd8c988a64..8d6eb014f7 100644 --- a/src/i18n/langPT-br.ts +++ b/src/i18n/langPT-br.ts @@ -24,7 +24,8 @@ export default { time: { month: [ - 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' + 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', + 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ], monthAbbr: [ 'Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', diff --git a/test/line-extraneous.html b/test/line-animation-update.html similarity index 97% rename from test/line-extraneous.html rename to test/line-animation-update.html index e749696cfe..514559e836 100644 --- a/test/line-extraneous.html +++ b/test/line-animation-update.html @@ -42,6 +42,7 @@
+
+ + diff --git a/test/line-case.html b/test/line-case.html index 066715e43e..4c2bbb873d 100644 --- a/test/line-case.html +++ b/test/line-case.html @@ -447,9 +447,6 @@ 'Test case from https://github.com/apache/echarts/issues/15380' ], option: option - // height: 300, - // buttons: [{text: 'btn-txt', onclick: function () {}}], - // recordCanvas: true, }); }); diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 01f5097433..37aea6b857 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -111,10 +111,10 @@ "legend-visualMapColor": 2, "line": 1, "line-animation": 1, + "line-animation-update": 3, "line-boldWhenHover": 1, "line-crash": 1, "line-endLabel": 1, - "line-extraneous": 2, "line-visual2": 1, "lines-bus": 1, "map": 3, diff --git a/test/runTest/actions/line-extraneous.json b/test/runTest/actions/line-animation-update.json similarity index 57% rename from test/runTest/actions/line-extraneous.json rename to test/runTest/actions/line-animation-update.json index 455c58f692..79b547e948 100644 --- a/test/runTest/actions/line-extraneous.json +++ b/test/runTest/actions/line-animation-update.json @@ -1 +1 @@ -[{"name":"Action 1","ops":[{"type":"mousedown","time":596,"x":28,"y":93},{"type":"mouseup","time":698,"x":28,"y":93},{"time":699,"delay":2000,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1568042380534},{"name":"Action 2","ops":[{"type":"mousedown","time":736,"x":218,"y":184},{"type":"mouseup","time":827,"x":218,"y":184},{"time":828,"delay":400,"type":"screenshot-auto"}],"scrollY":416,"scrollX":0,"timestamp":1617082817083}] \ No newline at end of file +[{"name":"Action 1","ops":[{"type":"mousedown","time":596,"x":28,"y":93},{"type":"mouseup","time":698,"x":28,"y":93},{"time":699,"delay":2000,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1568042380534},{"name":"Action 2","ops":[{"type":"mousedown","time":736,"x":218,"y":184},{"type":"mouseup","time":827,"x":218,"y":184},{"time":828,"delay":400,"type":"screenshot-auto"}],"scrollY":416,"scrollX":0,"timestamp":1617082817083},{"name":"Action 3","ops":[{"type":"mousedown","time":325,"x":110,"y":174},{"type":"mouseup","time":433,"x":110,"y":174},{"time":434,"delay":400,"type":"screenshot-auto"}],"scrollY":915,"scrollX":0,"timestamp":1631687531615}] \ No newline at end of file