import React, {useEffect, useState} from 'react';
import {ScrollView, TouchableOpacity} from 'react-native';
import {Alert} from 'react-native';
import {View, Text, StyleSheet} from 'react-native';
import {MyPattern} from './src/pattern';
import {BarChart, LineChart, PieChart} from './src';
import {Path, Pattern} from 'react-native-svg';
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 ndd = [
{value: 30, color: 'rgb(84,219,234)'},
{value: 40, color: 'lightgreen'},
{value: 20, color: 'orange'},
];
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'},
]);
const renderLegend = (text, color) => {
return (
{text || ''}
);
};
// const styleObject = {
// marginLeft: -95,
// paddingLeft: 120,
// transform: [{rotate: '90deg'}],
// };
const ddtt = [
{
value: 10,
label: 'January month',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 20,
label: 'February month',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 30,
label: 'March month',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 20,
label: 'April month',
labelTextStyle: styleObject,
labelWidth: 130,
},
];
const MyPattern = () => {
return (
);
};
const nn = () => {
return (
);
};
const [dtt, setDtt] = useState([
{
value: 110,
barBackgroundPattern: MyPattern,
patternId: 'DiagonalLines',
frontColor: '#4444dd',
spacing: 8,
},
{value: 130},
{
value: 120,
barBackgroundPattern: MyPattern,
patternId: 'DiagonalLines',
frontColor: '#4444dd',
spacing: 8,
},
{value: 160},
{
value: 190,
barBackgroundPattern: MyPattern,
patternId: 'DiagonalLines',
frontColor: '#4444dd',
spacing: 8,
},
]);
const barData = [
{
value: 15,
label: 'Mon',
},
{value: 30, label: 'Tue'},
{value: -23, label: 'Wed'},
{value: 40, label: 'Thu'},
{value: -16, label: 'Wed'},
{value: 40, label: 'Thu'},
{value: -16, label: 'Wed'},
{value: 40, label: 'Thu'},
];
const sdata = [
{
value: 1.0,
label: '1',
showVerticalLine: true,
verticalLineUptoDataPoint: true,
verticalLineColor: 'green',
},
{value: 0.75, label: '2'},
{value: 0.25, label: '3'},
{value: 0.0, label: '4'},
{value: 0.5, label: '5'},
{value: 0.72, label: '6'},
{value: 0.85, label: '7'},
{value: 0.0, label: '8'},
{value: 0.5, label: '9'},
{value: 0.72, label: '10'},
{value: 0.85, label: '11'},
{value: 0.72, label: '12'},
{value: 0.85, label: '13'},
{value: 0.72, label: '14'},
{value: 0.85, label: '15'},
];
const lineData = [
{value: 8, pointerShiftX: 10, pointerShiftY: -10},
{value: 10},
{value: 12},
{value: 8},
{value: 11},
{value: 13},
{value: 19},
{value: 18},
{value: 22},
{value: 20},
{value: 28},
{value: 32},
{value: 36},
{value: 40},
{value: 38},
{value: 40},
{value: 42},
{value: 46},
{value: 44},
{value: 40},
{value: 36},
{value: 32},
{value: 38},
{value: 36},
{value: 32},
{value: 28},
{value: 22},
{value: 20},
];
// const lineData = [
// {value: 0, dataPointText: '0'},
// {value: 10, dataPointText: '10'},
// {value: 8, dataPointText: '8'},
// {value: 58, dataPointText: '58'},
// {value: 56, dataPointText: '56'},
// {value: 78, dataPointText: '78'},
// {value: 74, dataPointText: '74'},
// {value: 98, dataPointText: '98'},
// ];
// const lineData2 = [
// {value: 0, dataPointText: '0'},
// {value: 20, dataPointText: '20'},
// {value: 18, dataPointText: '18'},
// {value: 40, dataPointText: '40'},
// {value: 36, dataPointText: '36'},
// {value: 60, dataPointText: '60'},
// {value: 54, dataPointText: '54'},
// {value: 85, dataPointText: '85'},
// ];
const styleObject = {
marginLeft: -95,
paddingLeft: 110,
transform: [{rotate: '90deg'}],
// backgroundColor: 'red',
};
const lineData1 = [
{
value: 10000,
barMarginBottom: 20,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 40000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 48000,
onPress: item => Alert.alert(item.value + ''),
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 50000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 56000,
barMarginBottom: 40,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 70000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 90000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 95000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 70000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 90000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
{
value: 95000,
label: 'hello world',
labelTextStyle: styleObject,
labelWidth: 130,
},
];
const lineData2 = [
{value: 5},
{value: 8},
{value: 18},
{value: 22},
{value: 30},
{value: 44},
{value: 52},
];
const stackData = [
{
stacks: [
{value: 10, color: 'orange'},
{value: 20, color: '#4ABFF4', marginBottom: 2},
],
spacing: 15,
label: 'Jan',
},
{
stacks: [
{value: 10, color: '#4ABFF4'},
{value: 11, color: 'orange', marginBottom: 2},
{value: 15, color: '#28B2B3', marginBottom: 2},
],
label: 'Mar',
},
{
stacks: [
{value: 14, color: 'orange'},
{value: 18, color: '#4ABFF4', marginBottom: 2},
],
spacing: 15,
label: 'Feb',
},
{
stacks: [
{value: 7, color: '#4ABFF4'},
{value: 11, color: 'orange', marginBottom: 2},
{value: 10, color: '#28B2B3', marginBottom: 2},
],
label: 'Mar',
},
];
const showChart = [
{value: 50, label: 'archieved', labelTextStyle: {textAlign: 'left'}},
{value: 450, label: 'discared', labelTextStyle: {textAlign: 'left'}},
{value: 1387, label: 'active', labelTextStyle: {textAlign: 'left'}},
];
const ldt = [
{value: -10},
{value: 25},
{value: 24},
{value: 45},
{value: 60},
{value: -34},
{value: 24},
{value: 45},
{value: 60},
{value: -34},
];
const pieData = [
{value: 54, color: '#177AD5', text: '54%'},
{value: 40, color: '#79D2DE', text: '30%'},
{value: 20, color: '#ED6665', text: '26%'},
];
const pieData2 = [
{value: 70, color: '#177AD5'},
{value: 30, color: 'lightgray'},
];
return (
{/* */}
{
return 70%;
}}
/>
{/* */}
{/* */}
{
// return(
//
// 100%
//
// )
// }}
/>
{/* */}
{/* */}
{/* */}
{/* */}
{/*
*/}
{/* */}
{/* {
return (
{item.value}
);
},
}}
/> */}
{/* {
return (
{'1234'}
);
},
}}
// data2={lineData2}
hideDataPoints
height={250}
// showVerticalLines
// spacing={44}
initialSpacing={0}
color1="skyblue"
color2="orange"
textColor1="green"
dataPointsHeight={6}
dataPointsWidth={6}
dataPointsHeight2={6}
dataPointsWidth2={6}
dataPointsColor1="blue"
dataPointsColor2="red"
textShiftY={-2}
textShiftX={-5}
textFontSize={13}
hideRules
spacing={10}
areaChart
/> */}
{/* */}
{/* */}
{/* */}
{/* {
dtt[1].value += 20;
setDtt([...dtt]);
}}>
Press me
*/}
{/*
Quarterly Sales
{
return (
90
Total
);
}}
/>
{renderLegend('Jan', 'rgb(84,219,234)')}
{renderLegend('Feb', 'lightgreen')}
{renderLegend('Mar', 'orange')}
*/}
{/* 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
*/}
{/* {true ? (
{
return 30;
},
},
{value: 250, label: 'Feb'},
{value: 200, label: 'Mar'},
{
value: 150,
label: 'Apr',
showVerticalLine: true,
verticalLineColor: 'black',
},
{value: 200, label: 'May'},
{value: 250, label: 'Jun'},
{value: 270, label: 'Jul'},
]}
// horizontal
// showReferenceLine1
// referenceLine1Position={120}
// referenceLine1Config={{
// type: 'solid',
// color: 'rgba(200,0,0,0.6)',
// thickness: 1,
// }}
// showReferenceLine2
// referenceLine2Position={240}
// referenceLine2Config={{
// type: 'solid',
// color: 'rgba(0,0,0,0.6)',
// thickness: 1,
// }}
// showReferenceLine3
// referenceLine3Position={330}
// referenceLine3Config={{
// type: 'solid',
// color: 'rgba(0,0,200,0.6)',
// thickness: 1,
// }}
// showYAxisIndices
isAnimated
showGradient
// cappedBars
yAxisColor={'rgb(78, 0, 142)'}
xAxisColor={'rgb(78, 0, 142)'}
xAxisThickness={3}
yAxisThickness={3}
yAxisTextStyle={{color: 'rgb(78, 0, 142)'}}
capColor={'rgb(78, 0, 142)'}
capThickness={4}
// barWidth={35}
gradientColor={'rgba(200, 100, 244,0.2)'}
frontColor={'rgba(78, 0, 142,1)'}
// rulesType="dashed"
// rulesColor={'rgba(0,200,0,0.5)'}
// rulesThickness={1}
// dashWidth={12}
// dashGap={2}
/>
) : (
{
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;