import React, {useEffect, useState} from 'react';
import {TouchableOpacity} from 'react-native';
import {Alert} from 'react-native';
import {View, Text, StyleSheet} from 'react-native';
import {BarChart, LineChart} from './src';
const App = () => {
const [toggle, setToggle] = useState(true);
useEffect(() => {
setTimeout(() => {
setCurrentData(latestData5);
}, 1100 + 100 + 310);
setTimeout(() => {
setCurrentData(latestData2);
}, 1100 + 300 + 620);
setTimeout(() => {
setCurrentData(latestData5);
}, 1100 + 500 + 930);
setTimeout(() => {
setCurrentData(latestData3);
}, 1100 + 1000 + 1240);
setTimeout(() => {
setCurrentData(latestData4);
}, 1100 + 1500 + 1550);
setTimeout(() => {
setCurrentData(latestData5);
}, 6000);
setTimeout(() => {
setCurrentData(latestData);
}, 7000);
}, []);
const dPoint = () => {
return (
);
};
const lcomp = val => {
return (
{val}
);
};
const latestData = [
{
value: 600 - 100,
labelComponent: () => lcomp('22 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 120,
hideDataPoint: true,
},
{
value: 600 - 210,
customDataPoint: dPoint,
},
{
value: 600 - 250,
hideDataPoint: true,
},
{
value: 600 - 320,
labelComponent: () => lcomp('24 Nov'),
customDataPoint: dPoint,
showStrip: true,
stripHeight: 190,
stripColor: 'black',
dataPointLabelComponent: () => {
return (
410
);
},
dataPointLabelShiftY: -70,
dataPointLabelShiftX: -14,
},
{
value: 600 - 310,
hideDataPoint: true,
},
{
value: 600 - 270,
customDataPoint: dPoint,
},
{
value: 600 - 240,
hideDataPoint: true,
},
{
value: 600 - 130,
labelComponent: () => lcomp('26 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 120,
hideDataPoint: true,
},
{
value: 600 - 100,
customDataPoint: dPoint,
},
{
value: 600 - 210,
hideDataPoint: true,
},
{
value: 600 - 270,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 240,
hideDataPoint: true,
},
{
value: 600 - 120,
hideDataPoint: true,
},
{
value: 600 - 100,
customDataPoint: dPoint,
},
{
value: 600 - 210,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 20,
hideDataPoint: true,
},
{
value: 600 - 100,
customDataPoint: dPoint,
},
];
const latestData2 = [
{
value: 400 - 100,
labelComponent: () => lcomp('22 Nov'),
customDataPoint: dPoint,
},
{
value: 400 - 120,
hideDataPoint: true,
},
{
value: 400 - 210,
customDataPoint: dPoint,
},
{
value: 400 - 250,
hideDataPoint: true,
},
{
value: 400 - 320,
labelComponent: () => lcomp('24 Nov'),
customDataPoint: dPoint,
showStrip: true,
stripHeight: 190,
stripColor: 'black',
dataPointLabelComponent: () => {
return (
410
);
},
dataPointLabelShiftY: -70,
dataPointLabelShiftX: -14,
},
{
value: 400 - 310,
hideDataPoint: true,
},
{
value: 400 - 270,
customDataPoint: dPoint,
},
{
value: 400 - 240,
hideDataPoint: true,
},
{
value: 400 - 130,
labelComponent: () => lcomp('26 Nov'),
customDataPoint: dPoint,
},
{
value: 400 - 120,
hideDataPoint: true,
},
{
value: 400 - 100,
customDataPoint: dPoint,
},
{
value: 400 - 210,
hideDataPoint: true,
},
{
value: 400 - 270,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 400 - 240,
hideDataPoint: true,
},
{
value: 400 - 120,
hideDataPoint: true,
},
{
value: 400 - 100,
customDataPoint: dPoint,
},
{
value: 400 - 210,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 400 - 20,
hideDataPoint: true,
},
{
value: 400 - 100,
customDataPoint: dPoint,
},
];
const latestData3 = [
{
value: 600 - 170,
labelComponent: () => lcomp('22 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 60,
hideDataPoint: true,
},
{
value: 600 - 290,
customDataPoint: dPoint,
},
{
value: 600 - 120,
hideDataPoint: true,
},
{
value: 600 - 390,
labelComponent: () => lcomp('24 Nov'),
customDataPoint: dPoint,
showStrip: true,
stripHeight: 190,
stripColor: 'black',
dataPointLabelComponent: () => {
return (
410
);
},
dataPointLabelShiftY: -70,
dataPointLabelShiftX: -14,
},
{
value: 600 - 210,
hideDataPoint: true,
},
{
value: 600 - 370,
customDataPoint: dPoint,
},
{
value: 600 - 140,
hideDataPoint: true,
},
{
value: 600 - 330,
labelComponent: () => lcomp('26 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 50,
hideDataPoint: true,
},
{
value: 600 - 200,
customDataPoint: dPoint,
},
{
value: 600 - 110,
hideDataPoint: true,
},
{
value: 600 - 370,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 140,
hideDataPoint: true,
},
{
value: 600 - 320,
hideDataPoint: true,
},
{
value: 600 - 20,
customDataPoint: dPoint,
},
{
value: 600 - 310,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 600 - 120,
hideDataPoint: true,
},
{
value: 600 - 100,
customDataPoint: dPoint,
},
];
const latestData4 = [
{
value: 300 - 170,
labelComponent: () => lcomp('22 Nov'),
customDataPoint: dPoint,
},
{
value: 300 - 60,
hideDataPoint: true,
},
{
value: 300 - 290,
customDataPoint: dPoint,
},
{
value: 300 - 120,
hideDataPoint: true,
},
{
value: 300 - 390,
labelComponent: () => lcomp('24 Nov'),
customDataPoint: dPoint,
showStrip: true,
stripHeight: 190,
stripColor: 'black',
dataPointLabelComponent: () => {
return (
410
);
},
dataPointLabelShiftY: -70,
dataPointLabelShiftX: -14,
},
{
value: 300 - 210,
hideDataPoint: true,
},
{
value: 300 - 370,
customDataPoint: dPoint,
},
{
value: 300 - 140,
hideDataPoint: true,
},
{
value: 300 - 330,
labelComponent: () => lcomp('26 Nov'),
customDataPoint: dPoint,
},
{
value: 300 - 50,
hideDataPoint: true,
},
{
value: 300 - 200,
customDataPoint: dPoint,
},
{
value: 300 - 110,
hideDataPoint: true,
},
{
value: 300 - 370,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 300 - 140,
hideDataPoint: true,
},
{
value: 300 - 320,
hideDataPoint: true,
},
{
value: 300 - 20,
customDataPoint: dPoint,
},
{
value: 300 - 310,
labelComponent: () => lcomp('28 Nov'),
customDataPoint: dPoint,
},
{
value: 300 - 120,
hideDataPoint: true,
},
{
value: 300 - 100,
customDataPoint: dPoint,
},
];
const latestData5 = [];
for (let i = 0; i < latestData.length; i++) {
latestData5[i] = {...latestData, value: 300};
}
const [currentData, setCurrentData] = useState(latestData);
const customLabel = val => {
return (
{val}
);
};
const [data, setData] = useState([
{value: 15, label: 'Jan'},
{
value: 40,
label: 'Feb',
verticalLineColor: 'red',
// showVerticalLine: true,
verticalLineThickness: StyleSheet.hairlineWidth,
dataPointLabelComponent: () => customLabel(40),
},
{
value: 10,
label: 'Mar',
dataPointLabelComponent: () => customLabel(10),
},
{
value: 30,
label: 'Apr',
dataPointLabelComponent: () => customLabel(30),
},
{
value: 20,
label: 'May',
dataPointLabelComponent: () => customLabel(20),
},
{
value: 40,
label: 'Jun',
focusedDataPointLabelComponent: () => customLabel(40),
},
{value: 48, label: 'Jul'},
{value: 30, label: 'Aug'},
{value: 20, label: 'Sep'},
{value: 40, label: 'Oct'},
{
value: 48,
label: 'Nov',
onPress: () => Alert.alert('Sales in Nov skyrocketed to $48 M'),
},
{value: 30, label: 'Dec'},
]);
return (
{/* setCurrentData(latestData)}
style={{padding: 12, backgroundColor: 'lightgreen', marginBottom: 15}}>
Smooth
setCurrentData(latestData2)}
style={{padding: 12, backgroundColor: 'lightgreen', marginBottom: 15}}>
Smooth Low
setCurrentData(latestData3)}
style={{padding: 12, backgroundColor: 'lightgreen', marginBottom: 15}}>
Edged
setCurrentData(latestData4)}
style={{padding: 12, backgroundColor: 'lightgreen', marginBottom: 15}}>
Edged Low
setCurrentData(latestData5)}
style={{padding: 12, backgroundColor: 'lightgreen'}}>
Straight
*/}
{/* {!toggle ? (
) : (
{
return (
);
}}
// focusedCustomDataPoint={() => {
// return (
//
// );
// }}
// onPress={(item, index) => {
// console.log('index-->', index);
// setData(data => {
// item.focusedCustomDataPoint = () => {
// return (
//
// );
// };
// data[index] = item;
// console.log('data------.....', data);
// return data;
// });
// }}
// disableScroll
pressEnabled
// showDataPointOnPress
showStripOnPress
// showTextOnPress
// textShiftY={-10}
// textShiftX={-5}
// textFontSize={18}
// textColor={'green'}
// stripWidth={1}
// stripHeight={200}
// stripHeight={200}
// stripOpacity={1}
// curved
// isAnimated
// animationDuration={2000}
// animationDuration={2000}
// dataPointsShape="rectangular"
// showGradient
color={'rgb(78, 0, 142)'}
yAxisColor={'rgb(78, 0, 142)'}
xAxisColor={'rgb(78, 0, 142)'}
// dataPointsColor={'yellow'}
dataPointsWidth={20}
dataPointsHeight={20}
xAxisThickness={3}
yAxisThickness={3}
// dataPointsRadius={4}
// focusedDataPointRadius={10}
yAxisTextStyle={{color: 'rgb(78, 0, 142)'}}
startFillColor={'rgb(200, 100, 244)'}
startOpacity={0.9}
endFillColor={'rgb(255, 255, 255)'}
endOpacity={0.2}
/>
)} */}
{/* setToggle(!toggle)}
style={{marginTop: 100, alignSelf: 'center'}}>
Line Chart
*/}
);
};
export default App;