-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
Conversation
Thanks for your contribution! The pull request is marked to be |
src/chart/helper/labelHelper.ts
Outdated
@@ -45,6 +45,10 @@ export function getDefaultLabel( | |||
} | |||
return vals.join(' '); | |||
} | |||
else { | |||
const rawVal = retrieveRawValue(data, dataIndex, 'value'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brief Information
This pull request is in the type of:
What does this PR do?
For
singleaxis
, it doesn't havedefaultedLabel
, then usevalue
as default dim to retrieve label.Fixed issues
Details
Before: What was the problem?
After: How is it fixed in this PR?
Misc
Related test cases or examples to use the new APIs
test/scatter-single-axis.html
Others
Merging options
Other information