From 21a43e0fabf6e3a0b5365c3e33ed9286f8e38d62 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 14:04:15 +0800 Subject: [PATCH 01/14] fix(chart): DefaultStatesMixinEmpasis -> DefaultStatesMixinEmphasis in util/types --- src/chart/bar/BarSeries.ts | 4 ++-- src/chart/funnel/FunnelSeries.ts | 4 ++-- src/chart/gauge/GaugeSeries.ts | 4 ++-- src/chart/lines/LinesSeries.ts | 4 ++-- src/chart/parallel/ParallelSeries.ts | 6 +++--- src/chart/radar/RadarSeries.ts | 4 ++-- src/chart/themeRiver/ThemeRiverSeries.ts | 4 ++-- src/util/types.ts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts index d2b76ab3a7..eb838c11ff 100644 --- a/src/chart/bar/BarSeries.ts +++ b/src/chart/bar/BarSeries.ts @@ -27,7 +27,7 @@ import { SeriesSamplingOptionMixin, SeriesLabelOption, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, CallbackDataParams } from '../../util/types'; import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; @@ -49,7 +49,7 @@ export interface BarStateOption { } interface BarStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface BarItemStyleOption extends ItemStyleOption { diff --git a/src/chart/funnel/FunnelSeries.ts b/src/chart/funnel/FunnelSeries.ts index b40ed8b253..152cdb37da 100644 --- a/src/chart/funnel/FunnelSeries.ts +++ b/src/chart/funnel/FunnelSeries.ts @@ -37,7 +37,7 @@ import { VerticalAlign, SeriesLabelOption, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; @@ -49,7 +49,7 @@ type FunnelLabelOption = Omit & { }; interface FunnelStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface FunnelCallbackDataParams extends CallbackDataParams { diff --git a/src/chart/gauge/GaugeSeries.ts b/src/chart/gauge/GaugeSeries.ts index 78601156d2..07bfcc470e 100644 --- a/src/chart/gauge/GaugeSeries.ts +++ b/src/chart/gauge/GaugeSeries.ts @@ -29,7 +29,7 @@ import { OptionDataValueNumeric, StatesOptionMixin, SeriesEncodeOptionMixin, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; @@ -105,7 +105,7 @@ interface DetailOption extends LabelOption { } interface GaugeStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface GaugeStateOption { itemStyle?: ItemStyleOption diff --git a/src/chart/lines/LinesSeries.ts b/src/chart/lines/LinesSeries.ts index 03a08dfbbb..f97b6a0b97 100644 --- a/src/chart/lines/LinesSeries.ts +++ b/src/chart/lines/LinesSeries.ts @@ -35,7 +35,7 @@ import { StatesOptionMixin, SeriesLineLabelOption, DimensionDefinitionLoose, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, ZRColor, CallbackDataParams } from '../../util/types'; @@ -86,7 +86,7 @@ interface LegacyDataItemOption { } interface LinesStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface LinesStateOption { lineStyle?: LinesLineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor> diff --git a/src/chart/parallel/ParallelSeries.ts b/src/chart/parallel/ParallelSeries.ts index d3f94b0176..301b56c106 100644 --- a/src/chart/parallel/ParallelSeries.ts +++ b/src/chart/parallel/ParallelSeries.ts @@ -33,10 +33,10 @@ import { OptionEncodeValue, Dictionary, OptionEncode, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, ZRColor, CallbackDataParams - } from '../../util/types'; +} from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; import { ParallelActiveState, ParallelAxisOption } from '../../coord/parallel/AxisModel'; @@ -46,7 +46,7 @@ import ParallelModel from '../../coord/parallel/ParallelModel'; type ParallelSeriesDataValue = OptionDataValue[]; interface ParallelStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface ParallelStateOption { lineStyle?: LineStyleOption<(TCbParams extends never ? never : (params: TCbParams) => ZRColor) | ZRColor> diff --git a/src/chart/radar/RadarSeries.ts b/src/chart/radar/RadarSeries.ts index 761f096abe..1405ac074b 100644 --- a/src/chart/radar/RadarSeries.ts +++ b/src/chart/radar/RadarSeries.ts @@ -33,7 +33,7 @@ import { OptionDataItemObject, SeriesEncodeOptionMixin, CallbackDataParams, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmphasis } from '../../util/types'; import GlobalModel from '../../model/Global'; import SeriesData from '../../data/SeriesData'; @@ -45,7 +45,7 @@ import { type RadarSeriesDataValue = OptionDataValue[]; interface RadarStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface RadarSeriesStateOption { lineStyle?: LineStyleOption diff --git a/src/chart/themeRiver/ThemeRiverSeries.ts b/src/chart/themeRiver/ThemeRiverSeries.ts index 64a01a004e..f1fb0bc495 100644 --- a/src/chart/themeRiver/ThemeRiverSeries.ts +++ b/src/chart/themeRiver/ThemeRiverSeries.ts @@ -35,7 +35,7 @@ import { Dictionary, SeriesLabelOption, CallbackDataParams, - DefaultStatesMixinEmpasis + DefaultStatesMixinEmphasis } from '../../util/types'; import SingleAxis from '../../coord/single/SingleAxis'; import GlobalModel from '../../model/Global'; @@ -51,7 +51,7 @@ interface ThemeRiverSeriesLabelOption extends SeriesLabelOption { type ThemerRiverDataItem = [OptionDataValueDate, OptionDataValueNumeric, string]; interface ThemeRiverStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface ThemeRiverStateOption { label?: ThemeRiverSeriesLabelOption diff --git a/src/util/types.ts b/src/util/types.ts index 4c00203ea0..dbaafc81b6 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -1471,7 +1471,7 @@ export interface DefaultStatesMixin { export type DefaultEmphasisFocus = 'none' | 'self' | 'series'; -export interface DefaultStatesMixinEmpasis { +export interface DefaultStatesMixinEmphasis { /** * self: Focus self and blur all others. * series: Focus series and blur all other series. From 2e65a4ec8ad1b01a927151043292697d096998b0 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 14:18:09 +0800 Subject: [PATCH 02/14] feat: heatmap itemStyle.borderRadius with https://github.com/apache/echarts/issues/16490 --- src/chart/heatmap/HeatmapSeries.ts | 10 ++++++--- src/chart/heatmap/HeatmapView.ts | 36 ++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/chart/heatmap/HeatmapSeries.ts b/src/chart/heatmap/HeatmapSeries.ts index 700f0b439d..c1bb413fd6 100644 --- a/src/chart/heatmap/HeatmapSeries.ts +++ b/src/chart/heatmap/HeatmapSeries.ts @@ -30,7 +30,7 @@ import { StatesOptionMixin, SeriesEncodeOptionMixin, SeriesOnCalendarOptionMixin, - DefaultStatesMixinEmpasis, + DefaultStatesMixinEmphasis, CallbackDataParams } from '../../util/types'; import GlobalModel from '../../model/Global'; @@ -41,14 +41,18 @@ import type Calendar from '../../coord/calendar/Calendar'; type HeatmapDataValue = OptionDataValue[]; +export type BorderRadius = number | number[]; + export interface HeatmapStateOption { // Available on cartesian2d coordinate system - itemStyle?: ItemStyleOption + itemStyle?: ItemStyleOption & { + borderRadius?: BorderRadius + } label?: SeriesLabelOption } interface FunnelStatesMixin { - emphasis?: DefaultStatesMixinEmpasis + emphasis?: DefaultStatesMixinEmphasis } export interface HeatmapDataItemOption extends HeatmapStateOption, StatesOptionMixin { diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index 253fe50e6a..42c16c66a3 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -22,7 +22,7 @@ import { toggleHoverEmphasis } from '../../util/states'; import HeatmapLayer from './HeatmapLayer'; import * as zrUtil from 'zrender/src/core/util'; import ChartView from '../../view/Chart'; -import HeatmapSeriesModel, { HeatmapDataItemOption } from './HeatmapSeries'; +import HeatmapSeriesModel, { BorderRadius, HeatmapDataItemOption } from './HeatmapSeries'; import type GlobalModel from '../../model/Global'; import type ExtensionAPI from '../../core/ExtensionAPI'; import type VisualMapModel from '../../component/visualMap/VisualMapModel'; @@ -31,9 +31,10 @@ import type ContinuousModel from '../../component/visualMap/ContinuousModel'; import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem'; import { StageHandlerProgressParams, Dictionary, OptionDataValue } from '../../util/types'; import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; -import type Calendar from '../../coord/calendar/Calendar'; +import Calendar from '../../coord/calendar/Calendar'; import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle'; import Element from 'zrender/src/Element'; +import { RectLike, RectShape } from 'zrender'; // Coord can be 'geo' 'bmap' 'amap' 'leaflet'... interface GeoLikeCoordSys extends CoordinateSystem { @@ -205,6 +206,8 @@ class HeatmapView extends ChartView { let emphasisStyle = seriesModel.getModel(['emphasis', 'itemStyle']).getItemStyle(); let blurStyle = seriesModel.getModel(['blur', 'itemStyle']).getItemStyle(); let selectStyle = seriesModel.getModel(['select', 'itemStyle']).getItemStyle(); + const itemStyle = seriesModel.getModel(['itemStyle']); + const borderRadius = itemStyle.get('borderRadius'); let labelStatesModels = getLabelStatesModels(seriesModel); const emphasisModel = seriesModel.getModel('emphasis'); let focus = emphasisModel.get('focus'); @@ -245,13 +248,21 @@ class HeatmapView extends ChartView { dataDimY ]); + const shape: RectShape & { + r?: BorderRadius + } = { + x: Math.floor(Math.round(point[0]) - width / 2), + y: Math.floor(Math.round(point[1]) - height / 2), + width: Math.ceil(width), + height: Math.ceil(height) + }; + + if (borderRadius) { + shape.r = borderRadius; + } + rect = new graphic.Rect({ - shape: { - x: Math.floor(Math.round(point[0]) - width / 2), - y: Math.floor(Math.round(point[1]) - height / 2), - width: Math.ceil(width), - height: Math.ceil(height) - }, + shape, style }); } @@ -260,10 +271,17 @@ class HeatmapView extends ChartView { if (isNaN(data.get(dataDims[1], idx) as number)) { continue; } + const shape: RectLike & { + r?: BorderRadius + } = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; + + if (borderRadius) { + shape.r = borderRadius; + } rect = new graphic.Rect({ z2: 1, - shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape, + shape, style }); } From 97d5d5351f3ea605e055d1b7f771e0173393149e Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 14:20:20 +0800 Subject: [PATCH 03/14] feat(test): format heatmap-geo --- test/heatmap-geo.html | 174 ++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 92 deletions(-) diff --git a/test/heatmap-geo.html b/test/heatmap-geo.html index f4deb29d34..79afbb4da4 100644 --- a/test/heatmap-geo.html +++ b/test/heatmap-geo.html @@ -5,14 +5,14 @@ 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 +'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 +'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. @@ -20,94 +20,84 @@ - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - + + + + + + + + + + + + + + +
+ + + + + + \ No newline at end of file From 1d6eeec07f828893f2684cd1298e92d50658bdbf Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 14:21:41 +0800 Subject: [PATCH 04/14] feat(test): heatmap itemStyle.borderRadius --- test/heatmap-border-radius.html | 166 ++++++++++++++++++++++++++++++++ test/heatmap-calendar.html | 106 ++++++++++++++++++++ 2 files changed, 272 insertions(+) create mode 100644 test/heatmap-border-radius.html create mode 100644 test/heatmap-calendar.html diff --git a/test/heatmap-border-radius.html b/test/heatmap-border-radius.html new file mode 100644 index 0000000000..4f6701e8fd --- /dev/null +++ b/test/heatmap-border-radius.html @@ -0,0 +1,166 @@ + + + + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/test/heatmap-calendar.html b/test/heatmap-calendar.html new file mode 100644 index 0000000000..b20b7ce3c5 --- /dev/null +++ b/test/heatmap-calendar.html @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + \ No newline at end of file From 9134132b9bc23af2fec4c4b0149fcc716037b0bc Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 21:37:37 +0800 Subject: [PATCH 05/14] feat(chart): borderRadius support data item; adjust RectShape type be the instance with graphic.Rect --- src/chart/heatmap/HeatmapView.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index 42c16c66a3..4514738a0e 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -34,7 +34,6 @@ import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; import Calendar from '../../coord/calendar/Calendar'; import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle'; import Element from 'zrender/src/Element'; -import { RectLike, RectShape } from 'zrender'; // Coord can be 'geo' 'bmap' 'amap' 'leaflet'... interface GeoLikeCoordSys extends CoordinateSystem { @@ -42,6 +41,8 @@ interface GeoLikeCoordSys extends CoordinateSystem { getViewRect(): graphic.BoundingRect } +type Shape = graphic.Rect['shape']; + function getIsInPiecewiseRange( dataExtent: number[], pieceList: ReturnType, @@ -206,8 +207,7 @@ class HeatmapView extends ChartView { let emphasisStyle = seriesModel.getModel(['emphasis', 'itemStyle']).getItemStyle(); let blurStyle = seriesModel.getModel(['blur', 'itemStyle']).getItemStyle(); let selectStyle = seriesModel.getModel(['select', 'itemStyle']).getItemStyle(); - const itemStyle = seriesModel.getModel(['itemStyle']); - const borderRadius = itemStyle.get('borderRadius'); + let borderRadius = seriesModel.get(['itemStyle', 'borderRadius']); let labelStatesModels = getLabelStatesModels(seriesModel); const emphasisModel = seriesModel.getModel('emphasis'); let focus = emphasisModel.get('focus'); @@ -228,6 +228,17 @@ class HeatmapView extends ChartView { for (let idx = start; idx < end; idx++) { let rect; const style = data.getItemVisual(idx, 'style'); + const itemModel = data.getItemModel(idx); + + // borderRadius must be set before the Rect draw. + if (data.hasItemOption) { + // Each item value struct in the data would be firstly + // { + // itemStyle: { borderRadius: [30, 30] }, + // value: [2022, 02, 22] + // } + borderRadius = itemModel.get(['itemStyle', 'borderRadius']); + } if (isCoordinateSystemType(coordSys, 'cartesian2d')) { const dataDimX = data.get(dataDims[0], idx); @@ -248,16 +259,14 @@ class HeatmapView extends ChartView { dataDimY ]); - const shape: RectShape & { - r?: BorderRadius - } = { + const shape: Shape = { x: Math.floor(Math.round(point[0]) - width / 2), y: Math.floor(Math.round(point[1]) - height / 2), width: Math.ceil(width), height: Math.ceil(height) }; - if (borderRadius) { + if (borderRadius || Array.isArray(borderRadius)) { shape.r = borderRadius; } @@ -271,11 +280,9 @@ class HeatmapView extends ChartView { if (isNaN(data.get(dataDims[1], idx) as number)) { continue; } - const shape: RectLike & { - r?: BorderRadius - } = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; + const shape: Shape = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; - if (borderRadius) { + if (borderRadius || Array.isArray(borderRadius)) { shape.r = borderRadius; } @@ -286,8 +293,6 @@ class HeatmapView extends ChartView { }); } - const itemModel = data.getItemModel(idx); - // Optimization for large datset if (data.hasItemOption) { const emphasisModel = itemModel.getModel('emphasis'); From 04392f5336f0f895c37b3e3f36294b67fc5fdf5c Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Fri, 11 Feb 2022 21:38:46 +0800 Subject: [PATCH 06/14] feat(test): Heatmap Border Radius by Each Item --- test/heatmap-item-border-radius.html | 116 +++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 test/heatmap-item-border-radius.html diff --git a/test/heatmap-item-border-radius.html b/test/heatmap-item-border-radius.html new file mode 100644 index 0000000000..831635e9bf --- /dev/null +++ b/test/heatmap-item-border-radius.html @@ -0,0 +1,116 @@ + + + + + + + + + + + + + +
+ + + + \ No newline at end of file From eac8d5ef46553f842a9a062a5a4b84e1722ef113 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 14 Feb 2022 14:15:15 +0800 Subject: [PATCH 07/14] feat(heatmap): mktest for heatmap-border-radius --- test/heatmap-border-radius.html | 209 ++++++++++++++++++++++++--- test/heatmap-calendar.html | 106 -------------- test/heatmap-item-border-radius.html | 116 --------------- 3 files changed, 185 insertions(+), 246 deletions(-) delete mode 100644 test/heatmap-calendar.html delete mode 100644 test/heatmap-item-border-radius.html diff --git a/test/heatmap-border-radius.html b/test/heatmap-border-radius.html index 4f6701e8fd..984fc14845 100644 --- a/test/heatmap-border-radius.html +++ b/test/heatmap-border-radius.html @@ -20,34 +20,35 @@ - - - - + + + + + + + + + -
+
- - chartTwo.setOption({ + + + + + diff --git a/test/heatmap-calendar.html b/test/heatmap-calendar.html deleted file mode 100644 index b20b7ce3c5..0000000000 --- a/test/heatmap-calendar.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - \ No newline at end of file diff --git a/test/heatmap-item-border-radius.html b/test/heatmap-item-border-radius.html deleted file mode 100644 index 831635e9bf..0000000000 --- a/test/heatmap-item-border-radius.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - -
- - - - \ No newline at end of file From 6a88f7d6f5cc7edac7fb713181c3899b59be6e91 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 14 Feb 2022 15:36:58 +0800 Subject: [PATCH 08/14] feat(heatmap): get borderRadius value before ensureState set emphasis --- src/chart/heatmap/HeatmapView.ts | 35 ++++++++++++-------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index 4514738a0e..f107fc689b 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -41,7 +41,7 @@ interface GeoLikeCoordSys extends CoordinateSystem { getViewRect(): graphic.BoundingRect } -type Shape = graphic.Rect['shape']; +type RectShape = graphic.Rect['shape']; function getIsInPiecewiseRange( dataExtent: number[], @@ -228,17 +228,6 @@ class HeatmapView extends ChartView { for (let idx = start; idx < end; idx++) { let rect; const style = data.getItemVisual(idx, 'style'); - const itemModel = data.getItemModel(idx); - - // borderRadius must be set before the Rect draw. - if (data.hasItemOption) { - // Each item value struct in the data would be firstly - // { - // itemStyle: { borderRadius: [30, 30] }, - // value: [2022, 02, 22] - // } - borderRadius = itemModel.get(['itemStyle', 'borderRadius']); - } if (isCoordinateSystemType(coordSys, 'cartesian2d')) { const dataDimX = data.get(dataDims[0], idx); @@ -259,17 +248,13 @@ class HeatmapView extends ChartView { dataDimY ]); - const shape: Shape = { + const shape: RectShape = { x: Math.floor(Math.round(point[0]) - width / 2), y: Math.floor(Math.round(point[1]) - height / 2), width: Math.ceil(width), height: Math.ceil(height) }; - if (borderRadius || Array.isArray(borderRadius)) { - shape.r = borderRadius; - } - rect = new graphic.Rect({ shape, style @@ -280,11 +265,7 @@ class HeatmapView extends ChartView { if (isNaN(data.get(dataDims[1], idx) as number)) { continue; } - const shape: Shape = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; - - if (borderRadius || Array.isArray(borderRadius)) { - shape.r = borderRadius; - } + const shape: RectShape = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; rect = new graphic.Rect({ z2: 1, @@ -295,11 +276,19 @@ class HeatmapView extends ChartView { // Optimization for large datset if (data.hasItemOption) { + const itemModel = data.getItemModel(idx); const emphasisModel = itemModel.getModel('emphasis'); emphasisStyle = emphasisModel.getModel('itemStyle').getItemStyle(); blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle(); selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle(); + // Each item value struct in the data would be firstly + // { + // itemStyle: { borderRadius: [30, 30] }, + // value: [2022, 02, 22] + // } + borderRadius = itemModel.get(['itemStyle', 'borderRadius']); + focus = emphasisModel.get('focus'); blurScope = emphasisModel.get('blurScope'); emphasisDisabled = emphasisModel.get('disabled'); @@ -307,6 +296,8 @@ class HeatmapView extends ChartView { labelStatesModels = getLabelStatesModels(itemModel); } + rect.shape.r = borderRadius; + const rawValue = seriesModel.getRawValue(idx) as OptionDataValue[]; let defaultText = '-'; if (rawValue && rawValue[2] != null) { From 97a4818e880600df30910fa31d80039de35b985d Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 14 Feb 2022 15:38:31 +0800 Subject: [PATCH 09/14] feat(test): rename heatmap-border-radius to heatmap-borderRadius --- ...atmap-border-radius.html => heatmap-borderRadius.html} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename test/{heatmap-border-radius.html => heatmap-borderRadius.html} (98%) diff --git a/test/heatmap-border-radius.html b/test/heatmap-borderRadius.html similarity index 98% rename from test/heatmap-border-radius.html rename to test/heatmap-borderRadius.html index 984fc14845..afdd5649a7 100644 --- a/test/heatmap-border-radius.html +++ b/test/heatmap-borderRadius.html @@ -108,7 +108,7 @@ var chart = testHelper.create(echarts, 'main1', { option: option, title: [ - 'Heatmap Border Radius (number)', + 'Heatmap borderRadius (number)', ], }); }); @@ -181,7 +181,7 @@ var chart = testHelper.create(echarts, 'main2', { option: option, title: [ - 'Heatmap Border Radius(number[])', + 'Heatmap borderRadius(number[])', ], }); }); @@ -253,7 +253,7 @@ var chart = testHelper.create(echarts, 'main3', { option: option, title: [ - 'Heatmap Border Radius by Each Item', + 'Heatmap borderRadius by Each Item', ], }); }); @@ -317,7 +317,7 @@ var chart = testHelper.create(echarts, 'main4', { option: option, title: [ - 'Heatmap Border Radius', + 'Heatmap borderRadius in Calendar', ], }); }); From 6a030011fa6d4363a34afa67222ea0bee22cf248 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 14 Feb 2022 16:12:46 +0800 Subject: [PATCH 10/14] feat(heatmap): remove useless temporary variable shape --- src/chart/heatmap/HeatmapView.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index f107fc689b..07b8f856d2 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -41,8 +41,6 @@ interface GeoLikeCoordSys extends CoordinateSystem { getViewRect(): graphic.BoundingRect } -type RectShape = graphic.Rect['shape']; - function getIsInPiecewiseRange( dataExtent: number[], pieceList: ReturnType, @@ -248,15 +246,13 @@ class HeatmapView extends ChartView { dataDimY ]); - const shape: RectShape = { - x: Math.floor(Math.round(point[0]) - width / 2), - y: Math.floor(Math.round(point[1]) - height / 2), - width: Math.ceil(width), - height: Math.ceil(height) - }; - rect = new graphic.Rect({ - shape, + shape: { + x: Math.floor(Math.round(point[0]) - width / 2), + y: Math.floor(Math.round(point[1]) - height / 2), + width: Math.ceil(width), + height: Math.ceil(height) + }, style }); } @@ -265,11 +261,10 @@ class HeatmapView extends ChartView { if (isNaN(data.get(dataDims[1], idx) as number)) { continue; } - const shape: RectShape = coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape; rect = new graphic.Rect({ z2: 1, - shape, + shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape, style }); } From edb7e0ce80b934c49f64be813a0585469b558e1b Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 14 Feb 2022 16:15:58 +0800 Subject: [PATCH 11/14] feat(test): format heatmap (geo, borderRadius) --- test/heatmap-borderRadius.html | 5 +- test/heatmap-geo.html | 141 ++++++++++++++++----------------- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/test/heatmap-borderRadius.html b/test/heatmap-borderRadius.html index afdd5649a7..f7cc584a4e 100644 --- a/test/heatmap-borderRadius.html +++ b/test/heatmap-borderRadius.html @@ -1,17 +1,18 @@ + - - - - - - - - - - + + + + + + + + + - -
- + var chart = testHelper.create(echarts, 'main0', { + title: [ + 'Heatmap in Geo coordinate system' + ], + height: 600, + option: option + }); + }); + From dc4e6ee15ef9315a6105ced811d6e2bbca9ffae1 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Tue, 15 Feb 2022 12:23:00 +0800 Subject: [PATCH 12/14] feat(heatmap): remove uesless import in HeatmapView --- src/chart/heatmap/HeatmapView.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index 07b8f856d2..8fbc4bef63 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -22,7 +22,7 @@ import { toggleHoverEmphasis } from '../../util/states'; import HeatmapLayer from './HeatmapLayer'; import * as zrUtil from 'zrender/src/core/util'; import ChartView from '../../view/Chart'; -import HeatmapSeriesModel, { BorderRadius, HeatmapDataItemOption } from './HeatmapSeries'; +import HeatmapSeriesModel, { HeatmapDataItemOption } from './HeatmapSeries'; import type GlobalModel from '../../model/Global'; import type ExtensionAPI from '../../core/ExtensionAPI'; import type VisualMapModel from '../../component/visualMap/VisualMapModel'; From dec9715b8bee93e7b9131fe5eb8b5db55fc5224e Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Tue, 15 Feb 2022 12:25:07 +0800 Subject: [PATCH 13/14] fix(test): revert heatmap-geo.html --- test/heatmap-geo.html | 171 ++++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 80 deletions(-) diff --git a/test/heatmap-geo.html b/test/heatmap-geo.html index 4fe49b0ff2..f4deb29d34 100644 --- a/test/heatmap-geo.html +++ b/test/heatmap-geo.html @@ -18,85 +18,96 @@ under the License. --> + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + - - - - - - - - - - - - - - -
- - - - - - \ No newline at end of file From 384737ab31721ebe01b35e7fa99e368855dc3e09 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Tue, 15 Feb 2022 12:30:53 +0800 Subject: [PATCH 14/14] fix(heatmap): merge type & restore lost type about Calendar --- src/chart/heatmap/HeatmapSeries.ts | 4 +--- src/chart/heatmap/HeatmapView.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/chart/heatmap/HeatmapSeries.ts b/src/chart/heatmap/HeatmapSeries.ts index c1bb413fd6..df68efdeb6 100644 --- a/src/chart/heatmap/HeatmapSeries.ts +++ b/src/chart/heatmap/HeatmapSeries.ts @@ -41,12 +41,10 @@ import type Calendar from '../../coord/calendar/Calendar'; type HeatmapDataValue = OptionDataValue[]; -export type BorderRadius = number | number[]; - export interface HeatmapStateOption { // Available on cartesian2d coordinate system itemStyle?: ItemStyleOption & { - borderRadius?: BorderRadius + borderRadius?: number | number[] } label?: SeriesLabelOption } diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index 8fbc4bef63..cd835ae048 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -31,7 +31,7 @@ import type ContinuousModel from '../../component/visualMap/ContinuousModel'; import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem'; import { StageHandlerProgressParams, Dictionary, OptionDataValue } from '../../util/types'; import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; -import Calendar from '../../coord/calendar/Calendar'; +import type Calendar from '../../coord/calendar/Calendar'; import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle'; import Element from 'zrender/src/Element';