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

图例重叠在一起 #2173

Closed
yeqisong opened this issue Mar 16, 2020 · 0 comments · Fixed by #2257
Closed

图例重叠在一起 #2173

yeqisong opened this issue Mar 16, 2020 · 0 comments · Fixed by #2257
Assignees

Comments

@yeqisong
Copy link

yeqisong commented Mar 16, 2020

  • G2 Version: 4.0.1
  • Platform: web
  • Mini Showcase(like screenshots):
  • CodePen Link:

问题:用例没有自动布局。
1、使用2个view时

var data1 = [
        {time: '2020-03-01', views:'pv', view_value: 1900},
        {time: '2020-03-01', views:'uv', view_value: 1000},
        {time: '2020-03-02', views:'pv', view_value: 2100},
        {time: '2020-03-02', views:'uv', view_value: 800},
        {time: '2020-03-03', views:'pv', view_value: 2100},
        {time: '2020-03-03', views:'uv', view_value: 800},
        {time: '2020-03-04', views:'pv', view_value: 1900},
        {time: '2020-03-04', views:'uv', view_value: 1000}
    ];
    var data2 = [
        {time: '2020-03-01', products:'product1', sale_value: 56},
        {time: '2020-03-01', products:'product2', sale_value: 36},
        {time: '2020-03-02', products:'product1', sale_value: 46},
        {time: '2020-03-02', products:'product2', sale_value: 46},
        {time: '2020-03-03', products:'product1', sale_value: 46},
        {time: '2020-03-03', products:'product2', sale_value: 46},
        {time: '2020-03-04', products:'product1', sale_value: 56},
        {time: '2020-03-04', products:'product2', sale_value: 36}
    ];
var view1 = chart.createView();
    view1.data(data1);
    view1.line().position('time*view_value').color('views');
    
    var view2 = chart.createView();
    view2.data(data2);
    view2.line().position('time*sale_value').color('products');

生产的图表,图例重叠在一起了。

2、一个chart时

var data = [
        {time: '2020-03-01', views:'pv', view_value: 1900},
        {time: '2020-03-01', views:'uv', view_value: 1000},
        {time: '2020-03-01', products:'product1', sale_value: 56},
        {time: '2020-03-01', products:'product2', sale_value: 36},
        {time: '2020-03-02', views:'pv', view_value: 2100},
        {time: '2020-03-02', views:'uv', view_value: 800},
        {time: '2020-03-02', products:'product1', sale_value: 46},
        {time: '2020-03-02', products:'product2', sale_value: 46},
        {time: '2020-03-03', views:'pv', view_value: 2100},
        {time: '2020-03-03', views:'uv', view_value: 800},
        {time: '2020-03-03', products:'product1', sale_value: 46},
        {time: '2020-03-03', products:'product2', sale_value: 46},
        {time: '2020-03-04', views:'pv', view_value: 1900},
        {time: '2020-03-04', views:'uv', view_value: 1000},
        {time: '2020-03-04', products:'product1', sale_value: 56},
        {time: '2020-03-04', products:'product2', sale_value: 36}
    ];
chart.line().position('time*view_value').color('views');
    chart.line().position('time*sale_value').color('products');

生成的图表,图例依然重叠在一起。

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 a pull request may close this issue.

2 participants