react-native - 尝试在 React-Native 中的 Victory 图表中的条形图中创建对角虚线(线性渐变)
问题描述
我的大部分功能都在工作:
这是代码:
<VictoryStack
animate={{ duration: 500 }}
height={60}
padding={{ left: 15, top: 0, bottom: 30, right: 15 }}
horizontal
style={{ data: { width: 24 } }}>
<VictoryBar
style={{ data: { fill: Colors.score.detractors } }}
data={[{ x: 1, y: detractor }]}
cornerRadius={
passive === 0 && promoter === 0
? {
bottomLeft: 10,
bottomRight: 10,
topLeft: 10,
topRight: 10,
}
: { bottomLeft: 10, bottomRight: 10 }
}
labels={() => `${detractor}%`}
labelComponent={
<VictoryLabel
x={45}
dy={25}
textAnchor="end"
verticalAnchor="start"
style={labelStyle}
/>
}
/>
<VictoryBar
animate={{ duration: 500 }}
style={{ data: { fill: Colors.score.passives } }}
data={[{ x: 1, y: passive }]}
cornerRadius={
detractor === 0 && promoter === 0
? {
bottomLeft: 10,
bottomRight: 10,
topLeft: 10,
topRight: 10,
}
: detractor === 0
? { bottomLeft: 10, bottomRight: 10 }
: promoter === 0
? { topLeft: 10, topRight: 10 }
: {}
}
labels={() => `${passive}%`}
labelComponent={
<VictoryLabel
x={200}
dy={25}
textAnchor="end"
verticalAnchor="start"
style={labelStyle}
/>
}
/>
<VictoryBar
animate={{ duration: 500 }}
style={{ data: { fill: Colors.score.promoters } }}
data={[{ x: 1, y: promoter }]}
cornerRadius={
passive === 0 && detractor === 0
? {
bottomLeft: 10,
bottomRight: 10,
topLeft: 10,
topRight: 10,
}
: { topLeft: 10, topRight: 10 }
}
labels={() => `${promoter}%`}
labelComponent={
<VictoryLabel
dx={0}
dy={25}
textAnchor="end"
verticalAnchor="start"
style={labelStyle}
/>
}
/>
</VictoryStack>
但我不确定如何将那些对角虚线渐变线添加为条形图中的填充。
我需要修补 react-svg 还是Victory-charts可以开箱即用?
解决方案
推荐阅读
- javascript - 未在实例上定义,但在渲染期间引用,但可以按我的意愿工作
- javascript - 如何在渲染组件之前获取要加载的链接?
- sql - ClickHouse - SELECT 行数据太慢
- javascript - 将格式应用于 ag-Grid 中的一行
- amazon-web-services - SSO - 权限集不能承担角色
- ruby-on-rails - 如何覆盖来自 :require_no_authentication 中的设计集的 Flash 消息
- java - java - 如何在java spring中将多个枚举映射到同一列?
- javascript - 如何在按钮单击 [JAVASCRIPT] 上附加和运行脚本
- typescript - 从 TypeScript 中自定义类型的键构造字符串联合类型
- azure-devops - Azure DevOps - 自定义任务板上的列 - SCRUM 流程