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

Feature #7340. Add the itemStyle to legend #11302

Merged
merged 7 commits into from
Sep 23, 2019
Merged

Conversation

yufeng04
Copy link
Contributor

Add the itemStyle to legend symbol.

  • The default borderWidth of legend symbol is 0, so the borderColor only can be seen when the legend.itemStyle.borderWidth isn't 0.
  • legend.itemStyle.borderWidth !== 0
    1. the borderWidth of legend symbol only depends on legend.itemStyle.borderWidth
    2. the boderColor of legend symbol depends on legend.itemStyle.borderColor and series[i].itemStyle.borderColor, and the legend.itemStyle.borderColor has higher priority.
    3. The borderColor of emptyCircle legend symbol is the same as color of series
    4. The legend borderColor is incompatible with barBorderColor
  • The former PR

@yufeng04 yufeng04 changed the title fix bug #7340. Add the itemStyle to legend Feature #7340. Add the itemStyle to legend Sep 23, 2019
pissang
pissang previously approved these changes Sep 23, 2019

if (!singleDataBorderColor) {
// FIXME Performance
var itemModel = dataAll.getItemModel(rawIdx);
Copy link
Member

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.

Copy link
Contributor Author

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);
}
};

Copy link
Member

Choose a reason for hiding this comment

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

image

Why they are different

Copy link
Contributor Author

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 };
Copy link
Member

Choose a reason for hiding this comment

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

image

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
});

Copy link
Contributor Author

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.

pissang
pissang previously approved these changes Sep 23, 2019
@100pah 100pah merged commit 2df6956 into apache:master Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants