vedic-calc 1.0.3

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.
@@ -0,0 +1,411 @@
1
+ ---
2
+ title: API Reference - Vedic Calc
3
+ description: Complete API documentation for Kundali Charts SDK - generateRasiChart, generateNavamsaChart, SVG chart generation functions.
4
+ keywords:
5
+ - kundali charts api
6
+ - generateRasiChart
7
+ - generateNavamsaChart
8
+ - svg renderer
9
+ - vedic astrology api
10
+ - typescript astrology
11
+ ---
12
+
13
+ # API Reference
14
+
15
+ ## Chart Generation
16
+
17
+ ### generateRasiChart
18
+
19
+ Generates a complete Rasi (D-1) birth chart with planetary positions.
20
+
21
+ ```typescript
22
+ function generateRasiChart(
23
+ date: Date,
24
+ latitude: number,
25
+ longitude: number,
26
+ timezone?: string,
27
+ nodeType?: NodeType
28
+ ): BirthChart
29
+ ```
30
+
31
+ **Parameters:**
32
+
33
+ | Parameter | Type | Required | Description |
34
+ |-----------|------|----------|-------------|
35
+ | `date` | `Date` | Yes | Date and time of birth |
36
+ | `latitude` | `number` | Yes | Birth place latitude (-90 to 90) |
37
+ | `longitude` | `number` | Yes | Birth place longitude (-180 to 180) |
38
+ | `timezone` | `string` | No | IANA timezone (default: "UTC") |
39
+ | `nodeType` | `NodeType` | No | Rahu/Ketu node type (default: Mean) |
40
+
41
+ **Returns:** `BirthChart`
42
+
43
+ **Example:**
44
+
45
+ ```typescript
46
+ const chart = generateRasiChart(
47
+ new Date('1990-04-29T21:15:00+05:30'),
48
+ 16.544893, // Latitude
49
+ 81.521240, // Longitude
50
+ 'Asia/Kolkata'
51
+ );
52
+ ```
53
+
54
+ ---
55
+
56
+ ### generateNavamsaChart
57
+
58
+ Generates Navamsa (D-9) divisional chart from Rasi chart.
59
+
60
+ ```typescript
61
+ function generateNavamsaChart(rasiChart: BirthChart): BirthChart
62
+ ```
63
+
64
+ **Parameters:**
65
+
66
+ | Parameter | Type | Required | Description |
67
+ |-----------|------|----------|-------------|
68
+ | `rasiChart` | `BirthChart` | Yes | Rasi chart from `generateRasiChart` |
69
+
70
+ **Returns:** `BirthChart`
71
+
72
+ **Example:**
73
+
74
+ ```typescript
75
+ const rasi = generateRasiChart(date, lat, lon, tz);
76
+ const navamsa = generateNavamsaChart(rasi);
77
+ ```
78
+
79
+ ---
80
+
81
+ ### generateKundali
82
+
83
+ Generates both Rasi (D-1) and Navamsa (D-9) charts in one call.
84
+
85
+ ```typescript
86
+ function generateKundali(
87
+ date: Date,
88
+ latitude: number,
89
+ longitude: number,
90
+ timezone?: string,
91
+ options?: { nodeType?: NodeType }
92
+ ): { rasi: RasiChart; navamsa: NavamsaChart }
93
+ ```
94
+
95
+ **Parameters:**
96
+
97
+ | Parameter | Type | Required | Description |
98
+ |-----------|------|----------|-------------|
99
+ | `date` | `Date` | Yes | Date and time of birth |
100
+ | `latitude` | `number` | Yes | Birth place latitude (-90 to 90) |
101
+ | `longitude` | `number` | Yes | Birth place longitude (-180 to 180) |
102
+ | `timezone` | `string` | No | IANA timezone (default: "UTC") |
103
+ | `options.nodeType` | `NodeType` | No | Rahu/Ketu node type |
104
+
105
+ **Returns:** `{ rasi: RasiChart; navamsa: NavamsaChart }`
106
+
107
+ **Example:**
108
+
109
+ ```typescript
110
+ const { rasi, navamsa } = generateKundali(
111
+ new Date('1990-04-29T21:15:00+05:30'),
112
+ 16.544893,
113
+ 81.521240,
114
+ 'Asia/Kolkata'
115
+ );
116
+ ```
117
+
118
+ ---
119
+
120
+ ### calculateNavamsaSign
121
+
122
+ Calculates the Navamsa sign for a given longitude.
123
+
124
+ ```typescript
125
+ function calculateNavamsaSign(longitude: number): Sign
126
+ ```
127
+
128
+ **Parameters:**
129
+
130
+ | Parameter | Type | Required | Description |
131
+ |-----------|------|----------|-------------|
132
+ | `longitude` | `number` | Yes | Planetary longitude (0-360) |
133
+
134
+ **Returns:** `Sign` (0-11)
135
+
136
+ **Example:**
137
+
138
+ ```typescript
139
+ const navamsaSign = calculateNavamsaSign(125.5); // Returns Sign
140
+ ```
141
+
142
+ ---
143
+
144
+ ## SVG Chart Rendering
145
+
146
+ ### generateNorthIndianChartSVG
147
+
148
+ Generates North Indian style chart (diamond grid layout).
149
+
150
+ ```typescript
151
+ function generateNorthIndianChartSVG(
152
+ chart: BirthChart,
153
+ options?: NorthIndianOptions
154
+ ): string
155
+ ```
156
+
157
+ **Options:**
158
+
159
+ ```typescript
160
+ interface NorthIndianOptions {
161
+ showTable?: boolean; // Show planet details table
162
+ layout?: 'row' | 'column'; // Table layout
163
+ title?: string; // Chart title
164
+ width?: number; // Chart width in pixels
165
+ height?: number; // Chart height in pixels
166
+ showSignGlyphs?: boolean; // Show zodiac symbols (♈♉♊)
167
+ showSignNumbers?: boolean; // Show sign numbers (1-12)
168
+ showDegrees?: boolean; // Show planet degrees
169
+ customConfig?: ChartConfig; // Custom styling
170
+ }
171
+ ```
172
+
173
+ **Example:**
174
+
175
+ ```typescript
176
+ const svg = generateNorthIndianChartSVG(chart, {
177
+ showTable: true,
178
+ layout: 'row',
179
+ title: 'My Kundali',
180
+ width: 400,
181
+ height: 300,
182
+ showSignGlyphs: true,
183
+ showSignNumbers: true,
184
+ showDegrees: true,
185
+ customConfig: {
186
+ colors: {
187
+ background: '#FFFFFF',
188
+ border: '#422762',
189
+ innerLines: '#422762',
190
+ signNumber: '#422762',
191
+ text: '#1A1A2E',
192
+ retrograde: '#D63031',
193
+ }
194
+ }
195
+ });
196
+ ```
197
+
198
+ ---
199
+
200
+ ### generateSouthIndianChartSVG
201
+
202
+ Generates South Indian style chart (3x4 grid layout).
203
+
204
+ ```typescript
205
+ function generateSouthIndianChartSVG(
206
+ chart: BirthChart,
207
+ options?: SouthIndianOptions
208
+ ): string
209
+ ```
210
+
211
+ **Options:**
212
+
213
+ ```typescript
214
+ interface SouthIndianOptions {
215
+ showTable?: boolean; // Show planet details table
216
+ showSignGlyphs?: boolean; // Show zodiac symbols
217
+ showSignNumbers?: boolean; // Show sign numbers
218
+ showDegrees?: boolean; // Show planet degrees
219
+ cellWidth?: number; // Cell width
220
+ cellHeight?: number; // Cell height
221
+ title?: string; // Chart title
222
+ customConfig?: ChartConfig; // Custom styling
223
+ }
224
+ ```
225
+
226
+ **Example:**
227
+
228
+ ```typescript
229
+ const svg = generateSouthIndianChartSVG(chart, {
230
+ showTable: true,
231
+ showSignGlyphs: true,
232
+ cellWidth: 150,
233
+ cellHeight: 100,
234
+ title: 'My Kundali'
235
+ });
236
+ ```
237
+
238
+ ---
239
+
240
+ ### PREBUILT_THEMES
241
+
242
+ Pre-defined color themes for charts.
243
+
244
+ ```typescript
245
+ const PREBUILT_THEMES: {
246
+ light: ChartTheme;
247
+ dark: ChartTheme;
248
+ ocean: ChartTheme;
249
+ forest: ChartTheme;
250
+ golden: ChartTheme;
251
+ }
252
+ ```
253
+
254
+ **Example:**
255
+
256
+ ```typescript
257
+ import { generateNorthIndianChartSVG, PREBUILT_THEMES } from 'vedic-calc';
258
+
259
+ const svg = generateNorthIndianChartSVG(chart, {
260
+ customConfig: {
261
+ colors: PREBUILT_THEMES.dark.colors
262
+ }
263
+ });
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Core Functions
269
+
270
+ ### getAyanamsa
271
+
272
+ Calculates the ayanamsa (sidereal correction) value.
273
+
274
+ ```typescript
275
+ function getAyanamsa(jd: number, system?: AyanamsaSystem): number
276
+ ```
277
+
278
+ ### tropicalToSidereal
279
+
280
+ Converts tropical longitude to sidereal longitude.
281
+
282
+ ```typescript
283
+ function tropicalToSidereal(tropicalLongitude: number, ayanamsa: number): number
284
+ ```
285
+
286
+ ### calculateHouseCusps
287
+
288
+ Calculates house cusps for a given time and location.
289
+
290
+ ```typescript
291
+ function calculateHouseCusps(
292
+ jd: number,
293
+ latitude: number,
294
+ longitude: number,
295
+ system?: HouseSystem
296
+ ): number[]
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Types & Enums
302
+
303
+ ### Planet
304
+
305
+ ```typescript
306
+ enum Planet {
307
+ SUN = 0,
308
+ MOON = 1,
309
+ MARS = 2,
310
+ MERCURY = 3,
311
+ JUPITER = 4,
312
+ VENUS = 5,
313
+ SATURN = 6,
314
+ RAHU = 7,
315
+ KETU = 8
316
+ }
317
+ ```
318
+
319
+ ### Sign
320
+
321
+ ```typescript
322
+ enum Sign {
323
+ ARIES = 0,
324
+ TAURUS = 1,
325
+ GEMINI = 2,
326
+ CANCER = 3,
327
+ LEO = 4,
328
+ VIRGO = 5,
329
+ LIBRA = 6,
330
+ SCORPIO = 7,
331
+ SAGITTARIUS = 8,
332
+ CAPRICORN = 9,
333
+ AQUARIUS = 10,
334
+ PISCES = 11
335
+ }
336
+ ```
337
+
338
+ ### Nakshatras
339
+
340
+ ```typescript
341
+ const Nakshatras: string[] = [
342
+ "Ashwini", "Bharani", "Kritika", "Rohini", "Mrigashira",
343
+ "Ardra", "Punarvasu", "Pushya", "Ashlesha", "Magha",
344
+ "Purva Phalguni", "Uttara Phalguni", "Hasta", "Chitra",
345
+ "Swati", "Vishakha", "Anuradha", "Jyeshtha", "Mula",
346
+ "Purva Ashadha", "Uttara Ashadha", "Shravana", "Dhanishtha",
347
+ "Shatabhisha", "Purva Bhadrapada", "Uttara Bhadrapada", "Revati"
348
+ ]
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Return Types
354
+
355
+ ### BirthChart
356
+
357
+ ```typescript
358
+ interface BirthChart {
359
+ birthData: {
360
+ date: Date;
361
+ latitude: number;
362
+ longitude: number;
363
+ timezone: string;
364
+ };
365
+
366
+ ascendant: {
367
+ degree: number;
368
+ sign: Sign;
369
+ signName: string;
370
+ nakshatra: string;
371
+ nakshatraPada: number;
372
+ };
373
+
374
+ planets: PlanetPosition[];
375
+
376
+ houses: House[];
377
+
378
+ ayanamsa: number;
379
+ }
380
+ ```
381
+
382
+ ### PlanetPosition
383
+
384
+ ```typescript
385
+ interface PlanetPosition {
386
+ planet: Planet;
387
+ longitude: number;
388
+ sign: Sign;
389
+ signName: string;
390
+ degreeInSign: number;
391
+ nakshatra: string;
392
+ nakshatraPada: number;
393
+ nakshatraLord: string;
394
+ house: number;
395
+ isRetrograde: boolean;
396
+ }
397
+ ```
398
+
399
+ ### House
400
+
401
+ ```typescript
402
+ interface House {
403
+ number: number;
404
+ sign: Sign;
405
+ signName: string;
406
+ lord: string;
407
+ planets: Planet[];
408
+ cuspStart: number;
409
+ cuspEnd: number;
410
+ }
411
+ ```
package/docs/charts.md ADDED
@@ -0,0 +1,237 @@
1
+ ---
2
+ title: Chart Rendering - Vedic Astro
3
+ description: Learn how to customize SVG charts with themes, colors, layouts, and styling options in Kundali Charts SDK.
4
+ keywords:
5
+ - svg chart rendering
6
+ - north indian chart
7
+ - south indian chart
8
+ - chart customization
9
+ - chart themes
10
+ - kundali visualization
11
+ ---
12
+
13
+ # Chart Rendering
14
+
15
+ Kundali Charts provides two SVG chart styles: North Indian and South Indian. Both can be extensively customized.
16
+
17
+ ## Chart Styles
18
+
19
+ ### North Indian Chart
20
+
21
+ The North Indian chart uses a diamond grid layout, common in North India.
22
+
23
+ ```typescript
24
+ import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
25
+
26
+ const chart = generateRasiChart(date, lat, lon, tz);
27
+
28
+ const svg = generateNorthIndianChartSVG(chart, {
29
+ showTable: true,
30
+ title: 'My Birth Chart'
31
+ });
32
+ ```
33
+
34
+ ### South Indian Chart
35
+
36
+ The South Indian chart uses a 3x4 grid layout, common in South India.
37
+
38
+ ```typescript
39
+ import { generateSouthIndianChartSVG } from 'vedic-calc';
40
+
41
+ const svg = generateSouthIndianChartSVG(chart, {
42
+ showTable: true,
43
+ title: 'My Birth Chart'
44
+ });
45
+ ```
46
+
47
+ ## Customization Options
48
+
49
+ ### Basic Options
50
+
51
+ ```typescript
52
+ const options = {
53
+ // Display options
54
+ showTable: true, // Show/hide planet table
55
+ showSignGlyphs: true, // Show ♈♉♊ symbols
56
+ showSignNumbers: true, // Show 1-12 numbers
57
+ showDegrees: true, // Show planet degrees
58
+
59
+ // Layout
60
+ title: 'My Kundali', // Chart title
61
+ width: 400, // Chart width
62
+ height: 300, // Chart height
63
+
64
+ // South Indian only
65
+ cellWidth: 150, // Cell width
66
+ cellHeight: 100 // Cell height
67
+ };
68
+ ```
69
+
70
+ ### Color Customization
71
+
72
+ ```typescript
73
+ const customConfig = {
74
+ colors: {
75
+ background: '#FFFFFF', // Chart background
76
+ border: '#422762', // Outer border
77
+ innerLines: '#422762', // Grid lines
78
+ signNumber: '#422762', // Sign numbers
79
+ text: '#1A1A2E', // Main text
80
+ retrograde: '#D63031', // Retrograde planets
81
+ }
82
+ };
83
+
84
+ const svg = generateNorthIndianChartSVG(chart, {
85
+ customConfig
86
+ });
87
+ ```
88
+
89
+ ## Pre-built Themes
90
+
91
+ ### Dark Theme
92
+
93
+ ```typescript
94
+ import { PREBUILT_THEMES } from 'vedic-calc';
95
+
96
+ const svg = generateNorthIndianChartSVG(chart, {
97
+ customConfig: {
98
+ colors: PREBUILT_THEMES.dark.colors
99
+ }
100
+ });
101
+ ```
102
+
103
+ ### Ocean Theme
104
+
105
+ ```typescript
106
+ const svg = generateNorthIndianChartSVG(chart, {
107
+ customConfig: {
108
+ colors: PREBUILT_THEMES.ocean.colors
109
+ }
110
+ });
111
+ ```
112
+
113
+ ### Forest Theme
114
+
115
+ ```typescript
116
+ const svg = generateNorthIndianChartSVG(chart, {
117
+ customConfig: {
118
+ colors: PREBUILT_THEMES.forest.colors
119
+ }
120
+ });
121
+ ```
122
+
123
+ ### Golden Theme
124
+
125
+ ```typescript
126
+ const svg = generateNorthIndianChartSVG(chart, {
127
+ customConfig: {
128
+ colors: PREBUILT_THEMES.golden.colors
129
+ }
130
+ });
131
+ ```
132
+
133
+ ## Complete Example
134
+
135
+ ```typescript
136
+ import {
137
+ generateRasiChart,
138
+ generateNorthIndianChartSVG
139
+ } from 'vedic-calc';
140
+
141
+ const chart = generateRasiChart(
142
+ new Date('1990-04-29T21:15:00+05:30'),
143
+ 16.544893,
144
+ 81.521240,
145
+ 'Asia/Kolkata'
146
+ );
147
+
148
+ // Generate SVG chart
149
+ const svg = generateNorthIndianChartSVG(chart, {
150
+ showTable: true,
151
+ width: 500,
152
+ height: 400,
153
+ });
154
+
155
+ // Embed in HTML
156
+ const container = document.getElementById('kundali');
157
+ container.innerHTML = svg;
158
+ ```
159
+ colors: {
160
+ background: '#1a1a2e',
161
+ border: '#e94560',
162
+ innerLines: '#e94560',
163
+ signNumber: '#e94560',
164
+ text: '#ffffff',
165
+ retrograde: '#ff6b6b',
166
+ }
167
+ }
168
+ });
169
+
170
+ // Embed in HTML
171
+ const container = document.getElementById('kundali');
172
+ container.innerHTML = svg;
173
+ ```
174
+
175
+ ## HTML Integration
176
+
177
+ ```html
178
+ <!DOCTYPE html>
179
+ <html>
180
+ <head>
181
+ <title>Kundali Chart</title>
182
+ <style>
183
+ body {
184
+ display: flex;
185
+ justify-content: center;
186
+ align-items: center;
187
+ min-height: 100vh;
188
+ margin: 0;
189
+ background: #f5f5f5;
190
+ }
191
+ .chart-container {
192
+ background: white;
193
+ padding: 20px;
194
+ border-radius: 12px;
195
+ box-shadow: 0 4px 20px rgba(0,0,0,0.15);
196
+ }
197
+ </style>
198
+ </head>
199
+ <body>
200
+ <div class="chart-container" id="kundali"></div>
201
+
202
+ <script type="module">
203
+ import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
204
+
205
+ const chart = generateRasiChart(
206
+ new Date('1990-04-29T21:15:00+05:30'),
207
+ 16.544893,
208
+ 81.521240,
209
+ 'Asia/Kolkata'
210
+ );
211
+
212
+ const svg = generateNorthIndianChartSVG(chart, {
213
+ showTable: true,
214
+ title: 'My Birth Chart'
215
+ });
216
+
217
+ document.getElementById('kundali').innerHTML = svg;
218
+ </script>
219
+ </body>
220
+ </html>
221
+ ```
222
+
223
+ ## Chart Comparison
224
+
225
+ | Feature | North Indian | South Indian |
226
+ |---------|--------------|--------------|
227
+ | Layout | Diamond grid | 3x4 grid |
228
+ | Best for | Quick overview | Detailed view |
229
+ | Table position | Side | Bottom |
230
+ | Default orientation | - | Signs 1-12 left to right |
231
+
232
+ ## Tips
233
+
234
+ 1. **Use appropriate size** - Set width/height based on where you'll display
235
+ 2. **Choose right style** - North Indian for overview, South Indian for details
236
+ 3. **Theme matching** - Match chart theme to your app's design
237
+ 4. **Show/hide elements** - Customize what information to display