作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是一个通用的胜利代码。
<svg viewBox={viewBox}>
<VictoryPie
standalone={false}
width={width} height={height}
data={data}
innerRadius={innerRadius}
colorScale={colorScale}
/>
<VictoryLegend x={width - 50} y={30}
title="Totals"
centerTitle
orientation="vertical"
gutter={20}
style={{
title: { fontSize: 15 }
}}
data={legendDataWithStyle}
standalone={false}
/>
</svg>
这是对应的Jsfiddle
我正在使用 VictoryLegend x={width - 50} y={30}
来调节饼图和图例的距离。但是我发现很难精确地调整它。如何增加饼图和图例的距离?
最佳答案
我可以建议您使用 g
具有适当的 transform
属性值的元素
The g SVG element is a container used to group other SVG elements. Transformations applied to the element are performed on all of its child elements, and any of its attributes are inherited by its child elements.
width
和 height
属性用于 svg
元素而不是 viewBox
。我 fork 了你的 fiddle ,请检查 - https://jsfiddle.net/levsha/5tx2s8jj/这里the diff between your and my code .
<svg width={width + 100} height={height}> // we add 100 here to legend fits in svg
...
<g transform="translate(40,0)"> // we move legend on 40px here
<VictoryLegend x={width} y={30}
title="Totals"
centerTitle
orientation="vertical"
gutter={20}
style={{
title: { fontSize: 15 }
}}
data={legendDataWithStyle}
standalone={false}
/>
</g>
关于css - 如何调整胜率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47346561/
我是一名优秀的程序员,十分优秀!