-
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
Feature #7340. Add the itemStyle to legend #11302
Conversation
src/visual/dataColor.js
Outdated
|
||
if (!singleDataBorderColor) { | ||
// FIXME Performance | ||
var itemModel = dataAll.getItemModel(rawIdx); |
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.
itemModel should not be created twice if both singleDataborderColor
and singleDataColor
is true.
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.
Thanks!I didn't take this into account.
if (color != null) { | ||
data.setItemVisual(idx, 'color', color); | ||
} | ||
if (borderColor != null) { | ||
data.setItemVisual(idx, 'borderColor', borderColor); | ||
} | ||
}; | ||
|
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.
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.
The emptyCircle symbol doesn't have fillColor, so the strokeColor should be the same as color of corresponding series
if (color != null) { | ||
data.setItemVisual(idx, 'color', color); | ||
} | ||
if (borderColor != null) { | ||
data.setItemVisual(idx, 'borderColor', borderColor); | ||
} | ||
}; | ||
|
||
return { dataEach: data.hasItemOption ? dataEach : null }; |
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.
If use scatter
:
If symbol: emptyCircle
: The color of scatter is different with legend.
If symbol: circle
border
set, legend do not show the border.
var option4 = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
// itemStyle: {
// borderWidth: 3
// },
// selected: {
// '联盟广告': false
// }
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '直接访问',
type: 'scatter',
data: [320, 332, 301, 334, 390, 330, 320],
symbol: 'emptyCircle',
itemStyle: {
borderColor: '#5e1',
borderWidth: 3
}
},
{
name: '邮件营销',
type: 'scatter',
data: [120, 132, 101, 134, 90, 230, 210],
symbol: 'emptyCircle',
itemStyle: {
borderColor: '#ae2',
borderWidth: 5
}
},
{
name: '邮件营销2',
type: 'scatter',
data: [21, 33, 11, 22, 22, 11, 22],
symbol: 'circle',
itemStyle: {
borderColor: '#912',
borderWidth: 5
}
}
]
};
// chart1.setOption(option4);
testHelper.create(echarts, 'plain4', {
title: [
'(Legend symbol of line)??',
],
option: option4,
height: 300
});
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.
The default borderWidth of legend symbol is 0, so the borderColor only can be seen when the legend.itemStyle.borderWidth is not 0.
Add the itemStyle to legend symbol.
legend.itemStyle.borderWidth !== 0
legend.itemStyle.borderWidth
legend.itemStyle.borderColor
andseries[i].itemStyle.borderColor
, and thelegend.itemStyle.borderColor
has higher priority.emptyCircle
legend symbol is the same as color of seriesbarBorderColor