2021-08-16 13:41:23 +05:30
|
|
|
import React, {useState} from 'react';
|
|
|
|
import {TouchableOpacity} from 'react-native';
|
|
|
|
import {Alert} from 'react-native';
|
2021-08-12 20:02:44 +05:30
|
|
|
import {View, Text, StyleSheet} from 'react-native';
|
2021-12-02 17:21:19 +05:30
|
|
|
import {BarChart, LineChart} from './src';
|
2021-08-02 00:50:13 +05:30
|
|
|
|
|
|
|
const App = () => {
|
2021-08-16 13:41:23 +05:30
|
|
|
const [toggle, setToggle] = useState(true);
|
2021-12-04 00:01:42 +05:30
|
|
|
const dPoint = () => {
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
backgroundColor: 'white',
|
|
|
|
borderWidth: 4,
|
|
|
|
borderRadius: 10,
|
|
|
|
borderColor: '#07BAD1',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
const lcomp = val => {
|
|
|
|
return (
|
|
|
|
<View style={{width: 70, marginLeft: 7}}>
|
|
|
|
<Text style={{color: 'white', fontWeight: 'bold'}}>{val}</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
const latestData = [
|
|
|
|
{
|
|
|
|
value: 100,
|
|
|
|
labelComponent: () => lcomp('22 Nov'),
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 140,
|
|
|
|
hideDataPoint: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 250,
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 290,
|
|
|
|
hideDataPoint: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 410,
|
|
|
|
labelComponent: () => lcomp('24 Nov'),
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
showStrip: true,
|
|
|
|
stripHeight: 190,
|
|
|
|
stripColor: 'black',
|
|
|
|
dataPointLabelComponent: () => {
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'black',
|
|
|
|
paddingHorizontal: 8,
|
|
|
|
paddingVertical: 5,
|
|
|
|
borderRadius: 4,
|
|
|
|
}}>
|
|
|
|
<Text style={{color: 'white'}}>410</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
dataPointLabelShiftY: -70,
|
|
|
|
dataPointLabelShiftX: -14,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 440,
|
|
|
|
hideDataPoint: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 300,
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 280,
|
|
|
|
hideDataPoint: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 180,
|
|
|
|
labelComponent: () => lcomp('26 Nov'),
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 150,
|
|
|
|
hideDataPoint: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 150,
|
|
|
|
customDataPoint: dPoint,
|
|
|
|
},
|
|
|
|
];
|
2021-08-16 13:41:23 +05:30
|
|
|
|
2021-12-04 00:01:42 +05:30
|
|
|
const customLabel = val => {
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'black',
|
|
|
|
// padding: 16,
|
|
|
|
borderRadius: 8,
|
|
|
|
width: 30,
|
|
|
|
paddingVertical: 4,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}>
|
|
|
|
<Text style={{color: 'white'}}>{val}</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2021-12-02 17:21:19 +05:30
|
|
|
const [data, setData] = useState([
|
2021-11-26 23:34:22 +05:30
|
|
|
{value: 15, label: 'Jan'},
|
2021-08-12 20:02:44 +05:30
|
|
|
{
|
|
|
|
value: 40,
|
|
|
|
label: 'Feb',
|
|
|
|
verticalLineColor: 'red',
|
2021-08-16 13:41:23 +05:30
|
|
|
// showVerticalLine: true,
|
2021-08-12 20:02:44 +05:30
|
|
|
verticalLineThickness: StyleSheet.hairlineWidth,
|
2021-12-04 00:01:42 +05:30
|
|
|
dataPointLabelComponent: () => customLabel(40),
|
2021-08-12 20:02:44 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 10,
|
|
|
|
label: 'Mar',
|
2021-12-04 00:01:42 +05:30
|
|
|
dataPointLabelComponent: () => customLabel(10),
|
2021-08-12 20:02:44 +05:30
|
|
|
},
|
2021-08-16 13:41:23 +05:30
|
|
|
{
|
|
|
|
value: 30,
|
|
|
|
label: 'Apr',
|
2021-12-04 00:01:42 +05:30
|
|
|
dataPointLabelComponent: () => customLabel(30),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 20,
|
|
|
|
label: 'May',
|
|
|
|
dataPointLabelComponent: () => customLabel(20),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 40,
|
|
|
|
label: 'Jun',
|
|
|
|
focusedDataPointLabelComponent: () => customLabel(40),
|
2021-08-16 13:41:23 +05:30
|
|
|
},
|
|
|
|
{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'},
|
2021-12-02 17:21:19 +05:30
|
|
|
]);
|
2021-08-02 16:41:56 +05:30
|
|
|
|
2021-07-30 18:38:12 +05:30
|
|
|
return (
|
2021-08-12 20:02:44 +05:30
|
|
|
<View
|
|
|
|
style={{
|
2021-11-26 23:34:22 +05:30
|
|
|
marginTop: 100,
|
2021-08-12 20:02:44 +05:30
|
|
|
paddingVertical: 50,
|
2021-12-04 00:01:42 +05:30
|
|
|
backgroundColor: '#414141',
|
2021-08-12 20:02:44 +05:30
|
|
|
}}>
|
2021-12-04 00:01:42 +05:30
|
|
|
<LineChart
|
|
|
|
thickness={6}
|
|
|
|
color="#07BAD1"
|
|
|
|
maxValue={600}
|
|
|
|
noOfSections={3}
|
|
|
|
areaChart
|
|
|
|
yAxisTextStyle={{color: 'lightgray'}}
|
|
|
|
data={latestData}
|
|
|
|
curved
|
|
|
|
startFillColor={'rgb(84,219,234)'}
|
|
|
|
endFillColor={'rgb(84,219,234)'}
|
|
|
|
startOpacity={0.4}
|
|
|
|
endOpacity={0.4}
|
|
|
|
spacing={38}
|
|
|
|
backgroundColor="#414141"
|
|
|
|
rulesColor="gray"
|
|
|
|
rulesType="solid"
|
|
|
|
initialSpacing={10}
|
|
|
|
yAxisColor="lightgray"
|
|
|
|
xAxisColor="lightgray"
|
|
|
|
dataPointsHeight={20}
|
|
|
|
dataPointsWidth={20}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{/* {!toggle ? (
|
2021-08-16 13:41:23 +05:30
|
|
|
<BarChart
|
2021-11-26 23:34:22 +05:30
|
|
|
isThreeD
|
|
|
|
key={'xyz'}
|
|
|
|
height={300}
|
|
|
|
maxValue={360}
|
|
|
|
showLine
|
2021-12-02 18:55:03 +05:30
|
|
|
initialSpacing={30}
|
2021-11-26 23:34:22 +05:30
|
|
|
// showVerticalLines
|
|
|
|
lineConfig={{
|
|
|
|
// isAnimated: true,
|
|
|
|
delay: 800,
|
|
|
|
color: 'green',
|
|
|
|
// hideDataPoints: true,
|
|
|
|
// showDataPoint: false,
|
|
|
|
// dataPointsRadius: 5,
|
|
|
|
dataPointsColor: 'purple',
|
|
|
|
dataPointsRadius: 4,
|
|
|
|
thickness: 2,
|
|
|
|
shiftY: 25,
|
|
|
|
curved: true,
|
|
|
|
}}
|
|
|
|
barWidth={32}
|
2021-11-23 21:17:50 +05:30
|
|
|
// width={190}
|
2021-11-26 23:34:22 +05:30
|
|
|
data={[
|
|
|
|
{
|
|
|
|
value: 270,
|
|
|
|
label: 'Jan',
|
|
|
|
},
|
|
|
|
{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'},
|
|
|
|
]}
|
2021-08-16 13:41:23 +05:30
|
|
|
// horizontal
|
2021-11-26 23:34:22 +05:30
|
|
|
// 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,
|
|
|
|
// }}
|
2021-11-23 21:17:50 +05:30
|
|
|
// showYAxisIndices
|
2021-08-16 13:41:23 +05:30
|
|
|
isAnimated
|
|
|
|
showGradient
|
2021-11-26 23:34:22 +05:30
|
|
|
// cappedBars
|
2021-08-16 13:41:23 +05:30
|
|
|
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}
|
2021-11-26 23:34:22 +05:30
|
|
|
// barWidth={35}
|
|
|
|
frontColor={'rgba(200, 100, 244,0.2)'}
|
|
|
|
gradientColor={'rgba(78, 0, 142,1)'}
|
|
|
|
// rulesType="dashed"
|
|
|
|
// rulesColor={'rgba(0,200,0,0.5)'}
|
|
|
|
// rulesThickness={1}
|
|
|
|
// dashWidth={12}
|
|
|
|
// dashGap={2}
|
2021-08-16 13:41:23 +05:30
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<LineChart
|
2021-11-23 21:17:50 +05:30
|
|
|
// width={150}
|
2021-12-02 17:21:19 +05:30
|
|
|
// hideDataPoints1
|
|
|
|
// spacing={30}
|
2021-08-16 13:41:23 +05:30
|
|
|
data={data}
|
2021-12-04 00:01:42 +05:30
|
|
|
dataPointLabelWidth={30}
|
|
|
|
dataPointLabelShiftY={-30}
|
2021-12-02 17:21:19 +05:30
|
|
|
// data2={lineData1}
|
|
|
|
areaChart
|
2021-12-02 18:55:03 +05:30
|
|
|
initialSpacing={20}
|
2021-12-04 00:01:42 +05:30
|
|
|
customDataPoint={() => {
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
height: 10,
|
|
|
|
width: 10,
|
|
|
|
backgroundColor: 'red',
|
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: 'blue',
|
|
|
|
borderRadius: 5,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
2021-12-02 19:26:44 +05:30
|
|
|
// focusedCustomDataPoint={() => {
|
|
|
|
// return (
|
|
|
|
// <View
|
|
|
|
// style={{
|
|
|
|
// height: 14,
|
|
|
|
// width: 14,
|
|
|
|
// backgroundColor: 'green',
|
|
|
|
// borderWidth: 2,
|
|
|
|
// borderColor: 'yellow',
|
|
|
|
// borderRadius: 7,
|
|
|
|
// }}
|
|
|
|
// />
|
|
|
|
// );
|
|
|
|
// }}
|
|
|
|
// onPress={(item, index) => {
|
|
|
|
// console.log('index-->', index);
|
|
|
|
// setData(data => {
|
|
|
|
// item.focusedCustomDataPoint = () => {
|
|
|
|
// return (
|
|
|
|
// <View
|
|
|
|
// style={{
|
|
|
|
// height: 14,
|
|
|
|
// width: 14,
|
|
|
|
// backgroundColor: 'green',
|
|
|
|
// borderWidth: 2,
|
|
|
|
// borderColor: 'yellow',
|
|
|
|
// borderRadius: 7,
|
|
|
|
// }}
|
|
|
|
// />
|
|
|
|
// );
|
|
|
|
// };
|
|
|
|
// data[index] = item;
|
|
|
|
// console.log('data------.....', data);
|
|
|
|
// return data;
|
|
|
|
// });
|
|
|
|
// }}
|
2021-12-02 17:21:19 +05:30
|
|
|
// disableScroll
|
|
|
|
pressEnabled
|
|
|
|
// showDataPointOnPress
|
|
|
|
showStripOnPress
|
2021-12-04 00:01:42 +05:30
|
|
|
// showTextOnPress
|
|
|
|
// textShiftY={-10}
|
|
|
|
// textShiftX={-5}
|
|
|
|
// textFontSize={18}
|
|
|
|
// textColor={'green'}
|
|
|
|
// stripWidth={1}
|
2021-12-02 17:21:19 +05:30
|
|
|
// stripHeight={200}
|
2021-12-02 18:55:03 +05:30
|
|
|
// stripHeight={200}
|
2021-12-04 00:01:42 +05:30
|
|
|
// stripOpacity={1}
|
|
|
|
// curved
|
|
|
|
// isAnimated
|
|
|
|
// animationDuration={2000}
|
2021-12-02 17:21:19 +05:30
|
|
|
// animationDuration={2000}
|
|
|
|
// dataPointsShape="rectangular"
|
|
|
|
// showGradient
|
2021-08-16 13:41:23 +05:30
|
|
|
color={'rgb(78, 0, 142)'}
|
|
|
|
yAxisColor={'rgb(78, 0, 142)'}
|
|
|
|
xAxisColor={'rgb(78, 0, 142)'}
|
2021-12-02 18:55:03 +05:30
|
|
|
// dataPointsColor={'yellow'}
|
2021-12-04 00:01:42 +05:30
|
|
|
dataPointsWidth={20}
|
|
|
|
dataPointsHeight={20}
|
2021-08-16 13:41:23 +05:30
|
|
|
xAxisThickness={3}
|
|
|
|
yAxisThickness={3}
|
2021-12-04 00:01:42 +05:30
|
|
|
// dataPointsRadius={4}
|
|
|
|
// focusedDataPointRadius={10}
|
2021-08-16 13:41:23 +05:30
|
|
|
yAxisTextStyle={{color: 'rgb(78, 0, 142)'}}
|
|
|
|
startFillColor={'rgb(200, 100, 244)'}
|
|
|
|
startOpacity={0.9}
|
|
|
|
endFillColor={'rgb(255, 255, 255)'}
|
|
|
|
endOpacity={0.2}
|
|
|
|
/>
|
2021-12-04 00:01:42 +05:30
|
|
|
)} */}
|
2021-08-16 13:41:23 +05:30
|
|
|
|
2021-12-04 00:01:42 +05:30
|
|
|
{/* <TouchableOpacity
|
2021-08-16 13:41:23 +05:30
|
|
|
onPress={() => setToggle(!toggle)}
|
|
|
|
style={{marginTop: 100, alignSelf: 'center'}}>
|
|
|
|
<Text>Line Chart</Text>
|
2021-12-04 00:01:42 +05:30
|
|
|
</TouchableOpacity> */}
|
2021-07-30 18:38:12 +05:30
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|