@dhiraj0720/report1chart 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +20 -0
  2. package/src/index.js +43 -0
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@dhiraj0720/report1chart",
3
+ "version": "1.0.0",
4
+ "main": "src/index.js",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "MIT",
14
+ "description": "",
15
+ "dependencies": {
16
+ "react": "^19.2.3",
17
+ "react-native": "^0.80.2"
18
+ }
19
+ }
20
+
package/src/index.js ADDED
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { View, Text, StyleSheet } from 'react-native';
3
+
4
+ const BarChart = ({ data = [], height = 200 }) => {
5
+ const maxValue = Math.max(...data.map(d => d.value), 1);
6
+
7
+ return (
8
+ <View style={[styles.container, { height }]}>
9
+ {data.map((item, index) => {
10
+ const barHeight = (item.value / maxValue) * height;
11
+
12
+ return (
13
+ <View key={index} style={styles.barWrapper}>
14
+ <View style={[styles.bar, { height: barHeight }]} />
15
+ <Text style={styles.label}>{item.name}</Text>
16
+ </View>
17
+ );
18
+ })}
19
+ </View>
20
+ );
21
+ };
22
+
23
+ export default BarChart; // ✅ DEFAULT EXPORT
24
+
25
+ const styles = StyleSheet.create({
26
+ container: {
27
+ flexDirection: 'row',
28
+ alignItems: 'flex-end',
29
+ },
30
+ barWrapper: {
31
+ flex: 1,
32
+ alignItems: 'center',
33
+ },
34
+ bar: {
35
+ width: 22,
36
+ backgroundColor: '#4CAF50',
37
+ borderRadius: 6,
38
+ },
39
+ label: {
40
+ marginTop: 6,
41
+ fontSize: 12,
42
+ },
43
+ });