bidviz 1.0.0__tar.gz

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.
bidviz-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mohammad Amin Khara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
bidviz-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,425 @@
1
+ Metadata-Version: 2.4
2
+ Name: bidviz
3
+ Version: 1.0.0
4
+ Summary: A powerful, configurable backend visualization data transformation library
5
+ Author-email: Mohammad Amin Khara <kharama8709@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aghabidareh/bidviz
8
+ Project-URL: Repository, https://github.com/aghabidareh/bidviz
9
+ Project-URL: Issues, https://github.com/aghabidareh/bidviz/issues
10
+ Keywords: visualization,charts,data-transformation,pandas,analytics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Scientific/Engineering :: Visualization
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pandas>=2.0.0
25
+ Requires-Dist: numpy>=1.24.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
29
+ Requires-Dist: black>=23.0.0; extra == "dev"
30
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
32
+ Requires-Dist: isort>=5.12.0; extra == "dev"
33
+ Provides-Extra: docs
34
+ Requires-Dist: sphinx>=7.0.0; extra == "docs"
35
+ Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
36
+ Dynamic: license-file
37
+
38
+ # BidViz
39
+
40
+ [![PyPI version](https://badge.fury.io/py/bidviz.svg)](https://badge.fury.io/py/bidviz)
41
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
+ [![Tests](https://github.com/aghabidareh/bidviz/workflows/Tests/badge.svg)](https://github.com/aghabidareh/bidviz/actions)
44
+ [![Coverage](https://codecov.io/gh/aghabidareh/bidviz/branch/main/graph/badge.svg)](https://codecov.io/gh/aghabidareh/bidviz)
45
+
46
+ A powerful, configurable backend visualization data transformation library designed to bridge the gap between raw data and frontend charting libraries. Built with pandas at its core, BidViz provides a comprehensive suite of tools for data cleaning, transformation, and formatting optimized for analytics dashboards and data visualization applications.
47
+
48
+ ## Features
49
+
50
+ - **12+ Chart Type Transformations**: Support for KPI cards, bar charts, line charts, pie charts, heatmaps, funnels, tables, and more
51
+ - **Automatic Data Cleaning**: NaN handling, type conversion, and null sanitization
52
+ - **Human-Readable Formatting**: Intelligent label generation from column names
53
+ - **Built-in Pagination**: Server-side pagination for data tables
54
+ - **Frontend-Ready Output**: JSON-serializable structures optimized for charting libraries
55
+ - **Statistical Analysis**: Correlation matrices with heatmap data generation
56
+ - **Highly Configurable**: Custom column mappings, formatting rules, and transformation behaviors
57
+ - **Framework Agnostic**: Works with any frontend (React, Vue, Angular) and any charting library (Chart.js, D3, Plotly, Recharts)
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install bidviz
63
+ ```
64
+
65
+ For development:
66
+
67
+ ```bash
68
+ pip install bidviz[dev]
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ```python
74
+ import pandas as pd
75
+ from bidviz import ChartTransformer
76
+
77
+ # Initialize the transformer
78
+ transformer = ChartTransformer()
79
+
80
+ # Sample data
81
+ df = pd.DataFrame({
82
+ 'vendor': ['Vendor A', 'Vendor B', 'Vendor C'],
83
+ 'revenue': [125000, 98000, 112000]
84
+ })
85
+
86
+ # Transform to bar chart
87
+ result = transformer.transform_to_bar_chart(
88
+ df=df,
89
+ x_column='vendor',
90
+ y_column='revenue'
91
+ )
92
+
93
+ print(result)
94
+ # {
95
+ # "chart_type": "bar_chart",
96
+ # "data": [
97
+ # {"x": "Vendor A", "y": 125000, "label": "Vendor A"},
98
+ # {"x": "Vendor B", "y": 98000, "label": "Vendor B"},
99
+ # {"x": "Vendor C", "y": 112000, "label": "Vendor C"}
100
+ # ],
101
+ # "x_label": "Vendor",
102
+ # "y_label": "Revenue"
103
+ # }
104
+ ```
105
+
106
+ ## Supported Chart Types
107
+
108
+ | Chart Type | Method | Use Case |
109
+ |------------|--------|----------|
110
+ | **KPI Cards** | `transform_to_kpi_cards()` | Dashboard metrics, summary numbers |
111
+ | **Bar Chart** | `transform_to_bar_chart()` | Categorical comparisons, rankings |
112
+ | **Line Chart** | `transform_to_line_chart()` | Time series, trends |
113
+ | **Multi-Line Chart** | `transform_to_multi_line_chart()` | Multiple time series comparisons |
114
+ | **Pie Chart** | `transform_to_pie_chart()` | Part-to-whole relationships |
115
+ | **Heatmap** | `transform_to_heatmap()` | Two-dimensional relationships |
116
+ | **Funnel Chart** | `transform_to_funnel_chart()` | Conversion pipelines |
117
+ | **Stacked Bar Chart** | `transform_to_stacked_bar_chart()` | Composed categorical comparisons |
118
+ | **Data Table** | `transform_to_data_table()` | Tabular data with pagination |
119
+ | **Correlation Heatmap** | `transform_to_correlation_heatmap()` | Statistical relationships |
120
+
121
+ ## Usage Examples
122
+
123
+ ### KPI Cards
124
+
125
+ ```python
126
+ # Single-row DataFrame with metrics
127
+ df = pd.DataFrame({
128
+ 'total_orders': [150],
129
+ 'revenue': [45000.50],
130
+ 'satisfaction_rate': [94.2]
131
+ })
132
+
133
+ result = transformer.transform_to_kpi_cards(df)
134
+ # Returns list of KPI cards with labels, values, and keys
135
+ ```
136
+
137
+ ### Line Chart with Time Series
138
+
139
+ ```python
140
+ df = pd.DataFrame({
141
+ 'date': pd.date_range('2024-01-01', periods=30),
142
+ 'orders': [152, 168, 145, ...] # 30 values
143
+ })
144
+
145
+ result = transformer.transform_to_line_chart(
146
+ df=df,
147
+ x_column='date',
148
+ y_column='orders',
149
+ series_name='Daily Orders'
150
+ )
151
+ ```
152
+
153
+ ### Multi-Line Chart
154
+
155
+ ```python
156
+ df = pd.DataFrame({
157
+ 'date': pd.date_range('2024-01-01', periods=30),
158
+ 'vendor_a': [...],
159
+ 'vendor_b': [...],
160
+ 'vendor_c': [...]
161
+ })
162
+
163
+ result = transformer.transform_to_multi_line_chart(
164
+ df=df,
165
+ x_column='date',
166
+ y_columns=['vendor_a', 'vendor_b', 'vendor_c'],
167
+ series_names=['Vendor A', 'Vendor B', 'Vendor C']
168
+ )
169
+ ```
170
+
171
+ ### Data Table with Pagination
172
+
173
+ ```python
174
+ df = pd.DataFrame({
175
+ 'order_id': range(1, 1001),
176
+ 'customer': [f'Customer {i}' for i in range(1, 1001)],
177
+ 'amount': [...] # 1000 values
178
+ })
179
+
180
+ result = transformer.transform_to_data_table(
181
+ df=df,
182
+ page=1,
183
+ page_size=50
184
+ )
185
+ # Returns paginated data with metadata
186
+ ```
187
+
188
+ ### Correlation Heatmap
189
+
190
+ ```python
191
+ df = pd.DataFrame({
192
+ 'revenue': [...],
193
+ 'orders': [...],
194
+ 'rating': [...],
195
+ 'shipping_days': [...]
196
+ })
197
+
198
+ result = transformer.transform_to_correlation_heatmap(df)
199
+ # Auto-detects numeric columns and generates correlation matrix
200
+ ```
201
+
202
+ ## Integration with Web Frameworks
203
+
204
+ ### FastAPI
205
+
206
+ ```python
207
+ from fastapi import FastAPI, Query
208
+ from bidviz import ChartTransformer
209
+ import pandas as pd
210
+
211
+ app = FastAPI()
212
+ transformer = ChartTransformer()
213
+
214
+ @app.get("/api/charts/revenue")
215
+ async def get_revenue_chart(chart_type: str = Query("bar")):
216
+ # Fetch data from database
217
+ df = get_revenue_data()
218
+
219
+ if chart_type == "bar":
220
+ return transformer.transform_to_bar_chart(
221
+ df, x_column='vendor', y_column='revenue'
222
+ )
223
+ elif chart_type == "line":
224
+ return transformer.transform_to_line_chart(
225
+ df, x_column='date', y_column='revenue'
226
+ )
227
+ ```
228
+
229
+ ### Flask
230
+
231
+ ```python
232
+ from flask import Flask, jsonify
233
+ from bidviz import ChartTransformer
234
+
235
+ app = Flask(__name__)
236
+ transformer = ChartTransformer()
237
+
238
+ @app.route('/api/charts/sales')
239
+ def sales_chart():
240
+ df = get_sales_data()
241
+ result = transformer.transform_to_pie_chart(
242
+ df, label_column='category', value_column='sales'
243
+ )
244
+ return jsonify(result)
245
+ ```
246
+
247
+ ## Frontend Integration
248
+
249
+ ### React with Recharts
250
+
251
+ ```javascript
252
+ import { BarChart, Bar, XAxis, YAxis } from 'recharts';
253
+
254
+ function RevenueChart() {
255
+ const [chartData, setChartData] = useState(null);
256
+
257
+ useEffect(() => {
258
+ fetch('/api/charts/revenue?chart_type=bar')
259
+ .then(res => res.json())
260
+ .then(data => setChartData(data));
261
+ }, []);
262
+
263
+ if (!chartData) return <div>Loading...</div>;
264
+
265
+ return (
266
+ <BarChart data={chartData.data}>
267
+ <XAxis dataKey="x" label={chartData.x_label} />
268
+ <YAxis label={chartData.y_label} />
269
+ <Bar dataKey="y" fill="#8884d8" />
270
+ </BarChart>
271
+ );
272
+ }
273
+ ```
274
+
275
+ ### Chart.js
276
+
277
+ ```javascript
278
+ const response = await fetch('/api/charts/revenue?chart_type=line');
279
+ const chartData = await response.json();
280
+
281
+ new Chart(ctx, {
282
+ type: 'line',
283
+ data: {
284
+ labels: chartData.data.map(d => d.x),
285
+ datasets: [{
286
+ label: chartData.series_name,
287
+ data: chartData.data.map(d => d.y)
288
+ }]
289
+ }
290
+ });
291
+ ```
292
+
293
+ ## Data Handling
294
+
295
+ ### NaN Handling
296
+
297
+ All transformations automatically handle pandas NaN values:
298
+ - **Numeric NaN** → `null` in JSON
299
+ - **String/Empty NaN** → `null` in JSON
300
+ - All computations work safely with NaN values
301
+
302
+ ### Type Conversion
303
+
304
+ | Input Type | Output Type | Notes |
305
+ |------------|-------------|-------|
306
+ | `int64` | `float` | Safe for JSON serialization |
307
+ | `float64` | `float` | Precision preserved |
308
+ | `datetime64` | `string` | ISO format |
309
+ | `object` | `string` | String representation |
310
+ | `boolean` | `boolean` | Preserved |
311
+
312
+ ### Label Formatting
313
+
314
+ Automatic snake_case to Title Case conversion:
315
+ - `total_gmv` → `"Total Gmv"`
316
+ - `customer_id` → `"Customer Id"`
317
+ - `avg_days_to_ship` → `"Avg Days To Ship"`
318
+
319
+ ## Error Handling
320
+
321
+ ```python
322
+ from bidviz.exceptions import TransformationError
323
+
324
+ try:
325
+ result = transformer.transform_to_bar_chart(df, 'category', 'value')
326
+ except TransformationError as e:
327
+ print(f"Error: {e.message}")
328
+ print(f"Chart Type: {e.chart_type}")
329
+ print(f"DataFrame Shape: {e.df_shape}")
330
+ print(f"Missing Columns: {e.missing_columns}")
331
+ ```
332
+
333
+ ## Development
334
+
335
+ ### Setup Development Environment
336
+
337
+ ```bash
338
+ # Clone the repository
339
+ git clone https://github.com/aghabidareh/bidviz.git
340
+ cd bidviz
341
+
342
+ # Create virtual environment
343
+ python -m venv venv
344
+ source venv/bin/activate # On Windows: venv\Scripts\activate
345
+
346
+ # Install development dependencies
347
+ pip install -e ".[dev]"
348
+ ```
349
+
350
+ ### Running Tests
351
+
352
+ ```bash
353
+ # Run all tests with coverage
354
+ pytest
355
+
356
+ # Run specific test file
357
+ pytest tests/test_transformer.py
358
+
359
+ # Run with verbose output
360
+ pytest -v
361
+
362
+ # Generate HTML coverage report
363
+ pytest --cov=bidviz --cov-report=html
364
+ ```
365
+
366
+ ### Code Quality
367
+
368
+ ```bash
369
+ # Format code with black
370
+ black bidviz tests
371
+
372
+ # Sort imports
373
+ isort bidviz tests
374
+
375
+ # Check code style
376
+ flake8 bidviz tests
377
+
378
+ # Type checking
379
+ mypy bidviz
380
+ ```
381
+
382
+ ## Contributing
383
+
384
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
385
+
386
+ 1. Fork the repository
387
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
388
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
389
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
390
+ 5. Open a Pull Request
391
+
392
+ Please make sure to update tests as appropriate and adhere to the existing code style.
393
+
394
+ ## License
395
+
396
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
397
+
398
+ ## Changelog
399
+
400
+ See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
401
+
402
+ ## Roadmap
403
+
404
+ - [ ] Advanced value formatting pipeline
405
+ - [ ] Data validation framework
406
+ - [ ] Aggregation pipeline
407
+ - [ ] Multi-chart dashboard builder
408
+ - [ ] Real-time streaming support
409
+ - [ ] Export & report generation (PDF, Excel)
410
+ - [ ] Caching layer
411
+ - [ ] Plugin system
412
+ - [ ] Multi-language support
413
+ - [ ] Performance profiling tools
414
+
415
+ ## Acknowledgments
416
+
417
+ - Built with [pandas](https://pandas.pydata.org/)
418
+ - Inspired by the need for seamless backend-to-frontend data transformation
419
+ - Thanks to all contributors and users of this library
420
+
421
+ ## Contact
422
+
423
+ Mohammad Amin Khara - kharama8709@gmail.com
424
+
425
+ Project Link: [https://github.com/aghabidareh/bidviz](https://github.com/aghabidareh/bidviz)