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(label): label not show on singleaxis #15851

Closed
wants to merge 4 commits into from

Conversation

susiwen8
Copy link
Contributor

@susiwen8 susiwen8 commented Oct 10, 2021

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

For singleaxis, it doesn't have defaultedLabel, then use value as default dim to retrieve label.

Fixed issues

Details

Before: What was the problem?

Screen Shot 2021-10-10 at 8 42 41 PM

After: How is it fixed in this PR?

Screen Shot 2021-10-10 at 8 42 28 PM

Misc

  • The API has been changed (apache/echarts-doc#xxx).
  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

test/scatter-single-axis.html

Others

Merging options

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

Other information

@echarts-bot
Copy link

echarts-bot bot commented Oct 10, 2021

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.

@@ -45,6 +45,10 @@ export function getDefaultLabel(
}
return vals.join(' ');
}
else {
const rawVal = retrieveRawValue(data, dataIndex, 'value');
Copy link
Contributor

@pissang pissang Oct 11, 2021

Choose a reason for hiding this comment

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

This branch can be merged with the first branch to have tighter code. Also, I think we should figure out why singleAxis coordinate system doesn't have the defaultLabel. It's an unexpected behavior

Copy link
Contributor Author

@susiwen8 susiwen8 Oct 12, 2021

Choose a reason for hiding this comment

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

For singleAxis, the dimension are ['single', 'value'] when data format is an array. Normally, in summarizeDimensions it will assign value as defaultLabel
https://github.com/apache/echarts/blob/master/src/data/helper/dimensionHelper.ts#L125
but in prepareSeriesDataSchema it marks value as isExtraCoord so singleAxis would skip this logic. That cause defaultLabel is an empty array. I was trying to add

    if (defaultedLabel && defaultedLabel.length) {
        defaultedLabel = encode.value.slice();
    }

However value wasn't always in DimensionSummary, also, if data format weren't array, which it is allowed. The dimension for singleAxis would be ['single']. @pissang

Copy link
Contributor

Choose a reason for hiding this comment

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

@100pah Please help check this logic

Copy link
Member

Choose a reason for hiding this comment

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

@susiwen8 I think it's probably not a good strategy to retrieveRawValue(data, dataIndex, 'value'); here.

The option provided in #15830 is:

option = {
    singleAxis: {
        type: 'category',
        data: ['a', 'b', 'c']
    },
    series: {
        data: [
            value: [0, 5]
        ]
    }
}

where only the first dimension of data (that is, 0) is used by the coord sys,
and the second dimension (that is, 5) is not used by the coord sys.
Consider the data might comes form series.data or dataset.source,
!isExtraCoord means: this is a dimension that used by this series and used by coord sys.

At present the strategy that "find a proper dimension as the default label" is:
only find from the dimensions that are !isExtraCoord.
Because if data comes from dataset, isExtraCoord dimensions may be used by other series.

But there is another detail in the strategy: it only choose dimensions that are not of type category and time.
That is why the label did not display in case #15830 , where the only !isExtraCoord dimension is a category dimension. See https://github.com/apache/echarts/blob/master/src/data/helper/dimensionHelper.ts#L124

I think we could change the strategy in https://github.com/apache/echarts/blob/master/src/data/helper/dimensionHelper.ts#L124 to:
(A) if no defaultedLabel selected, use the last !isExtraCoord dimension no matter it's category or time.
(B) if data is from series rather than dataset, do not need to consider isExtraCoord when finding defaultedLabel.

(A) can solve #15830
(B) might make it better but brings a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm incline solution A

Copy link
Member

@100pah 100pah left a comment

Choose a reason for hiding this comment

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

src/data/helper/dimensionHelper.ts Show resolved Hide resolved
src/data/helper/dimensionHelper.ts Outdated Show resolved Hide resolved
src/data/helper/dimensionHelper.ts Outdated Show resolved Hide resolved
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.

The label options never work on the "Scatter on Single Axis"
3 participants