From 1b1284fff6e0282a195b9c154a3d6cd123cfc925 Mon Sep 17 00:00:00 2001 From: Linghao Su Date: Mon, 29 Jan 2024 10:28:18 +0800 Subject: [PATCH] Revert "fix(tooltip): fix opacity not work in tooltip marker" --- src/component/tooltip/TooltipView.ts | 2 +- src/component/tooltip/seriesFormatTooltip.ts | 5 +- src/component/tooltip/tooltipMarkup.ts | 20 +-- src/model/mixin/dataFormat.ts | 2 - src/util/format.ts | 8 +- src/util/types.ts | 1 - test/runTest/actions/__meta__.json | 1 - test/runTest/actions/tooltip-opacity.json | 1 - test/tooltip-opacity.html | 144 ------------------- 9 files changed, 7 insertions(+), 177 deletions(-) delete mode 100644 test/runTest/actions/tooltip-opacity.json delete mode 100644 test/tooltip-opacity.html diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index 461db0174c..5600dc2925 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -573,7 +573,7 @@ class TooltipView extends ComponentView { // Pre-create marker style for makers. Users can assemble richText // text in `formatter` callback and use those markers style. cbParams.marker = markupStyleCreator.makeTooltipMarker( - 'item', convertToColorString(cbParams.color), renderMode, cbParams.opacity + 'item', convertToColorString(cbParams.color), renderMode ); const seriesTooltipResult = normalizeTooltipFormatResult( diff --git a/src/component/tooltip/seriesFormatTooltip.ts b/src/component/tooltip/seriesFormatTooltip.ts index cdc3b79795..714cac2dfd 100644 --- a/src/component/tooltip/seriesFormatTooltip.ts +++ b/src/component/tooltip/seriesFormatTooltip.ts @@ -24,8 +24,7 @@ import { retrieveVisualColorForTooltipMarker, TooltipMarkupBlockFragment, createTooltipMarkup, - TooltipMarkupSection, - retrieveVisualOpacityForTooltipMarker + TooltipMarkupSection } from './tooltipMarkup'; import { retrieveRawValue } from '../../data/helper/dataProvider'; import { isNameSpecified } from '../../util/model'; @@ -48,7 +47,6 @@ export function defaultSeriesFormatTooltip(opt: { const value = series.getRawValue(dataIndex) as any; const isValueArr = isArray(value); const markerColor = retrieveVisualColorForTooltipMarker(series, dataIndex); - const markerOpacity = retrieveVisualOpacityForTooltipMarker(series, dataIndex); // Complicated rule for pretty tooltip. let inlineValue; @@ -88,7 +86,6 @@ export function defaultSeriesFormatTooltip(opt: { createTooltipMarkup('nameValue', { markerType: 'item', markerColor: markerColor, - opacity: markerOpacity, // Do not mix display seriesName and itemName in one tooltip, // which might confuses users. name: inlineName, diff --git a/src/component/tooltip/tooltipMarkup.ts b/src/component/tooltip/tooltipMarkup.ts index a277dad278..c416dad5d4 100644 --- a/src/component/tooltip/tooltipMarkup.ts +++ b/src/component/tooltip/tooltipMarkup.ts @@ -149,7 +149,6 @@ export interface TooltipMarkupNameValueBlock extends TooltipMarkupBlock { // If `!markerType`, tooltip marker is not used. markerType?: TooltipMarkerType; markerColor?: ColorString; - opacity?: number; name?: string; // Also support value is `[121, 555, 94.2]`. value?: unknown | unknown[]; @@ -326,8 +325,7 @@ function buildNameValue( : ctx.markupStyleCreator.makeTooltipMarker( fragment.markerType, fragment.markerColor || '#333', - renderMode, - fragment.opacity + renderMode ); const readableName = noName ? '' @@ -478,16 +476,6 @@ export function retrieveVisualColorForTooltipMarker( return convertToColorString(color); } -export function retrieveVisualOpacityForTooltipMarker( - series: SeriesModel, - dataIndex: number -): number { - const style = series.getData().getItemVisual(dataIndex, 'style'); - const opacity = style.opacity; - return opacity; -} - - export function getPaddingFromTooltipModel( model: Model, renderMode: TooltipRenderMode @@ -521,8 +509,7 @@ export class TooltipMarkupStyleCreator { makeTooltipMarker( markerType: TooltipMarkerType, colorStr: ColorString, - renderMode: TooltipRenderMode, - opacity?: number + renderMode: TooltipRenderMode ): string { const markerId = renderMode === 'richText' ? this._generateStyleName() @@ -531,8 +518,7 @@ export class TooltipMarkupStyleCreator { color: colorStr, type: markerType, renderMode, - markerId: markerId, - opacity: opacity + markerId: markerId }); if (isString(marker)) { return marker; diff --git a/src/model/mixin/dataFormat.ts b/src/model/mixin/dataFormat.ts index 99ca5607e7..2c39816235 100644 --- a/src/model/mixin/dataFormat.ts +++ b/src/model/mixin/dataFormat.ts @@ -67,7 +67,6 @@ export class DataFormatMixin { const itemOpt = data.getRawDataItem(dataIndex); const style = data.getItemVisual(dataIndex, 'style'); const color = style && style[data.getItemVisual(dataIndex, 'drawType') || 'fill'] as ZRColor; - const opacity = style && style.opacity; const borderColor = style && style.stroke as ColorString; const mainType = this.mainType; const isSeries = mainType === 'series'; @@ -88,7 +87,6 @@ export class DataFormatMixin { value: rawValue, color: color, borderColor: borderColor, - opacity: opacity, dimensionNames: userOutput ? userOutput.fullDimensions : null, encode: userOutput ? userOutput.encode : null, diff --git a/src/util/format.ts b/src/util/format.ts index 69f4be7a19..afe9625b42 100644 --- a/src/util/format.ts +++ b/src/util/format.ts @@ -181,7 +181,6 @@ interface GetTooltipMarkerOpt { // id name for marker. If only one marker is in a rich text, this can be omitted. // By default: 'markerX' markerId?: string; - opacity?: number; } // Only support color string export function getTooltipMarker(color: ColorString, extraCssText?: string): TooltipMarker; @@ -192,7 +191,6 @@ export function getTooltipMarker(inOpt: ColorString | GetTooltipMarkerOpt, extra extraCssText: extraCssText } : (inOpt || {}) as GetTooltipMarkerOpt; const color = opt.color; - const opacity = String(opt.opacity || 1); const type = opt.type; extraCssText = opt.extraCssText; const renderMode = opt.renderMode || 'html'; @@ -206,10 +204,10 @@ export function getTooltipMarker(inOpt: ColorString | GetTooltipMarkerOpt, extra ? '' + + encodeHTML(color) + ';' + (extraCssText || '') + '">' : ''; + + encodeHTML(color) + ';' + (extraCssText || '') + '">'; } else { // Should better not to auto generate style name by auto-increment number here. @@ -225,14 +223,12 @@ export function getTooltipMarker(inOpt: ColorString | GetTooltipMarkerOpt, extra width: 4, height: 4, borderRadius: 2, - opacity: opacity, backgroundColor: color } : { width: 10, height: 10, borderRadius: 5, - opacity: opacity, backgroundColor: color } }; diff --git a/src/util/types.ts b/src/util/types.ts index b7c74abf58..01e9321888 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -696,7 +696,6 @@ export interface CallbackDataParams { dataType?: SeriesDataType; value: OptionDataItem | OptionDataValue; color?: ZRColor; - opacity?: number; borderColor?: string; dimensionNames?: DimensionName[]; encode?: DimensionUserOuputEncode; diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 8592bb1bee..7b2ccc514c 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -201,7 +201,6 @@ "tooltip-domnode": 1, "tooltip-event": 1, "tooltip-link": 2, - "tooltip-opacity": 1, "tooltip-rich": 1, "tooltip-setOption": 2, "tooltip-valueFormatter": 3, diff --git a/test/runTest/actions/tooltip-opacity.json b/test/runTest/actions/tooltip-opacity.json deleted file mode 100644 index c10d9722a5..0000000000 --- a/test/runTest/actions/tooltip-opacity.json +++ /dev/null @@ -1 +0,0 @@ -[{"name":"Action 1","ops":[{"type":"mousemove","time":1108,"x":1,"y":273},{"type":"mousemove","time":1308,"x":282,"y":375},{"type":"mousemove","time":1519,"x":283,"y":376},{"type":"screenshot","time":2038},{"type":"mousemove","time":2925,"x":283,"y":375},{"type":"mousemove","time":3126,"x":440,"y":322},{"type":"mousemove","time":3333,"x":453,"y":324},{"type":"screenshot","time":3945},{"type":"mousemove","time":4393,"x":453,"y":324},{"type":"mousemove","time":4595,"x":493,"y":508},{"type":"mousemove","time":4804,"x":489,"y":515},{"type":"screenshot","time":5333},{"type":"mousemove","time":5476,"x":483,"y":503},{"type":"mousemove","time":5678,"x":412,"y":313},{"type":"screenshot","time":6173},{"type":"mousemove","time":6242,"x":411,"y":313},{"type":"mousemove","time":6442,"x":236,"y":399},{"type":"mousemove","time":6643,"x":233,"y":401},{"type":"screenshot","time":6816},{"type":"mousemove","time":6860,"x":233,"y":401},{"type":"mousemove","time":7062,"x":218,"y":303},{"type":"mousemove","time":7267,"x":213,"y":286},{"type":"mousemove","time":7467,"x":210,"y":279},{"type":"screenshot","time":7513},{"type":"mousemove","time":7750,"x":210,"y":279},{"type":"mousemove","time":7951,"x":101,"y":295},{"type":"mousemove","time":8152,"x":123,"y":310},{"type":"mousemove","time":8353,"x":123,"y":310},{"type":"screenshot","time":8432},{"type":"mousemove","time":8826,"x":123,"y":310},{"type":"mousemove","time":9029,"x":133,"y":310},{"type":"mousemove","time":9246,"x":133,"y":310}],"scrollY":0,"scrollX":0,"timestamp":1690094350338}] \ No newline at end of file diff --git a/test/tooltip-opacity.html b/test/tooltip-opacity.html deleted file mode 100644 index 03820d4fb4..0000000000 --- a/test/tooltip-opacity.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -

axisPointer link in one echarts instance | after data zoom, link should be normal

-
- - - - - \ No newline at end of file