vedic-calc 1.0.4 → 1.0.5
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 +598 -216
- package/docs/api-reference.md +160 -185
- package/docs/charts.md +63 -127
- package/docs/examples.md +173 -135
- package/docs/getting-started.md +113 -71
- package/docs/index.md +54 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
# vedic-calc
|
|
4
|
+
|
|
5
|
+
### High-Precision Vedic Astrology (Jyotish) SDK for Node.js & TypeScript
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://www.npmjs.com/package/vedic-calc"><img src="https://img.shields.io/npm/v/vedic-calc.svg?style=flat-square&color=CB3837" alt="npm version"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/vedic-calc"><img src="https://img.shields.io/npm/dm/vedic-calc.svg?style=flat-square&color=blue" alt="npm downloads"></a>
|
|
10
|
+
<a href="https://github.com/jatingodnani/vedic-calc/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vedic-calc.svg?style=flat-square&color=green" alt="MIT License"></a>
|
|
11
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.x-3178C6?style=flat-square&logo=typescript" alt="TypeScript"></a>
|
|
12
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node.js-%3E%3D16-339933?style=flat-square&logo=node.js" alt="Node.js"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p>
|
|
16
|
+
Generate <strong>Rasi (D-1)</strong> & <strong>Navamsa (D-9)</strong> charts · <strong>9 Planets</strong> · <strong>27 Nakshatras</strong> · <strong>SVG Rendering</strong> · <strong>Swiss Ephemeris precision</strong>
|
|
8
17
|
</p>
|
|
9
18
|
|
|
10
|
-
>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Table of Contents
|
|
24
|
+
|
|
25
|
+
- [Why vedic-calc?](#why-vedic-calc)
|
|
26
|
+
- [Features](#features)
|
|
27
|
+
- [Installation](#installation)
|
|
28
|
+
- [Quick Start](#quick-start)
|
|
29
|
+
- [Core Concepts](#core-concepts)
|
|
30
|
+
- [API Reference](#api-reference)
|
|
31
|
+
- [generateKundali](#generatekundalidate-latitude-longitude-timezone-options)
|
|
32
|
+
- [generateRasiChart](#generaterasichartdate-latitude-longitude-timezone-nodetype)
|
|
33
|
+
- [generateNavamsaChart](#generatenavamsachartrasichart)
|
|
34
|
+
- [generateNorthIndianChartSVG](#generatenorthindianchartssvgchart-options)
|
|
35
|
+
- [Constants & Enums](#constants--enums)
|
|
36
|
+
- [SVG Chart Options](#svg-chart-options)
|
|
37
|
+
- [Usage Examples](#usage-examples)
|
|
38
|
+
- [Basic Kundali](#1-basic-kundali)
|
|
39
|
+
- [Save SVG to File](#2-save-svg-to-file)
|
|
40
|
+
- [Embed in HTML](#3-embed-in-html)
|
|
41
|
+
- [Express.js API](#4-expressjs-api-endpoint)
|
|
42
|
+
- [Next.js / React](#5-nextjs--react)
|
|
43
|
+
- [TypeScript Types](#typescript-types)
|
|
44
|
+
- [Roadmap](#roadmap)
|
|
45
|
+
- [Contributing](#contributing)
|
|
46
|
+
- [License](#license)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Why vedic-calc?
|
|
51
|
+
|
|
52
|
+
Most astrology libraries are either Western-focused, inaccurate, or lack developer-friendly APIs. **vedic-calc** is built specifically for **Vedic (Jyotish) astrology** with:
|
|
53
|
+
|
|
54
|
+
- **NASA-grade precision** via Swiss Ephemeris (same engine used by AstroSage, Astro.com)
|
|
55
|
+
- **Developer-first API** — one function call to get a complete Kundali
|
|
56
|
+
- **Built-in SVG rendering** — no external charting libraries needed
|
|
57
|
+
- **Zero config** — ephemeris data files bundled in the package
|
|
58
|
+
- **Full TypeScript support** — complete type definitions included
|
|
59
|
+
|
|
60
|
+
---
|
|
11
61
|
|
|
12
62
|
## Features
|
|
13
63
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
64
|
+
| Feature | Details |
|
|
65
|
+
|-------------------------|--------------------------------------------------------------|
|
|
66
|
+
| **Rasi Chart (D-1)** | Complete birth chart with all 9 planets in 12 signs |
|
|
67
|
+
| **Navamsa Chart (D-9)** | Divisional chart for marriage & spiritual analysis |
|
|
68
|
+
| **9 Planets** | Sun, Moon, Mars, Mercury, Jupiter, Venus, Saturn, Rahu, Ketu |
|
|
69
|
+
| **12 Houses** | Whole Sign house system (traditional Vedic method) |
|
|
70
|
+
| **27 Nakshatras** | Full nakshatra name, pada (1–4), and nakshatra lord |
|
|
71
|
+
| **Ascendant (Lagna)** | Precise Lagna with sign, nakshatra, and pada |
|
|
72
|
+
| **Retrograde Detection** | Automatically detects and flags retrograde planets |
|
|
73
|
+
| **Lahiri Ayanamsa** | Industry-standard Chitrapaksha ayanamsa |
|
|
74
|
+
| **True / Mean Node** | Choose between True Node or Mean Node for Rahu/Ketu |
|
|
75
|
+
| **SVG Chart Rendering** | North Indian diamond-grid style chart |
|
|
76
|
+
| **Planet Details Table** | Inline SVG table with sign, degree, nakshatra, house |
|
|
77
|
+
| **TypeScript** | Full `.d.ts` type definitions included |
|
|
78
|
+
|
|
79
|
+
---
|
|
26
80
|
|
|
27
81
|
## Installation
|
|
28
82
|
|
|
@@ -30,289 +84,617 @@
|
|
|
30
84
|
npm install vedic-calc
|
|
31
85
|
```
|
|
32
86
|
|
|
87
|
+
```bash
|
|
88
|
+
yarn add vedic-calc
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm add vedic-calc
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> **Requirements:** Node.js >= 16.0.0
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
33
99
|
## Quick Start
|
|
34
100
|
|
|
35
101
|
```typescript
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
new Date('1990-04-29T21:15:00+05:30'),
|
|
41
|
-
16.
|
|
42
|
-
81.
|
|
43
|
-
'Asia/Kolkata'
|
|
102
|
+
import { generateKundali, generateNorthIndianChartSVG, Planet } from 'vedic-calc';
|
|
103
|
+
|
|
104
|
+
// One call to get both Rasi + Navamsa charts
|
|
105
|
+
const { rasi, navamsa } = generateKundali(
|
|
106
|
+
new Date('1990-04-29T21:15:00+05:30'), // Date & time of birth
|
|
107
|
+
16.5449, // Latitude
|
|
108
|
+
81.5212, // Longitude
|
|
109
|
+
'Asia/Kolkata' // Timezone
|
|
44
110
|
);
|
|
45
111
|
|
|
46
|
-
//
|
|
47
|
-
console.log(
|
|
48
|
-
console.log('Ascendant:', chart.ascendant.signName, chart.ascendant.nakshatra);
|
|
49
|
-
console.log('Moon Sign:', chart.planets[1].signName);
|
|
50
|
-
|
|
51
|
-
// All Planets
|
|
52
|
-
chart.planets.forEach(p => {
|
|
53
|
-
console.log(`${p.planet}: ${p.signName} ${p.degreeInSign.toFixed(2)}° (${p.nakshatra} ${p.nakshatraPada})`);
|
|
54
|
-
});
|
|
112
|
+
// Ascendant (Lagna)
|
|
113
|
+
console.log(`Ascendant: ${rasi.ascendant.signName} (${rasi.ascendant.nakshatra} Pada ${rasi.ascendant.nakshatraPada})`);
|
|
55
114
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
115
|
+
// All 9 planets
|
|
116
|
+
rasi.planets.forEach(p => {
|
|
117
|
+
const retro = p.isRetrograde ? ' (R)' : '';
|
|
118
|
+
console.log(`${Planet[p.planet]}: ${p.signName} ${p.degreeInSign.toFixed(2)} | ${p.nakshatra} Pada ${p.nakshatraPada} | House ${p.house}${retro}`);
|
|
59
119
|
});
|
|
60
120
|
|
|
61
121
|
// Generate SVG chart
|
|
62
|
-
const svg = generateNorthIndianChartSVG(
|
|
63
|
-
|
|
64
|
-
// Save to file or display
|
|
65
|
-
console.log(svg);
|
|
122
|
+
const svg = generateNorthIndianChartSVG(rasi, { showTable: true });
|
|
66
123
|
```
|
|
67
124
|
|
|
68
125
|
**Sample Output:**
|
|
69
126
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...
|
|
127
|
+
Ascendant: Virgo (Hasta Pada 2)
|
|
128
|
+
SUN: Taurus 14.22 | Rohini Pada 2 | House 9
|
|
129
|
+
MOON: Taurus 3.56 | Krittika Pada 3 | House 9
|
|
130
|
+
MARS: Cancer 28.41 | Ashlesha Pada 4 | House 11
|
|
131
|
+
MERCURY: Aries 28.10 | Krittika Pada 1 | House 8
|
|
132
|
+
JUPITER: Cancer 9.88 | Pushya Pada 2 | House 11
|
|
133
|
+
VENUS: Pisces 22.34 | Revati Pada 3 | House 7
|
|
134
|
+
SATURN: Capricorn 4.12| Uttara Ashadha P 2 | House 5
|
|
135
|
+
RAHU: Aquarius 18.55| Shatabhisha Pada 1 | House 6
|
|
136
|
+
KETU: Leo 18.55 | Purva Phalguni P 1 | House 12
|
|
81
137
|
```
|
|
82
138
|
|
|
83
|
-
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Core Concepts
|
|
142
|
+
|
|
143
|
+
| Term | Meaning |
|
|
144
|
+
|------------------------|----------------------------------------------------------------------------|
|
|
145
|
+
| **Rasi (D-1)** | The main birth chart — shows planetary positions at the time of birth |
|
|
146
|
+
| **Navamsa (D-9)** | A divisional chart — each sign is divided into 9 parts; used for marriage & dharma |
|
|
147
|
+
| **Lagna (Ascendant)** | The rising sign at the time of birth — the most important point in the chart |
|
|
148
|
+
| **Nakshatra** | One of 27 lunar mansions (each 13°20') — gives deeper insight than just the sign |
|
|
149
|
+
| **Pada** | Each nakshatra is divided into 4 padas (quarters) of 3°20' each |
|
|
150
|
+
| **Ayanamsa** | The difference between Tropical and Sidereal zodiacs (~24° currently) |
|
|
151
|
+
| **Whole Sign Houses** | Traditional Vedic house system — each house = one complete zodiac sign |
|
|
152
|
+
| **Retrograde** | A planet appearing to move backward — considered significant in Jyotish |
|
|
84
153
|
|
|
85
|
-
|
|
154
|
+
---
|
|
86
155
|
|
|
87
|
-
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### `generateKundali(date, latitude, longitude, timezone?, options?)`
|
|
88
159
|
|
|
89
|
-
Generates
|
|
160
|
+
The **all-in-one** function. Generates both Rasi and Navamsa charts in a single call.
|
|
90
161
|
|
|
91
162
|
```typescript
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
163
|
+
import { generateKundali, NodeType } from 'vedic-calc';
|
|
164
|
+
|
|
165
|
+
const { rasi, navamsa } = generateKundali(
|
|
166
|
+
new Date('1990-04-29T21:15:00+05:30'),
|
|
167
|
+
16.5449,
|
|
168
|
+
81.5212,
|
|
169
|
+
'Asia/Kolkata',
|
|
170
|
+
{ nodeType: NodeType.TRUE_NODE } // optional: TRUE_NODE (default) or MEAN_NODE
|
|
97
171
|
);
|
|
98
172
|
```
|
|
99
173
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
sign: Sign, // 0-11
|
|
110
|
-
signName: string,
|
|
111
|
-
degreeInSign: number,
|
|
112
|
-
nakshatra: string,
|
|
113
|
-
nakshatraPada: number,
|
|
114
|
-
nakshatraLord: string,
|
|
115
|
-
house: number, // 1-12
|
|
116
|
-
isRetrograde: boolean
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
houses: [
|
|
120
|
-
{
|
|
121
|
-
number: number,
|
|
122
|
-
sign: Sign,
|
|
123
|
-
signName: string,
|
|
124
|
-
lord: string,
|
|
125
|
-
planets: Planet[],
|
|
126
|
-
cuspStart: number,
|
|
127
|
-
cuspEnd: number
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
ayanamsa: number
|
|
131
|
-
}
|
|
132
|
-
```
|
|
174
|
+
| Parameter | Type | Required | Description |
|
|
175
|
+
|---------------------|----------|----------|--------------------------------------------------------------|
|
|
176
|
+
| `date` | `Date` | Yes | Birth date and time (use the local time with timezone offset) |
|
|
177
|
+
| `latitude` | `number` | Yes | Geographic latitude (-90 to +90) |
|
|
178
|
+
| `longitude` | `number` | Yes | Geographic longitude (-180 to +180) |
|
|
179
|
+
| `timezone` | `string` | No | IANA timezone string (default: `'UTC'`) |
|
|
180
|
+
| `options.nodeType` | `NodeType` | No | `TRUE_NODE` or `MEAN_NODE` for Rahu/Ketu (default: `TRUE_NODE`) |
|
|
181
|
+
|
|
182
|
+
**Returns:** `{ rasi: RasiChart, navamsa: NavamsaChart }`
|
|
133
183
|
|
|
134
|
-
|
|
184
|
+
---
|
|
135
185
|
|
|
136
|
-
|
|
186
|
+
### `generateRasiChart(date, latitude, longitude, timezone?, nodeType?)`
|
|
187
|
+
|
|
188
|
+
Generates only the Rasi (D-1) birth chart.
|
|
137
189
|
|
|
138
190
|
```typescript
|
|
139
|
-
|
|
191
|
+
import { generateRasiChart } from 'vedic-calc';
|
|
192
|
+
|
|
193
|
+
const chart = generateRasiChart(
|
|
194
|
+
new Date('1990-04-29T21:15:00+05:30'),
|
|
195
|
+
16.5449,
|
|
196
|
+
81.5212,
|
|
197
|
+
'Asia/Kolkata'
|
|
198
|
+
);
|
|
140
199
|
```
|
|
141
200
|
|
|
142
|
-
|
|
201
|
+
**Returns:** `RasiChart` — see [TypeScript Types](#typescript-types) for full structure.
|
|
202
|
+
|
|
203
|
+
---
|
|
143
204
|
|
|
144
|
-
|
|
205
|
+
### `generateNavamsaChart(rasiChart)`
|
|
145
206
|
|
|
146
|
-
Generates
|
|
207
|
+
Generates the Navamsa (D-9) chart from an existing Rasi chart.
|
|
147
208
|
|
|
148
209
|
```typescript
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
showSignNumbers: true, // Show sign numbers
|
|
157
|
-
showDegrees: true, // Show planet degrees
|
|
158
|
-
customConfig: {
|
|
159
|
-
colors: {
|
|
160
|
-
background: '#FFFFFF',
|
|
161
|
-
border: '#422762',
|
|
162
|
-
innerLines: '#422762',
|
|
163
|
-
signNumber: '#422762',
|
|
164
|
-
text: '#1A1A2E',
|
|
165
|
-
retrograde: '#D63031',
|
|
166
|
-
}
|
|
167
|
-
}
|
|
210
|
+
import { generateRasiChart, generateNavamsaChart, Planet } from 'vedic-calc';
|
|
211
|
+
|
|
212
|
+
const rasi = generateRasiChart(date, lat, lon, tz);
|
|
213
|
+
const navamsa = generateNavamsaChart(rasi);
|
|
214
|
+
|
|
215
|
+
navamsa.planets.forEach(p => {
|
|
216
|
+
console.log(`${Planet[p.planet]}: Navamsa Sign ${p.navamsaSignName}, House ${p.navamsaHouse}`);
|
|
168
217
|
});
|
|
169
218
|
```
|
|
170
219
|
|
|
171
|
-
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### `generateNorthIndianChartSVG(chart, options?)`
|
|
172
223
|
|
|
173
|
-
Generates
|
|
224
|
+
Generates a **North Indian diamond-grid** style SVG chart.
|
|
174
225
|
|
|
175
226
|
```typescript
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
//
|
|
227
|
+
import { generateNorthIndianChartSVG } from 'vedic-calc';
|
|
228
|
+
|
|
229
|
+
const svg = generateNorthIndianChartSVG(rasi, {
|
|
230
|
+
showTable: true, // Show planet details table alongside the chart
|
|
231
|
+
layout: 'row', // 'row' (table beside chart) | 'column' (table below chart)
|
|
232
|
+
width: 400, // Chart width in px (default: 400)
|
|
233
|
+
height: 300, // Chart height in px (default: 300)
|
|
234
|
+
tableWidth: 520, // Width of the planet table (default: 520)
|
|
182
235
|
});
|
|
183
236
|
```
|
|
184
237
|
|
|
185
|
-
|
|
238
|
+
| Option | Type | Default | Description |
|
|
239
|
+
|--------------|---------------------|---------|-------------------------------|
|
|
240
|
+
| `showTable` | `boolean` | `true` | Show planet details table |
|
|
241
|
+
| `layout` | `'row' \| 'column'` | `'row'` | Table position relative to chart |
|
|
242
|
+
| `width` | `number` | `400` | Chart SVG width in pixels |
|
|
243
|
+
| `height` | `number` | `300` | Chart SVG height in pixels |
|
|
244
|
+
| `tableWidth` | `number` | `520` | Planet table width in pixels |
|
|
186
245
|
|
|
187
|
-
|
|
188
|
-
import { PREBUILT_THEMES } from 'vedic-calc';
|
|
246
|
+
**Returns:** `string` — a complete inline SVG string ready to embed in HTML or save as `.svg`.
|
|
189
247
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
### Constants & Enums
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import { Planet, Sign, NodeType, AyanamsaSystem } from 'vedic-calc';
|
|
254
|
+
|
|
255
|
+
// Planet enum
|
|
256
|
+
Planet.SUN // 0
|
|
257
|
+
Planet.MOON // 1
|
|
258
|
+
Planet.MARS // 2
|
|
259
|
+
Planet.MERCURY // 3
|
|
260
|
+
Planet.JUPITER // 4
|
|
261
|
+
Planet.VENUS // 5
|
|
262
|
+
Planet.SATURN // 6
|
|
263
|
+
Planet.RAHU // 7
|
|
264
|
+
Planet.KETU // 8
|
|
265
|
+
|
|
266
|
+
// Sign enum
|
|
267
|
+
Sign.ARIES // 0
|
|
268
|
+
Sign.TAURUS // 1
|
|
269
|
+
Sign.GEMINI // 2
|
|
270
|
+
Sign.CANCER // 3
|
|
271
|
+
Sign.LEO // 4
|
|
272
|
+
Sign.VIRGO // 5
|
|
273
|
+
Sign.LIBRA // 6
|
|
274
|
+
Sign.SCORPIO // 7
|
|
275
|
+
Sign.SAGITTARIUS // 8
|
|
276
|
+
Sign.CAPRICORN // 9
|
|
277
|
+
Sign.AQUARIUS // 10
|
|
278
|
+
Sign.PISCES // 11
|
|
279
|
+
|
|
280
|
+
// Node type for Rahu/Ketu
|
|
281
|
+
NodeType.TRUE_NODE // Precise astronomical position (default)
|
|
282
|
+
NodeType.MEAN_NODE // Smoothed/traditional position
|
|
283
|
+
|
|
284
|
+
// Ayanamsa systems
|
|
285
|
+
AyanamsaSystem.LAHIRI // Chitrapaksha — most popular in India (default)
|
|
286
|
+
AyanamsaSystem.RAMAN // Used in South India
|
|
287
|
+
AyanamsaSystem.KRISHNAMURTI // KP System
|
|
202
288
|
```
|
|
203
289
|
|
|
204
|
-
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## SVG Chart Options
|
|
293
|
+
|
|
294
|
+
The generated SVG uses a clean **North Indian diamond-grid** layout with a white background and deep purple borders — inspired by AstroSage's professional style.
|
|
295
|
+
|
|
296
|
+
### Default Color Scheme
|
|
205
297
|
|
|
206
298
|
```typescript
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
299
|
+
const colors = {
|
|
300
|
+
background: '#FFFFFF',
|
|
301
|
+
border: '#422762',
|
|
302
|
+
innerLines: '#422762',
|
|
303
|
+
signNumber: '#422762',
|
|
304
|
+
text: '#1A1A2E',
|
|
305
|
+
retrograde: '#D63031', // Red for retrograde planets
|
|
306
|
+
};
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Chart Layout Modes
|
|
310
|
+
|
|
311
|
+
**Row layout** (default) — table appears to the right of the chart:
|
|
312
|
+
```
|
|
313
|
+
+----------+ +-------------------------+
|
|
314
|
+
| Chart | | Planet Table |
|
|
315
|
+
+----------+ +-------------------------+
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Column layout** — table appears below the chart:
|
|
319
|
+
```
|
|
320
|
+
+----------+
|
|
321
|
+
| Chart |
|
|
322
|
+
+----------+
|
|
323
|
+
+--------------------------------------+
|
|
324
|
+
| Planet Table |
|
|
325
|
+
+--------------------------------------+
|
|
225
326
|
```
|
|
226
327
|
|
|
227
|
-
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Usage Examples
|
|
331
|
+
|
|
332
|
+
### 1. Basic Kundali
|
|
228
333
|
|
|
229
334
|
```typescript
|
|
230
|
-
import {
|
|
335
|
+
import { generateKundali, Planet } from 'vedic-calc';
|
|
336
|
+
|
|
337
|
+
const { rasi, navamsa } = generateKundali(
|
|
338
|
+
new Date('1995-10-15T06:30:00+05:30'),
|
|
339
|
+
28.6139, // New Delhi
|
|
340
|
+
77.2090,
|
|
341
|
+
'Asia/Kolkata'
|
|
342
|
+
);
|
|
231
343
|
|
|
232
|
-
//
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const longitude = 81.521240;
|
|
236
|
-
const timezone = 'Asia/Kolkata';
|
|
344
|
+
// Ascendant
|
|
345
|
+
console.log('Lagna:', rasi.ascendant.signName);
|
|
346
|
+
console.log('Lagna Nakshatra:', rasi.ascendant.nakshatra, 'Pada', rasi.ascendant.nakshatraPada);
|
|
237
347
|
|
|
238
|
-
//
|
|
239
|
-
const
|
|
240
|
-
|
|
348
|
+
// Moon sign (Rashi)
|
|
349
|
+
const moon = rasi.planets.find(p => p.planet === Planet.MOON)!;
|
|
350
|
+
console.log('Moon Sign (Rashi):', moon.signName);
|
|
351
|
+
console.log('Moon Nakshatra:', moon.nakshatra);
|
|
241
352
|
|
|
242
|
-
//
|
|
243
|
-
console.log('
|
|
353
|
+
// Navamsa Lagna
|
|
354
|
+
console.log('Navamsa Lagna:', navamsa.ascendantNavamsa.signName);
|
|
244
355
|
|
|
245
|
-
//
|
|
356
|
+
// Planets in each house
|
|
246
357
|
rasi.houses.forEach(house => {
|
|
247
|
-
|
|
358
|
+
if (house.planets.length > 0) {
|
|
359
|
+
const names = house.planets.map(p => Planet[p]).join(', ');
|
|
360
|
+
console.log(`House ${house.number} (${house.signName}): ${names} | Lord: ${house.lord}`);
|
|
361
|
+
}
|
|
248
362
|
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 2. Save SVG to File
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
import fs from 'fs';
|
|
371
|
+
import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
|
|
249
372
|
|
|
250
|
-
|
|
251
|
-
|
|
373
|
+
const chart = generateRasiChart(
|
|
374
|
+
new Date('1990-04-29T21:15:00+05:30'),
|
|
375
|
+
16.5449,
|
|
376
|
+
81.5212,
|
|
377
|
+
'Asia/Kolkata'
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
const svg = generateNorthIndianChartSVG(chart, {
|
|
252
381
|
showTable: true,
|
|
253
|
-
|
|
254
|
-
|
|
382
|
+
layout: 'column',
|
|
383
|
+
width: 500,
|
|
384
|
+
height: 400,
|
|
255
385
|
});
|
|
256
386
|
|
|
257
|
-
|
|
258
|
-
|
|
387
|
+
fs.writeFileSync('kundali.svg', svg);
|
|
388
|
+
console.log('Chart saved to kundali.svg');
|
|
259
389
|
```
|
|
260
390
|
|
|
261
|
-
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
### 3. Embed in HTML
|
|
262
394
|
|
|
263
395
|
```html
|
|
264
396
|
<!DOCTYPE html>
|
|
265
|
-
<html>
|
|
397
|
+
<html lang="en">
|
|
266
398
|
<head>
|
|
267
|
-
<
|
|
399
|
+
<meta charset="UTF-8">
|
|
400
|
+
<title>My Kundali</title>
|
|
268
401
|
<style>
|
|
269
|
-
body {
|
|
270
|
-
|
|
402
|
+
body {
|
|
403
|
+
font-family: sans-serif;
|
|
404
|
+
display: flex;
|
|
405
|
+
justify-content: center;
|
|
406
|
+
padding: 40px;
|
|
407
|
+
background: #f5f0ff;
|
|
408
|
+
}
|
|
409
|
+
.chart-container {
|
|
410
|
+
background: white;
|
|
411
|
+
border-radius: 16px;
|
|
412
|
+
padding: 24px;
|
|
413
|
+
box-shadow: 0 8px 32px rgba(66, 39, 98, 0.15);
|
|
414
|
+
}
|
|
271
415
|
</style>
|
|
272
416
|
</head>
|
|
273
417
|
<body>
|
|
274
|
-
<div class="chart">
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
418
|
+
<div class="chart-container" id="chart"></div>
|
|
419
|
+
|
|
420
|
+
<script type="module">
|
|
421
|
+
// If using a bundler (Vite, Webpack, etc.)
|
|
422
|
+
import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
|
|
423
|
+
|
|
424
|
+
const chart = generateRasiChart(
|
|
425
|
+
new Date('1990-04-29T21:15:00+05:30'),
|
|
426
|
+
16.5449, 81.5212, 'Asia/Kolkata'
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
document.getElementById('chart').innerHTML = generateNorthIndianChartSVG(chart, {
|
|
430
|
+
showTable: true,
|
|
431
|
+
width: 450,
|
|
432
|
+
height: 350,
|
|
433
|
+
});
|
|
280
434
|
</script>
|
|
281
435
|
</body>
|
|
282
436
|
</html>
|
|
283
437
|
```
|
|
284
438
|
|
|
285
|
-
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
### 4. Express.js API Endpoint
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
import express from 'express';
|
|
445
|
+
import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
|
|
446
|
+
|
|
447
|
+
const app = express();
|
|
448
|
+
app.use(express.json());
|
|
449
|
+
|
|
450
|
+
// POST /kundali — returns JSON chart data
|
|
451
|
+
app.post('/kundali', (req, res) => {
|
|
452
|
+
const { dateOfBirth, latitude, longitude, timezone } = req.body;
|
|
453
|
+
|
|
454
|
+
const chart = generateRasiChart(
|
|
455
|
+
new Date(dateOfBirth),
|
|
456
|
+
latitude,
|
|
457
|
+
longitude,
|
|
458
|
+
timezone
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
res.json({
|
|
462
|
+
ascendant: chart.ascendant,
|
|
463
|
+
planets: chart.planets,
|
|
464
|
+
houses: chart.houses,
|
|
465
|
+
ayanamsa: chart.ayanamsa,
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// GET /kundali/svg — returns SVG chart image
|
|
470
|
+
app.get('/kundali/svg', (req, res) => {
|
|
471
|
+
const { dob, lat, lon, tz } = req.query as Record<string, string>;
|
|
472
|
+
|
|
473
|
+
const chart = generateRasiChart(
|
|
474
|
+
new Date(dob),
|
|
475
|
+
parseFloat(lat),
|
|
476
|
+
parseFloat(lon),
|
|
477
|
+
tz
|
|
478
|
+
);
|
|
479
|
+
|
|
480
|
+
const svg = generateNorthIndianChartSVG(chart, { showTable: true });
|
|
481
|
+
|
|
482
|
+
res.setHeader('Content-Type', 'image/svg+xml');
|
|
483
|
+
res.send(svg);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
app.listen(3000, () => console.log('Server running on http://localhost:3000'));
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### 5. Next.js / React
|
|
492
|
+
|
|
493
|
+
```tsx
|
|
494
|
+
// app/api/chart/route.ts (Next.js App Router)
|
|
495
|
+
import { generateRasiChart, generateNorthIndianChartSVG } from 'vedic-calc';
|
|
496
|
+
import { NextResponse } from 'next/server';
|
|
497
|
+
|
|
498
|
+
export async function POST(request: Request) {
|
|
499
|
+
const { dateOfBirth, latitude, longitude, timezone } = await request.json();
|
|
500
|
+
|
|
501
|
+
const chart = generateRasiChart(
|
|
502
|
+
new Date(dateOfBirth),
|
|
503
|
+
latitude,
|
|
504
|
+
longitude,
|
|
505
|
+
timezone
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
const svg = generateNorthIndianChartSVG(chart, { showTable: true });
|
|
509
|
+
|
|
510
|
+
return NextResponse.json({ svg, ascendant: chart.ascendant, planets: chart.planets });
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
```tsx
|
|
515
|
+
// components/KundaliChart.tsx
|
|
516
|
+
'use client';
|
|
517
|
+
|
|
518
|
+
export function KundaliChart({ svg }: { svg: string }) {
|
|
519
|
+
return (
|
|
520
|
+
<div
|
|
521
|
+
className="kundali-chart"
|
|
522
|
+
dangerouslySetInnerHTML={{ __html: svg }}
|
|
523
|
+
/>
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
286
529
|
|
|
287
|
-
|
|
288
|
-
|----------|-------------|
|
|
289
|
-
| `generateRasiChart(date, lat, lon, tz)` | Generate Rasi (D-1) birth chart |
|
|
290
|
-
| `generateNavamsaChart(rasiChart)` | Generate Navamsa (D-9) chart |
|
|
291
|
-
| `generateNorthIndianChartSVG(chart, options)` | North Indian style SVG |
|
|
292
|
-
| `generateSouthIndianChartSVG(chart, options)` | South Indian style SVG |
|
|
293
|
-
| `calculateNavamsaSign(longitude)` | Calculate Navamsa sign for longitude |
|
|
294
|
-
| `getAyanamsa(jd, system)` | Get ayanamsa value |
|
|
295
|
-
| `calculateHouseCusps(jd, lat, lon, system)` | Calculate house cusps |
|
|
530
|
+
## TypeScript Types
|
|
296
531
|
|
|
297
|
-
|
|
532
|
+
```typescript
|
|
533
|
+
interface RasiChart {
|
|
534
|
+
birthData: {
|
|
535
|
+
date: Date;
|
|
536
|
+
latitude: number;
|
|
537
|
+
longitude: number;
|
|
538
|
+
timezone: string;
|
|
539
|
+
};
|
|
540
|
+
ascendant: {
|
|
541
|
+
degree: number; // Sidereal degree (0-360)
|
|
542
|
+
sign: Sign; // Sign enum value (0-11)
|
|
543
|
+
signName: string; // e.g. "Virgo"
|
|
544
|
+
nakshatra: string; // e.g. "Hasta"
|
|
545
|
+
nakshatraPada: number; // 1-4
|
|
546
|
+
};
|
|
547
|
+
planets: PlanetData[];
|
|
548
|
+
houses: {
|
|
549
|
+
number: number; // 1-12
|
|
550
|
+
sign: Sign;
|
|
551
|
+
signName: string;
|
|
552
|
+
lord: string; // e.g. "Mercury"
|
|
553
|
+
planets: Planet[]; // Planets in this house
|
|
554
|
+
cuspStart: number; // Start degree (0-360)
|
|
555
|
+
cuspEnd: number; // End degree (0-360)
|
|
556
|
+
}[];
|
|
557
|
+
ayanamsa: number; // Lahiri ayanamsa value used
|
|
558
|
+
}
|
|
298
559
|
|
|
299
|
-
|
|
300
|
-
|
|
560
|
+
interface PlanetData {
|
|
561
|
+
planet: Planet;
|
|
562
|
+
longitude: number; // Sidereal longitude (0-360)
|
|
563
|
+
sign: Sign;
|
|
564
|
+
signName: string;
|
|
565
|
+
degreeInSign: number; // Degree within the sign (0-30)
|
|
566
|
+
nakshatra: string;
|
|
567
|
+
nakshatraPada: number; // 1-4
|
|
568
|
+
nakshatraLord: string; // e.g. "Moon"
|
|
569
|
+
house: number; // 1-12
|
|
570
|
+
isRetrograde: boolean;
|
|
571
|
+
}
|
|
301
572
|
|
|
302
|
-
|
|
573
|
+
interface NavamsaChart {
|
|
574
|
+
planets: {
|
|
575
|
+
planet: Planet;
|
|
576
|
+
navamsaSign: Sign;
|
|
577
|
+
navamsaSignName: string;
|
|
578
|
+
navamsaHouse: number; // 1-12
|
|
579
|
+
longitude: number;
|
|
580
|
+
}[];
|
|
581
|
+
ascendantNavamsa: {
|
|
582
|
+
sign: Sign;
|
|
583
|
+
signName: string;
|
|
584
|
+
longitude: number;
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
```
|
|
303
588
|
|
|
304
|
-
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## Roadmap
|
|
592
|
+
|
|
593
|
+
We are actively building **vedic-calc** into the most complete Vedic astrology SDK for JavaScript/TypeScript. Here is what is coming:
|
|
594
|
+
|
|
595
|
+
### v1.1 — More Divisional Charts
|
|
596
|
+
- [ ] **D-3 (Drekkana)** — siblings, courage
|
|
597
|
+
- [ ] **D-4 (Chaturthamsa)** — property, fortune
|
|
598
|
+
- [ ] **D-7 (Saptamsa)** — children
|
|
599
|
+
- [ ] **D-10 (Dasamsa)** — career & profession
|
|
600
|
+
- [ ] **D-12 (Dwadasamsa)** — parents
|
|
601
|
+
- [ ] **D-16 (Shodasamsa)** — vehicles & comforts
|
|
602
|
+
- [ ] **D-20 (Vimsamsa)** — spiritual progress
|
|
603
|
+
- [ ] **D-24 (Chaturvimsamsa)** — education
|
|
604
|
+
- [ ] **D-27 (Saptavimsamsa)** — strength & weakness
|
|
605
|
+
- [ ] **D-30 (Trimsamsa)** — misfortune & health
|
|
606
|
+
- [ ] **D-60 (Shashtiamsa)** — past life karma
|
|
607
|
+
|
|
608
|
+
### v1.2 — Dasha Systems
|
|
609
|
+
- [ ] **Vimshottari Dasha** — the most widely used 120-year dasha system
|
|
610
|
+
- [ ] **Antardasha (Bhukti)** — sub-periods within each Mahadasha
|
|
611
|
+
- [ ] **Pratyantardasha** — sub-sub-periods
|
|
612
|
+
- [ ] **Yogini Dasha** — 36-year cycle dasha system
|
|
613
|
+
- [ ] **Ashtottari Dasha** — 108-year dasha system
|
|
614
|
+
|
|
615
|
+
### v1.3 — Yogas & Planetary Combinations
|
|
616
|
+
- [ ] **Raj Yogas** — combinations for power and success
|
|
617
|
+
- [ ] **Dhana Yogas** — wealth combinations
|
|
618
|
+
- [ ] **Pancha Mahapurusha Yogas** — Ruchaka, Bhadra, Hamsa, Malavya, Sasa
|
|
619
|
+
- [ ] **Kemadruma Yoga** — Moon without support
|
|
620
|
+
- [ ] **Gaja Kesari Yoga** — Jupiter-Moon combination
|
|
621
|
+
- [ ] **Neecha Bhanga Raj Yoga** — cancellation of debilitation
|
|
622
|
+
- [ ] **100+ classical yoga detection**
|
|
623
|
+
|
|
624
|
+
### v1.4 — Strength & Shadbala
|
|
625
|
+
- [ ] **Shadbala** — six-fold planetary strength calculation
|
|
626
|
+
- [ ] **Sthana Bala** — positional strength
|
|
627
|
+
- [ ] **Dig Bala** — directional strength
|
|
628
|
+
- [ ] **Kala Bala** — temporal strength
|
|
629
|
+
- [ ] **Chesta Bala** — motional strength
|
|
630
|
+
- [ ] **Naisargika Bala** — natural strength
|
|
631
|
+
- [ ] **Drik Bala** — aspectual strength
|
|
632
|
+
- [ ] **Bhava Bala** — house strength
|
|
633
|
+
|
|
634
|
+
### v1.5 — Transits & Predictions
|
|
635
|
+
- [ ] **Gochar (Transits)** — current planetary positions over natal chart
|
|
636
|
+
- [ ] **Sade Sati** — Saturn's 7.5-year transit over Moon
|
|
637
|
+
- [ ] **Ashtama Shani** — Saturn in 8th from Moon
|
|
638
|
+
- [ ] **Transit predictions** — planet-over-planet analysis
|
|
639
|
+
|
|
640
|
+
### v1.6 — Compatibility (Kundali Milan)
|
|
641
|
+
- [ ] **Ashtakoot Milan** — 8-factor compatibility scoring (36 points)
|
|
642
|
+
- [ ] **Guna Milan** — Varna, Vashya, Tara, Yoni, Graha Maitri, Gana, Bhakoot, Nadi
|
|
643
|
+
- [ ] **Mangal Dosha** — Mars affliction check
|
|
644
|
+
- [ ] **Nadi Dosha** — Nadi incompatibility check
|
|
645
|
+
|
|
646
|
+
### v1.7 — Chart Rendering Enhancements
|
|
647
|
+
- [ ] **South Indian chart style** — 3x4 grid layout
|
|
648
|
+
- [ ] **East Indian chart style** — square grid layout
|
|
649
|
+
- [ ] **Custom color themes** — dark, ocean, forest, golden presets
|
|
650
|
+
- [ ] **Aspect lines** — draw planetary aspects on chart
|
|
651
|
+
- [ ] **PNG/PDF export** — via canvas or puppeteer integration
|
|
652
|
+
|
|
653
|
+
### v2.0 — Advanced Features
|
|
654
|
+
- [ ] **Muhurta (Electional Astrology)** — find auspicious times
|
|
655
|
+
- [ ] **Prashna (Horary Astrology)** — answer questions from current chart
|
|
656
|
+
- [ ] **Ashtakavarga** — 8-source strength system
|
|
657
|
+
- [ ] **Sarvashtakavarga** — combined strength table
|
|
658
|
+
- [ ] **Panchanga** — Tithi, Vara, Nakshatra, Yoga, Karana
|
|
659
|
+
- [ ] **Hora Chart** — hourly planetary ruler
|
|
660
|
+
- [ ] **Lagna variations** — Chandra Lagna, Surya Lagna, Arudha Lagna
|
|
661
|
+
- [ ] **Browser/ESM build** — for direct use in browsers without bundler
|
|
662
|
+
|
|
663
|
+
---
|
|
664
|
+
|
|
665
|
+
## Contributing
|
|
666
|
+
|
|
667
|
+
Contributions are welcome. Whether it is a bug fix, new feature, or documentation improvement:
|
|
668
|
+
|
|
669
|
+
1. Fork the repository
|
|
670
|
+
2. Create your feature branch: `git checkout -b feature/vimshottari-dasha`
|
|
671
|
+
3. Commit your changes: `git commit -m 'feat: add Vimshottari Dasha calculation'`
|
|
672
|
+
4. Push to the branch: `git push origin feature/vimshottari-dasha`
|
|
673
|
+
5. Open a Pull Request
|
|
674
|
+
|
|
675
|
+
Please check the [open issues](https://github.com/jatingodnani/vedic-calc/issues) before starting work on a new feature.
|
|
676
|
+
|
|
677
|
+
---
|
|
678
|
+
|
|
679
|
+
## Resources
|
|
680
|
+
|
|
681
|
+
- [Swiss Ephemeris](https://www.astro.com/swisseph/) — The astronomical engine powering this library
|
|
682
|
+
- [Vedic Astrology Basics](https://www.vedicastrology.us.com/) — Learn Jyotish fundamentals
|
|
683
|
+
- [AstroSage](https://www.astrosage.com/) — Reference for chart calculations
|
|
684
|
+
|
|
685
|
+
---
|
|
305
686
|
|
|
306
687
|
## License
|
|
307
688
|
|
|
308
|
-
MIT
|
|
689
|
+
[MIT](LICENSE)
|
|
690
|
+
|
|
691
|
+
---
|
|
309
692
|
|
|
310
|
-
|
|
693
|
+
<div align="center">
|
|
311
694
|
|
|
312
|
-
vedic
|
|
695
|
+
If vedic-calc helped you, please star the repo on GitHub — it helps others discover it.
|
|
313
696
|
|
|
314
|
-
|
|
697
|
+
[](https://github.com/jatingodnani/vedic-calc)
|
|
698
|
+
[](https://www.npmjs.com/package/vedic-calc)
|
|
315
699
|
|
|
316
|
-
|
|
317
|
-
- [AstroSage](https://www.astro.com/) - Online astrology calculations reference
|
|
318
|
-
- [Vedic Rishi](https://www.vedicrishi.com/) - Vedic astrology reference
|
|
700
|
+
</div>
|