我正试图将这个react-native-chart-kit条形图对齐到中心。Bar Chart
这是我目前拥有的代码:
<BarChart
data={{
labels: ["SU", "MO", "TU", "WE", "TH", "FR", "SA"],
datasets: [
{
data: [
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
],
},
],
}}
width={Dimensions.get("window").width - 100}
height={220}
withHorizontalLabels={false}
fromZero={true}
withInnerLines={false}
chartConfig={{
backgroundGradientFrom: dark.backgroundColor,
backgroundGradientTo: dark.backgroundColor,
decimalPlaces: 0,
fillShadowGradientFrom: accent,
fillShadowGradientTo: accent,
fillShadowGradientFromOpacity: 1,
fillShadowGradientToOpacity: 0.25,
barPercentage: 0.75,
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
}}
style={{
marginVertical: 10,
borderRadius: 10,
}}
/>
我想禁用withHorizontalLabels
属性也会删除它所占用的空间,但事实并非如此。我试过调整propsForHorizontalLabels
的样式,但没有结果。
1条答案
按热度按时间fjaof16o1#
下面是一个工作示例:
在这里检查:https://snack.expo.dev/@footios/charts-in-the-center