@dhiraj0720/report1chart 2.8.0 → 2.8.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhiraj0720/report1chart",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "main": "src/index.jsx",
5
5
  "scripts": {
6
6
  "test": "echo 'No tests'"
@@ -6,88 +6,66 @@ import { formatNumber } from '../utils/formatNumber';
6
6
  const SvgBarLineChartCompact = ({ data }) => {
7
7
  if (!data?.series || !data.labels?.length) return null;
8
8
 
9
- const height = 260;
9
+ const height = 280;
10
10
  const paddingLeft = 70;
11
11
  const paddingRight = 30;
12
- const paddingTop = 20;
13
- const paddingBottom = 60;
12
+ const paddingTop = 30;
13
+ const paddingBottom = 70;
14
14
 
15
15
  const chartHeight = height - paddingTop - paddingBottom;
16
- const graphWidth = Math.max(500, data.labels.length * 100); // Wider spacing like image
16
+ const graphWidth = Math.max(500, data.labels.length * 110);
17
17
 
18
- // Max value slightly above the highest in image
19
18
  const MAX = 1279958;
20
- const barWidth = 20;
21
- const barGap = 6; // Gap between 2024 and 2025 bar
22
- const groupGap = 30; // Gap between months (matches image)
19
+ const barWidth = 22;
20
+ const barGap = 8;
21
+ const groupGap = 35;
23
22
 
24
23
  const y = (v) => paddingTop + ((MAX - v) / MAX) * chartHeight;
25
-
26
- // Center X for each month group
27
- const getGroupCenterX = (i) => paddingLeft + i * (barWidth * 2 + barGap + groupGap) + (barWidth + barGap / 2);
24
+ const getCenterX = (i) => paddingLeft + i * (barWidth * 2 + barGap + groupGap) + (barWidth + barGap / 2);
28
25
 
29
26
  return (
30
27
  <View style={styles.container}>
31
- <Text style={styles.title}>{data.title || 'AY BAZINDA KAR KARŞILAŞTIRMALARI'}</Text>
28
+ <Text style={styles.title}>AY BAZINDA KAR KARŞILAŞTIRMALARI</Text>
32
29
 
33
30
  <View style={{ flexDirection: 'row' }}>
34
- {/* Y Axis Labels */}
35
31
  <Svg width={paddingLeft} height={height}>
36
- {[1279958, 1000000, 500000, 0].map((v, i) => (
32
+ {[1000000, 500000, 0].map((v) => (
37
33
  <SvgText
38
- key={i}
34
+ key={v}
39
35
  x={paddingLeft - 10}
40
36
  y={y(v) + 5}
41
37
  fontSize="11"
42
38
  textAnchor="end"
43
39
  fill="#444"
44
40
  >
45
- {v >= 1000000 ? `$${ (v / 1000000).toFixed(1) }M` : formatNumber(v)}
41
+ {(v / 1000000).toFixed(1)}M
46
42
  </SvgText>
47
43
  ))}
48
44
  </Svg>
49
45
 
50
- {/* Main Chart - Scrollable */}
51
46
  <ScrollView horizontal showsHorizontalScrollIndicator={false}>
52
47
  <Svg width={graphWidth} height={height}>
53
- {/* Horizontal Grid Lines */}
54
- {[1279958, 1000000, 500000, 0].map((v) => (
55
- <Line
56
- key={v}
57
- x1={0}
58
- x2={graphWidth}
59
- y1={y(v)}
60
- y2={y(v)}
61
- stroke="#eee"
62
- strokeDasharray="5,5"
63
- />
48
+ {[1000000, 500000, 0].map((v) => (
49
+ <Line key={v} x1={0} x2={graphWidth} y1={y(v)} y2={y(v)} stroke="#eee" strokeDasharray="5,5" />
64
50
  ))}
65
51
 
66
- {/* Bars & Budget Line */}
67
52
  {data.labels.map((label, i) => {
68
- const centerX = getGroupCenterX(i);
69
-
53
+ const centerX = getCenterX(i);
70
54
  const val2024 = data.series[0]?.data[i] || 0;
71
55
  const val2025 = data.series[1]?.data[i] || 0;
72
56
  const budget = data.series[2]?.data[i] || 0;
73
57
 
74
- const barHeight2024 = chartHeight - (y(val2024) - paddingTop);
75
- const barHeight2025 = chartHeight - (y(val2025) - paddingTop);
58
+ const h2024 = chartHeight - (y(val2024) - paddingTop);
59
+ const h2025 = chartHeight - (y(val2025) - paddingTop);
76
60
 
77
61
  return (
78
62
  <React.Fragment key={i}>
79
- {/* 2024 Bar - Orange */}
80
- <Rect
81
- x={centerX - barWidth - barGap / 2}
82
- y={y(val2024)}
83
- width={barWidth}
84
- height={barHeight2024}
85
- fill="#E07A3F"
86
- />
87
- {val2024 > MAX * 0.08 && (
63
+ {/* 2024 Bar */}
64
+ <Rect x={centerX - barWidth - barGap / 2} y={y(val2024)} width={barWidth} height={h2024} fill="#E07A3F" />
65
+ {val2024 > MAX * 0.1 && (
88
66
  <SvgText
89
67
  x={centerX - barWidth - barGap / 2 + barWidth / 2}
90
- y={y(val2024) + barHeight2024 / 2 + 4}
68
+ y={y(val2024) + h2024 / 2 + 5}
91
69
  fontSize="10"
92
70
  textAnchor="middle"
93
71
  fill="white"
@@ -97,18 +75,12 @@ const SvgBarLineChartCompact = ({ data }) => {
97
75
  </SvgText>
98
76
  )}
99
77
 
100
- {/* 2025 Bar - Blue */}
101
- <Rect
102
- x={centerX + barGap / 2}
103
- y={y(val2025)}
104
- width={barWidth}
105
- height={barHeight2025}
106
- fill="#4E79A7"
107
- />
108
- {val2025 > MAX * 0.08 && (
78
+ {/* 2025 Bar */}
79
+ <Rect x={centerX + barGap / 2} y={y(val2025)} width={barWidth} height={h2025} fill="#4E79A7" />
80
+ {val2025 > MAX * 0.1 && (
109
81
  <SvgText
110
82
  x={centerX + barGap / 2 + barWidth / 2}
111
- y={y(val2025) + barHeight2025 / 2 + 4}
83
+ y={y(val2025) + h2025 / 2 + 5}
112
84
  fontSize="10"
113
85
  textAnchor="middle"
114
86
  fill="white"
@@ -118,10 +90,10 @@ const SvgBarLineChartCompact = ({ data }) => {
118
90
  </SvgText>
119
91
  )}
120
92
 
121
- {/* Budget Dotted Line */}
93
+ {/* Budget Line & Dot */}
122
94
  {i > 0 && (
123
95
  <Line
124
- x1={getGroupCenterX(i - 1)}
96
+ x1={getCenterX(i - 1)}
125
97
  y1={y(data.series[2].data[i - 1])}
126
98
  x2={centerX}
127
99
  y2={y(budget)}
@@ -130,37 +102,19 @@ const SvgBarLineChartCompact = ({ data }) => {
130
102
  strokeDasharray="6,4"
131
103
  />
132
104
  )}
133
-
134
- {/* Budget Dot */}
135
- <Circle
136
- cx={centerX}
137
- cy={y(budget)}
138
- r={5}
139
- fill="#8AB6E8"
140
- stroke="#fff"
141
- strokeWidth={2}
142
- />
143
-
144
- {/* Budget Value Above Dot */}
145
- <SvgText
146
- x={centerX}
147
- y={y(budget) - 10}
148
- fontSize="10"
149
- textAnchor="middle"
150
- fill="#333"
151
- fontWeight="700"
152
- >
105
+ <Circle cx={centerX} cy={y(budget)} r={6} fill="#8AB6E8" stroke="#fff" strokeWidth={2} />
106
+ <SvgText x={centerX} y={y(budget) - 12} fontSize="11" textAnchor="middle" fill="#333" fontWeight="700">
153
107
  {formatNumber(budget)}
154
108
  </SvgText>
155
109
 
156
- {/* X Axis Label - Rotated */}
110
+ {/* X Label */}
157
111
  <SvgText
158
112
  x={centerX}
159
- y={height - 25}
113
+ y={height - 30}
160
114
  fontSize="11"
161
115
  textAnchor="middle"
162
116
  fill="#555"
163
- transform={`rotate(-45 ${centerX} ${height - 25})`}
117
+ transform={`rotate(-45 ${centerX} ${height - 30})`}
164
118
  >
165
119
  {label}
166
120
  </SvgText>
@@ -171,7 +125,6 @@ const SvgBarLineChartCompact = ({ data }) => {
171
125
  </ScrollView>
172
126
  </View>
173
127
 
174
- {/* Legend */}
175
128
  <View style={styles.legend}>
176
129
  <Text style={{ color: '#E07A3F', marginRight: 20 }}>● 2024 Kar USD</Text>
177
130
  <Text style={{ color: '#4E79A7', marginRight: 20 }}>● 2025 Kar USD</Text>
@@ -181,28 +134,21 @@ const SvgBarLineChartCompact = ({ data }) => {
181
134
  );
182
135
  };
183
136
 
184
- export default SvgBarLineChartCompact;
185
-
186
137
  const styles = StyleSheet.create({
187
- container: {
188
- marginVertical: 12,
189
- backgroundColor: '#fff',
190
- borderRadius: 10,
191
- padding: 10,
192
- borderWidth: 1,
193
- borderColor: '#ddd',
138
+ container: { padding: 10 },
139
+ title: {
140
+ fontWeight: '700',
141
+ fontSize: 14,
142
+ textAlign: 'center',
143
+ marginBottom: 10,
144
+ color: '#111'
194
145
  },
195
- title: {
196
- fontWeight: '700',
197
- fontSize: 14,
198
- textAlign: 'center',
199
- marginBottom: 8,
200
- color: '#111',
146
+ legend: {
147
+ flexDirection: 'row',
148
+ justifyContent: 'center',
149
+ marginTop: 12,
150
+ flexWrap: 'wrap'
201
151
  },
202
- legend: {
203
- flexDirection: 'row',
204
- justifyContent: 'center',
205
- marginTop: 10,
206
- flexWrap: 'wrap',
207
- },
208
- });
152
+ });
153
+
154
+ export default SvgBarLineChartCompact;
@@ -6,37 +6,37 @@ import { formatNumber } from '../utils/formatNumber';
6
6
  const SvgLineChartCompact = ({ data }) => {
7
7
  if (!data?.series || !data.labels?.length) return null;
8
8
 
9
- const height = 200;
10
- const paddingLeft = 60;
11
- const paddingRight = 20;
12
- const paddingTop = 20;
13
- const paddingBottom = 40;
9
+ const height = 260;
10
+ const paddingLeft = 70;
11
+ const paddingRight = 30;
12
+ const paddingTop = 30;
13
+ const paddingBottom = 60;
14
14
 
15
15
  const chartHeight = height - paddingTop - paddingBottom;
16
- const graphWidth = Math.max(400, data.labels.length * 80);
16
+ const graphWidth = Math.max(500, data.labels.length * 100);
17
17
 
18
- // FIXED AXIS (as per image)
19
18
  const MIN = 5000;
20
19
  const MAX = 10000;
21
20
 
22
21
  const y = (v) => paddingTop + ((MAX - Math.max(MIN, Math.min(MAX, v))) / (MAX - MIN)) * chartHeight;
23
22
 
24
- // Fix for single point: use fixed spacing
25
23
  const totalPoints = data.labels.length;
26
- const xStep = totalPoints === 1 ? 0 : (graphWidth - paddingLeft - paddingRight) / (totalPoints - 1);
24
+ const xStep = totalPoints === 1
25
+ ? graphWidth / 2
26
+ : (graphWidth - paddingLeft - paddingRight) / (totalPoints - 1);
27
27
 
28
- const colors = ['#E07A3F', '#4E79A7'];// orange / blue
28
+ const colors = ['#E07A3F', '#4E79A7'];
29
29
 
30
30
  return (
31
31
  <View style={styles.container}>
32
- <Text style={styles.title}>{data.title}</Text>
32
+ <Text style={styles.title}>AY BAZINDA KAR KARŞILAŞTIRMALARI</Text>
33
33
 
34
34
  <View style={{ flexDirection: 'row' }}>
35
35
  <Svg width={paddingLeft} height={height}>
36
36
  {[10000, 5000].map((v) => (
37
37
  <SvgText
38
38
  key={v}
39
- x={paddingLeft - 8}
39
+ x={paddingLeft - 10}
40
40
  y={y(v) + 5}
41
41
  fontSize="11"
42
42
  textAnchor="end"
@@ -49,31 +49,29 @@ const SvgLineChartCompact = ({ data }) => {
49
49
 
50
50
  <ScrollView horizontal showsHorizontalScrollIndicator={false}>
51
51
  <Svg width={graphWidth} height={height}>
52
- {/* Grid */}
53
52
  {[10000, 5000].map((v) => (
54
53
  <Line key={v} x1={0} x2={graphWidth} y1={y(v)} y2={y(v)} stroke="#eee" strokeDasharray="5,5" />
55
54
  ))}
56
55
 
57
- {/* Series */}
58
56
  {data.series.map((series, si) =>
59
57
  series.data.map((val, i) => {
60
- const x = paddingLeft + i * (totalPoints === 1 ? graphWidth / 2 - paddingLeft : xStep);
58
+ const x = paddingLeft + i * xStep + (totalPoints === 1 ? graphWidth / 2 - paddingLeft - xStep / 2 : 0);
61
59
 
62
60
  return (
63
61
  <React.Fragment key={`${si}-${i}`}>
64
62
  {i > 0 && (
65
63
  <Line
66
- x1={paddingLeft + (i - 1) * (totalPoints === 1 ? graphWidth / 2 - paddingLeft : xStep)}
64
+ x1={paddingLeft + (i - 1) * xStep + (totalPoints === 1 ? graphWidth / 2 - paddingLeft - xStep / 2 : 0)}
67
65
  y1={y(series.data[i - 1])}
68
66
  x2={x}
69
67
  y2={y(val)}
70
68
  stroke={colors[si]}
71
- strokeWidth={2.5}
72
- strokeDasharray={si === 0 ? '6,4' : '0'}
69
+ strokeWidth={3}
70
+ strokeDasharray={si === 0 ? "6,4" : "0"}
73
71
  />
74
72
  )}
75
- <Circle cx={x} cy={y(val)} r={5} fill={colors[si]} />
76
- <SvgText x={x} y={y(val) - 10} fontSize="10" textAnchor="middle" fill="#333">
73
+ <Circle cx={x} cy={y(val)} r={6} fill={colors[si]} stroke="#fff" strokeWidth={2} />
74
+ <SvgText x={x} y={y(val) - 12} fontSize="11" textAnchor="middle" fill="#333" fontWeight="700">
77
75
  {formatNumber(val)}
78
76
  </SvgText>
79
77
  </React.Fragment>
@@ -81,18 +79,17 @@ const SvgLineChartCompact = ({ data }) => {
81
79
  })
82
80
  )}
83
81
 
84
- {/* X Labels */}
85
82
  {data.labels.map((label, i) => {
86
- const x = paddingLeft + i * (totalPoints === 1 ? graphWidth / 2 - paddingLeft : xStep);
83
+ const x = paddingLeft + i * xStep + (totalPoints === 1 ? graphWidth / 2 - paddingLeft - xStep / 2 : 0);
87
84
  return (
88
85
  <SvgText
89
86
  key={i}
90
87
  x={x}
91
- y={height - 15}
88
+ y={height - 25}
92
89
  fontSize="11"
93
90
  textAnchor="middle"
94
91
  fill="#555"
95
- transform={`rotate(-45 ${x} ${height - 15})`}
92
+ transform={`rotate(-45 ${x} ${height - 25})`}
96
93
  >
97
94
  {label}
98
95
  </SvgText>
@@ -103,27 +100,27 @@ const SvgLineChartCompact = ({ data }) => {
103
100
  </View>
104
101
 
105
102
  <View style={styles.legend}>
106
- {data.series.map((s, i) => (
107
- <Text key={i} style={{ color: colors[i], marginRight: 16 }}>
108
- ● {s.name}
109
- </Text>
110
- ))}
103
+ <Text style={{ color: '#E07A3F', marginRight: 20 }}>● 2024 Kar USD</Text>
104
+ <Text style={{ color: '#4E79A7' }}>● 2025 Kar USD</Text>
111
105
  </View>
112
106
  </View>
113
107
  );
114
108
  };
115
109
 
116
- export default SvgLineChartCompact;
117
-
118
110
  const styles = StyleSheet.create({
119
- container: { marginVertical: 6 },
120
- title: {
121
- fontWeight: '700',
122
- marginBottom: 4,
123
- fontSize: 13,
111
+ container: { padding: 10 },
112
+ title: {
113
+ fontWeight: '700',
114
+ fontSize: 14,
115
+ textAlign: 'center',
116
+ marginBottom: 10,
117
+ color: '#111'
124
118
  },
125
- legend: {
126
- flexDirection: 'row',
127
- marginTop: 4,
119
+ legend: {
120
+ flexDirection: 'row',
121
+ justifyContent: 'center',
122
+ marginTop: 12
128
123
  },
129
124
  });
125
+
126
+ export default SvgLineChartCompact;
@@ -106,33 +106,24 @@ const Report2AScreen = ({ api, token, onBack }) => {
106
106
  </View>
107
107
 
108
108
  <ScrollView style={styles.content}>
109
- {/* FULL SCREEN BUTTON */}
110
- {/* <TouchableOpacity onPress={() => setFullscreen(true)} style={styles.fullScreenBtn}>
109
+ {/* FULL SCREEN BUTTON - SIMPLE TEXT */}
110
+ <TouchableOpacity
111
+ onPress={() => setFullscreen(true)}
112
+ style={styles.fullScreenBtn}
113
+ >
111
114
  <Text style={styles.fullScreenText}>⤢ Full Screen</Text>
112
- </TouchableOpacity> */}
113
- <TouchableOpacity
114
- onPress={() => setFullscreen(true)}
115
- style={{
116
- alignSelf: 'flex-end',
117
- marginBottom: 8,
118
- padding: 6,
119
- }}
120
- >
121
- <Text style={{ fontWeight: '700' }}>⤢ Full Screen</Text>
122
- </TouchableOpacity>
115
+ </TouchableOpacity>
123
116
 
124
117
  {/* TABLE */}
125
118
  <FrozenTableReport2A rows={filteredRows} />
126
119
 
127
- {/* LINE CHART WITH TITLE */}
128
- <View style={styles.chartWrapper}>
129
- <Text style={styles.chartTitle}>AY BAZINDA KAR KARŞILAŞTIRMALARI</Text>
120
+ {/* LINE CHART */}
121
+ <View style={styles.chartContainer}>
130
122
  <SvgLineChartCompact data={filteredLine} />
131
123
  </View>
132
124
 
133
- {/* BAR CHART WITH TITLE - ONLY ONE CARD */}
134
- <View style={styles.chartWrapper}>
135
- <Text style={styles.chartTitle}>AY BAZINDA KAR KARŞILAŞTIRMALARI</Text>
125
+ {/* BAR CHART */}
126
+ <View style={styles.chartContainer}>
136
127
  <SvgBarLineChartCompact data={filteredBar} />
137
128
  </View>
138
129
  </ScrollView>
@@ -198,36 +189,22 @@ const styles = StyleSheet.create({
198
189
 
199
190
  fullScreenBtn: {
200
191
  alignSelf: 'flex-end',
201
- paddingHorizontal: 16,
202
- paddingVertical: 10,
203
- backgroundColor: '#f0f0f0',
204
- borderRadius: 8,
205
- marginVertical: 12,
206
192
  marginRight: 12,
193
+ marginVertical: 12,
194
+ paddingHorizontal: 12,
195
+ paddingVertical: 6,
207
196
  },
208
- fullScreenText: { fontSize: 16, color: '#000', fontWeight: '700' },
197
+ fullScreenText: { fontSize: 16, fontWeight: '700', color: '#000' },
209
198
 
210
- content: { flex: 1, paddingHorizontal: 12 },
199
+ content: { flex: 1, padding: 12 },
211
200
 
212
- chartWrapper: {
213
- backgroundColor: '#fff',
214
- borderRadius: 12,
215
- padding: 16,
216
- marginVertical: 12,
201
+ chartContainer: {
217
202
  borderWidth: 1,
218
203
  borderColor: '#ddd',
219
- shadowColor: '#000',
220
- shadowOffset: { width: 0, height: 2 },
221
- shadowOpacity: 0.08,
222
- shadowRadius: 6,
223
- elevation: 4,
224
- },
225
- chartTitle: {
226
- fontSize: 16,
227
- fontWeight: '700',
228
- color: '#000',
229
- textAlign: 'center',
230
- marginBottom: 16,
204
+ borderRadius: 10,
205
+ overflow: 'hidden',
206
+ marginVertical: 12,
207
+ backgroundColor: '#fff',
231
208
  },
232
209
 
233
210
  fullModal: { flex: 1, backgroundColor: '#fff' },
@@ -260,11 +237,6 @@ const styles = StyleSheet.create({
260
237
  backgroundColor: '#fff',
261
238
  borderRadius: 12,
262
239
  overflow: 'hidden',
263
- shadowColor: '#000',
264
- shadowOffset: { width: 0, height: 4 },
265
- shadowOpacity: 0.15,
266
- shadowRadius: 10,
267
- elevation: 8,
268
240
  },
269
241
  landscapeFit: {
270
242
  transform: [{ scale: 1.45 }],