如何设置FacetRect各个plot的间距,类似V4的spacing? #5932
-
即实现,下图中的红框间的距离为0; 代码如下: /**
* A recreation of one of these demos: https://observablehq.com/@observablehq/plot-facets?collection=@observablehq/plot
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
width: 928,
height: 320,
padding: 0,
margin: 0,
inset: 0,
paddingOuter: 0
});
const facetRect = chart
.facetRect({
paddingOuter: 0,
})
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/anscombe.json',
})
.encode('x', 'series')
// .axis(false)
// .legend(false)
.style({
fill: 'rgba(0,0,0,0.1)',
stroke: 'red',
strokeWidth: 1,
})
facetRect
.point()
.attr('margin', 20)
.encode('x', 'x')
.encode('y', 'y')
.encode('color', (d) => `${d.series}`)
.viewStyle({
contentFill: 'rgba(0,0,0,0.1)'
})
chart.render(); |
Beta Was this translation helpful? Give feedback.
Answered by
Xiatian-leo
Dec 15, 2023
Replies: 1 comment
-
已解决了,通过在scale中添加 paddingInner:0 const facetRect = chart
.facetRect({
paddingOuter: 0,
})
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/anscombe.json',
})
.encode('x', 'series')
// .axis(false)
// .legend(false)
.style({
fill: 'rgba(0,0,0,0.1)',
stroke: 'red',
strokeWidth: 1,
})
// 此处添加
.scale({
x: {
paddingInner: 0
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hustcc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
已解决了,通过在scale中添加 paddingInner:0