Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Revert "fix(tooltip): fix opacity not work in tooltip marker" #19558

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 1 addition & 4 deletions src/component/tooltip/seriesFormatTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
retrieveVisualColorForTooltipMarker,
TooltipMarkupBlockFragment,
createTooltipMarkup,
TooltipMarkupSection,
retrieveVisualOpacityForTooltipMarker
TooltipMarkupSection
} from './tooltipMarkup';
import { retrieveRawValue } from '../../data/helper/dataProvider';
import { isNameSpecified } from '../../util/model';
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 3 additions & 17 deletions src/component/tooltip/tooltipMarkup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -326,8 +325,7 @@ function buildNameValue(
: ctx.markupStyleCreator.makeTooltipMarker(
fragment.markerType,
fragment.markerColor || '#333',
renderMode,
fragment.opacity
renderMode
);
const readableName = noName
? ''
Expand Down Expand Up @@ -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<TooltipOption>,
renderMode: TooltipRenderMode
Expand Down Expand Up @@ -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()
Expand All @@ -531,8 +518,7 @@ export class TooltipMarkupStyleCreator {
color: colorStr,
type: markerType,
renderMode,
markerId: markerId,
opacity: opacity
markerId: markerId
});
if (isString(marker)) {
return marker;
Expand Down
2 changes: 0 additions & 2 deletions src/model/mixin/dataFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,

Expand Down
8 changes: 2 additions & 6 deletions src/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -206,10 +204,10 @@ export function getTooltipMarker(inOpt: ColorString | GetTooltipMarkerOpt, extra
? '<span style="display:inline-block;vertical-align:middle;margin-right:8px;margin-left:3px;'
+ 'border-radius:4px;width:4px;height:4px;background-color:'
// Only support string
+ encodeHTML(color) + ';' + 'opacity:' + encodeHTML(opacity) + ';' + (extraCssText || '') + '"></span>'
+ encodeHTML(color) + ';' + (extraCssText || '') + '"></span>'
: '<span style="display:inline-block;margin-right:4px;'
+ 'border-radius:10px;width:10px;height:10px;background-color:'
+ encodeHTML(color) + ';' + 'opacity:' + encodeHTML(opacity) + ';' + (extraCssText || '') + '"></span>';
+ encodeHTML(color) + ';' + (extraCssText || '') + '"></span>';
}
else {
// Should better not to auto generate style name by auto-increment number here.
Expand All @@ -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
}
};
Expand Down
1 change: 0 additions & 1 deletion src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ export interface CallbackDataParams {
dataType?: SeriesDataType;
value: OptionDataItem | OptionDataValue;
color?: ZRColor;
opacity?: number;
borderColor?: string;
dimensionNames?: DimensionName[];
encode?: DimensionUserOuputEncode;
Expand Down
1 change: 0 additions & 1 deletion test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/runTest/actions/tooltip-opacity.json

This file was deleted.

144 changes: 0 additions & 144 deletions test/tooltip-opacity.html

This file was deleted.

Loading