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

fix(tooltip): get opacity from series visual #19552

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

linghaoSu
Copy link
Contributor

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

fix bug introduced from #18921

What does this PR do?

before:
image

image

after:
image
image

Fixed issues

Details

Before: What was the problem?

get opacity from realtime visual color

After: How does it behave after the fixing?

Gets the series visual opacity like the legend, but the legend gets the opacity from legendLineStyle when drawType is stroke, so the legend markers are opaque in parallel series, and the default opacity of parallel series is 0.45, so the tooltip The marker's opacity is also 0.45.

https://github.com/apache/echarts/blob/master/src/component/legend/LegendView.ts#L610-L615

    if ((itemStyle.opacity as any) === 'inherit') {
        /**
         * Use lineStyle.opacity if drawType is stroke
         */
        itemStyle.opacity = (drawType === 'fill' ? itemVisualStyle : lineVisualStyle).opacity;
    }
  1. line series
    If we set the opacity of lineStyle, the legend will respect these opacity.
    demo
image
  1. parallel series
    But for the parallel series, we set the opacity of lineStyle. At this time, the legend ignores the opacity in lineStyle.
    demo
image

I'm not sure this is the appropriate way to fix this error, could you give me some suggestions?@Ovilia

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

Copy link

echarts-bot bot commented Jan 25, 2024

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

⚠️ MISSING DOCUMENT INFO: Please make sure one of the document options are checked in this PR's description. Search "Document Info" in the description of this PR. This should be done either by the author or the reviewers of the PR.

Copy link
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-19552@77c707a

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than a small typo.

@@ -48,7 +48,7 @@ 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);
const markerOpacity = retrieveVisualOpacityForTooltipMarker(series); ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated ; here.

): number {
const style = series.getData().getItemVisual(dataIndex, 'style');
const style = series.getData().getVisual('style');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be correct. With this change, the opacity in the tooltip of pie series cannot use series.data.itemStyle.opacity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

After some testing, I found that the brush operation changes the colour of the graphic item, which will result in a colour change when tooltip is used, so would it also make sense for the brush operation to change the opacity of the tooltip?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The color should remain the same just as emphasis color should not be used when hovered.

@linghaoSu linghaoSu requested a review from Ovilia January 26, 2024 14:53
@linghaoSu linghaoSu marked this pull request as draft January 29, 2024 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants