I'm going to keep this brief and just include the important details.
I added this chart kit to my react native project and began to test it out. I needed a line chart so I naturally used the "LineChart." However, I ran into a few issues.
First
I can't seem to change the background color for the life of me. The gradient color works perfectly fine, but "backgroundColor" in the chartConfig, style, or chartConfig style, does not have any effect. If no gradient background is specified then the background is just black.
Second
Transparent backgrounds of any sort (I could only change the background through gradient) does not work, and also results in black background. I tried 'transparent' and 'rgba' yet neither of those work.
Component
import React from 'react';
import {
Dimensions,
StyleSheet,
Text,
View
} from 'react-native';
import { LineChart } from 'react-native-chart-kit';
const styles = StyleSheet.create({
outerContainer: {
elevation: 4,
backgroundColor: '#fff',
borderRadius: 10,
marginTop: 25
},
});
const chartConfig = {
backgroundColor: '#e26a00',
color: (opacity = 1) => `#2699FB`,
strokeWidth: 2,
}
const data = {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [{
data: [20, 45, 28, 80, 99, 43],
color: (opacity = 1) => `rgba(134, 65, 244, ${opacity})`, // optional
strokeWidth: 2 // optional
}]
}
export default class TideChart extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.outerContainer}>
<View>
<LineChart
data={data}
height={220}
width={Dimensions.get('window').width - 20}
chartConfig={chartConfig}
style={{ marginBottom: 25, marginTop: 25 }}
bezier
/>
</View>
</View>
);
}
}
Most of this is "right out of the box" but I tried a few things to try and fix. I wrapped it in a view and tried to get something to change.
I'm hoping this is just an error on my part.
I'm going to keep this brief and just include the important details.
I added this chart kit to my react native project and began to test it out. I needed a line chart so I naturally used the "LineChart." However, I ran into a few issues.
First
I can't seem to change the background color for the life of me. The gradient color works perfectly fine, but "backgroundColor" in the chartConfig, style, or chartConfig style, does not have any effect. If no gradient background is specified then the background is just black.
Second
Transparent backgrounds of any sort (I could only change the background through gradient) does not work, and also results in black background. I tried 'transparent' and 'rgba' yet neither of those work.
Component
Most of this is "right out of the box" but I tried a few things to try and fix. I wrapped it in a view and tried to get something to change.
I'm hoping this is just an error on my part.