<BarChart initialSpacing={0} stackData={existingArray} width={screenWidth * 0.8}…
- User
<BarChart initialSpacing={0} stackData={existingArray} width={screenWidth * 0.8} height={220} barWidth={50} spacing={1} lineConfig={{textColor: "black", textFontSize: 18, textShiftX: 4}} verticalLabelRotation={20} isAnimated fromZero={true} showLine={false} xAxisLength={0} xAxisColor={"transparent"} yAxisColor={"transparent"} xAxisLabelTextStyle={{ color: "gray", left: 10, top: -3, fontSize: 12, fontFamily: FONTS.MEDIUM, }}
hideRules hideYAxisText hideOrigin={true} hideDataPoints={true} barStyle={{ marginHorizontal: 10, justifyContent: "center", alignItems: "center", }} scrollAnimation={true} yAxisIndicesColor={"transparent"} labelTextStyle={{marginVertical: 10}} // renderBars={renderBars} animateOnDataChange={true} renderTooltip={item => { console.log(item); return ( <View style={{ height: 25, width: 49, backgroundColor: "#DBDBDB", borderRadius: 5, marginVertical: 1, justifyContent: "center", alignItems: "center", }}> <Text style={{ top: 2, right: -2, color: "black", fontFamily: FONTS.BOLD, fontSize:12 }}> {item.stacks[0].value} TND </Text> </View> ); }} renderBars={({bars}) => { console.log(bars); return bars.map((bar, index) => { const {x, y, width, height} = bar; const value = bar.stacks.reduce( (sum, stack) => sum + stack.value, 0, ); return ( <React.Fragment key={index}> <Rect x={x} y={y} width={width} height={height} fill={bar.backgroundColor} /> <Svg> <Texts x={x + width / 2} y={y - 10} textAnchor="middle" fill="black" fontFamily={FONTS.REGULAR} fontSize={12}> {value} TND </Texts> </Svg> </React.Fragment> ); }); }} /> why renderbars dont work here and i use react native gifted charts and i use stack in this package - Assistant
It seems that the
renderBarsprop is not working properly in the given code snippet. However, it is difficult to determine the exact reason without further analysis or access to the complete code.The issue might be related to the compatibility between the "react-native-gifted-charts" library and the "renderBars" implementation in the code. It is recommended to check the documentation and examples provided by the library to understand the proper usage of the
renderBarsprop.Alternatively, you can consider exploring other charting libraries that offer more comprehensive support and better documentation for rendering bars with stacked data in React Native. Some popular options include "react-native-chart-kit" and "react-native-svg-charts".