-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
waiting for maintainerTriage or intervention needed from a maintainerTriage or intervention needed from a maintainer
Description
Describe the bug / 问题描述
我绘制了一个柱形+折线的双轴分面图,但是
- 图例只显示了后绘制的折线图的图例,交换绘制顺序后,只显示了柱形图的图例,图例缺失一部分。
- 左右轴的数据值相差较大,但是刻度却自动同步了,这在单独的双轴图中就是按照各自的值生成的刻度
- y轴只在第一个分面显示了,后边的分面没有y轴,希望第一个分面显示左轴,最后一个分面显示右轴
如下图所示:
复现代码如下:
g2-demo.html
const data = [
{ name: '薪金', date: '20210121', leftKey: '指标1', leftValue: 2.7, rightKey: '指标A', rightValue: 13 },
{ name: '薪金', date: '20210121', leftKey: '指标2', leftValue: 1.5, rightKey: '指标B', rightValue: 18 },
{ name: '薪金', date: '20210121', leftKey: '指标3', leftValue: 3.3, rightKey: '指标C', rightValue: 22 },
{ name: '薪金', date: '20210121', leftKey: '指标4', leftValue: 1.4, rightKey: '指标D', rightValue: 26 },
{ name: '货币', date: '20210121', leftKey: '指标1', leftValue: 2.2, rightKey: '指标A', rightValue: 17 },
{ name: '货币', date: '20210121', leftKey: '指标2', leftValue: 5.6, rightKey: '指标B', rightValue: 44 },
{ name: '货币', date: '20210121', leftKey: '指标3', leftValue: 3.1, rightKey: '指标C', rightValue: 31 },
{ name: '货币', date: '20210121', leftKey: '指标4', leftValue: 2.5, rightKey: '指标D', rightValue: 18 },
{ name: '现金', date: '20210121', leftKey: '指标1', leftValue: 1.3, rightKey: '指标A', rightValue: 29 },
{ name: '现金', date: '20210121', leftKey: '指标2', leftValue: 3.6, rightKey: '指标B', rightValue: 36 },
{ name: '现金', date: '20210121', leftKey: '指标3', leftValue: 2.1, rightKey: '指标C', rightValue: 66 },
{ name: '现金', date: '20210121', leftKey: '指标4', leftValue: 1.5, rightKey: '指标D', rightValue: 52 },
{ name: '薪金', date: '20210122', leftKey: '指标1', leftValue: 4.2, rightKey: '指标A', rightValue: 48 },
{ name: '薪金', date: '20210122', leftKey: '指标2', leftValue: 2.8, rightKey: '指标B', rightValue: 33 },
{ name: '薪金', date: '20210122', leftKey: '指标3', leftValue: 5.1, rightKey: '指标C', rightValue: 65 },
{ name: '薪金', date: '20210122', leftKey: '指标4', leftValue: 1.9, rightKey: '指标D', rightValue: 21 },
{ name: '货币', date: '20210122', leftKey: '指标1', leftValue: 3.6, rightKey: '指标A', rightValue: 55 },
{ name: '货币', date: '20210122', leftKey: '指标2', leftValue: 4.9, rightKey: '指标B', rightValue: 41 },
{ name: '货币', date: '20210122', leftKey: '指标3', leftValue: 2.3, rightKey: '指标C', rightValue: 38 },
{ name: '货币', date: '20210122', leftKey: '指标4', leftValue: 5.4, rightKey: '指标D', rightValue: 67 },
{ name: '现金', date: '20210122', leftKey: '指标1', leftValue: 1.7, rightKey: '指标A', rightValue: 25 },
{ name: '现金', date: '20210122', leftKey: '指标2', leftValue: 3.3, rightKey: '指标B', rightValue: 59 },
{ name: '现金', date: '20210122', leftKey: '指标3', leftValue: 4.0, rightKey: '指标C', rightValue: 44 },
{ name: '现金', date: '20210122', leftKey: '指标4', leftValue: 2.1, rightKey: '指标D', rightValue: 30 },
{ name: '薪金', date: '20210123', leftKey: '指标1', leftValue: 3.8, rightKey: '指标A', rightValue: 52 },
{ name: '薪金', date: '20210123', leftKey: '指标2', leftValue: 1.2, rightKey: '指标B', rightValue: 27 },
{ name: '薪金', date: '20210123', leftKey: '指标3', leftValue: 4.5, rightKey: '指标C', rightValue: 39 },
{ name: '薪金', date: '20210123', leftKey: '指标4', leftValue: 2.6, rightKey: '指标D', rightValue: 43 },
{ name: '货币', date: '20210123', leftKey: '指标1', leftValue: 2.9, rightKey: '指标A', rightValue: 22 },
{ name: '货币', date: '20210123', leftKey: '指标2', leftValue: 5.2, rightKey: '指标B', rightValue: 50 },
{ name: '货币', date: '20210123', leftKey: '指标3', leftValue: 3.7, rightKey: '指标C', rightValue: 29 },
{ name: '货币', date: '20210123', leftKey: '指标4', leftValue: 1.8, rightKey: '指标D', rightValue: 15 },
{ name: '现金', date: '20210123', leftKey: '指标1', leftValue: 4.1, rightKey: '指标A', rightValue: 61 },
{ name: '现金', date: '20210123', leftKey: '指标2', leftValue: 2.4, rightKey: '指标B', rightValue: 34 },
{ name: '现金', date: '20210123', leftKey: '指标3', leftValue: 3.9, rightKey: '指标C', rightValue: 70 },
{ name: '现金', date: '20210123', leftKey: '指标4', leftValue: 1.3, rightKey: '指标D', rightValue: 24 },
];
// 初始化图表实例
const chart = new G2.Chart({
container: 'chart',
width: 800,
height: 400,
paddingTop: 120,
paddingRight: 60,
paddingBottom: 60,
paddingLeft: 60,
});
const facetRect = chart.facetRect().data(data).encode('x', 'name');
const facetView = facetRect.view();
facetView.attr('frame', false)
.interaction('tooltip', {crosshairs: false, shared: true})
.interaction('elementHighlight', {background: true, region: true});
facetView.interval()
.encode('x', 'date')
.encode('y', 'leftValue')
.encode('color', 'leftKey')
.axis('x', {title: null})
.axis('y', {title: null})
.transform({type: 'stackY'});
facetView.line()
.encode('x', 'date')
.encode('y', 'rightValue')
.encode('color', 'rightKey')
.axis('x', {title: null})
.axis('y', {position: 'right',title: null})
.scale('y', {independent: true});
chart.render();Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他
Metadata
Metadata
Assignees
Labels
waiting for maintainerTriage or intervention needed from a maintainerTriage or intervention needed from a maintainer