universal-adaptive-bars 0.0.5 → 0.1.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.
- package/README.md +23 -18
- package/dist/smart-bar-chart.js +2981 -2795
- package/dist/smart-bar-chart.umd.cjs +21 -10
- package/package.json +1 -1
- package/src/lib/SmartBarChart.tsx +155 -63
- package/src/lib/SmartBarChartNative.tsx +152 -53
- package/src/lib/__tests__/Navigation.test.tsx +3 -3
- package/src/lib/hooks/useChartData.ts +51 -3
- package/src/lib/types.ts +6 -1
package/README.md
CHANGED
|
@@ -3,28 +3,31 @@
|
|
|
3
3
|
A highly customizable, interactive, and drill-down capable Bar Chart library for **React** and **React Native**.
|
|
4
4
|
|
|
5
5
|

|
|
6
|
-

|
|
7
7
|
|
|
8
8
|
📖 **Read the Story**: [Universal Adaptive Bars: The Smart Cross-Platform Charting Library You’ve Been Waiting For](https://sammeddoshi.medium.com/universal-adaptive-bars-the-smart-cross-platform-charting-library-youve-been-waiting-for-80501b0c0e3b)
|
|
9
9
|
|
|
10
|
-
## New in v0.0
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
10
|
+
## New in v0.1.0 🚀
|
|
11
|
+
- **Horizontal Layouts**: Flip the chart horizontally using `layout="horizontal"`. Works automatically on Web and Native.
|
|
12
|
+
- **Grouped Variant**: Introducing side-by-side grouped charts for multi-value datasets using `variant="grouped"`.
|
|
13
|
+
- **Zero-Day Auto Fill**: Setting `missingDataStrategy="zero"` automatically detects and inserts missing dates/months so your timelines flow continuously without skips.
|
|
14
|
+
- **Annotations**: Feed an array of `annotations={[{ value: 50, label: "Target" }]}` to draw persistent threshold lines across the chart.
|
|
15
|
+
- **Value Formatters**: Pass `valueFormatter={(val) => '$' + val}` to format the Y-axis and labels automatically.
|
|
14
16
|
|
|
15
17
|
## Features
|
|
16
18
|
|
|
17
19
|
- 📅 **Time-based Drill Down**: Navigate seamlessly continuously from **Year** -> **Month** -> **Week** -> **Day**.
|
|
20
|
+
- 📐 **Multiple Layouts**: Toggle between **vertical** and **horizontal** layout rendering instantly.
|
|
18
21
|
- 🎨 **Deep Customization**: Full control over colors, grid, axis, and bar styling via the `theme` prop.
|
|
19
|
-
- 📱 **React Native Support**: First-class support for Mobile via `react-native-svg
|
|
20
|
-
- 🥞 **
|
|
22
|
+
- 📱 **React Native Support**: First-class support for Mobile via `react-native-svg` (100% parity with Web).
|
|
23
|
+
- 🥞 **Variants**: Support for `stacked` & `grouped` bars for multi-value data keys (Histogram style).
|
|
21
24
|
- ♿ **Accessible**: ARIA support for Web and Accessibility Props for Native.
|
|
22
25
|
- 🤖 **AI Ready**: Integrated interfaces for predictive analytics.
|
|
23
26
|
|
|
24
27
|
## Installation
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
|
-
npm install universal-adaptive-bars date-fns d3-scale
|
|
30
|
+
npm install universal-adaptive-bars date-fns d3-scale
|
|
28
31
|
# Peer Dependencies for React Native
|
|
29
32
|
# npm install react-native-svg
|
|
30
33
|
```
|
|
@@ -45,14 +48,14 @@ function App() {
|
|
|
45
48
|
<SmartBarChart
|
|
46
49
|
data={data}
|
|
47
50
|
view="month"
|
|
51
|
+
layout="vertical"
|
|
52
|
+
variant="grouped"
|
|
53
|
+
missingDataStrategy="zero"
|
|
54
|
+
valueFormatter={(val) => `$${val}`}
|
|
55
|
+
annotations={[{ value: 150, label: 'Goal', color: 'green' }]}
|
|
48
56
|
dataKeys={{ label: 'label', value: 'value', date: 'date' }}
|
|
49
57
|
axisLabels={{ x: 'Date', y: 'Revenue' }}
|
|
50
58
|
height={400}
|
|
51
|
-
theme={{
|
|
52
|
-
background: '#fff',
|
|
53
|
-
bar: { radius: 4, opacity: 1 },
|
|
54
|
-
grid: { stroke: '#eee', visible: true }
|
|
55
|
-
}}
|
|
56
59
|
/>
|
|
57
60
|
);
|
|
58
61
|
}
|
|
@@ -63,11 +66,10 @@ function App() {
|
|
|
63
66
|
```tsx
|
|
64
67
|
import { SmartBarChartNative } from 'smart-bar-chart/native';
|
|
65
68
|
|
|
66
|
-
// ... usage is identical to Web component
|
|
69
|
+
// ... usage is identical to Web component (Horizontal, Grouped, Zero-Day fully supported!)
|
|
67
70
|
<SmartBarChartNative
|
|
68
71
|
data={data}
|
|
69
|
-
|
|
70
|
-
dataKeys={{ label: 'label', value: 'value', date: 'date' }}
|
|
72
|
+
...
|
|
71
73
|
/>
|
|
72
74
|
```
|
|
73
75
|
|
|
@@ -78,9 +80,12 @@ import { SmartBarChartNative } from 'smart-bar-chart/native';
|
|
|
78
80
|
| `data` | `RawDataPoint[]` | Array of data objects. |
|
|
79
81
|
| `view` | `'day' \| 'week' \| 'month' \| 'year'` | Initial aggregation level. |
|
|
80
82
|
| `dataKeys` | `{ label: string, value: string \| string[], date: string }` | Keys to map data fields. |
|
|
83
|
+
| `variant` | `'default' \| 'stacked' \| 'grouped'` | The style architecture. |
|
|
84
|
+
| `layout` | `'vertical' \| 'horizontal'` | Flipped orientation. |
|
|
85
|
+
| `missingDataStrategy` | `'skip' \| 'zero'` | Strategy to deal with timeline skips. |
|
|
86
|
+
| `annotations` | `Array<{ value, label?, color?, strokeDasharray? }>` | Draws horizontal/vertical threshold lines. |
|
|
87
|
+
| `valueFormatter` | `(value: number) => string` | Custom formatting function. |
|
|
81
88
|
| `theme` | `ChartTheme` | Custom styling object. |
|
|
82
|
-
| `onViewChange` | `(view: ChartView) => void` | Callback when drill-down occurs. |
|
|
83
|
-
| `geminiConfig` | `{ apiKey: string, model: string }` | Configuration for AI predictions. |
|
|
84
89
|
|
|
85
90
|
## Customization (Theme)
|
|
86
91
|
|