← Recipes

Draw a Western natal chart wheel in SVG

A natal wheel is polar coordinates with one twist: the ascendant, not 0° Aries, sits at the left. Get that rotation right once and every planet, cusp and aspect line falls into place.

You build
An SVG wheel: 12 cusps, 13 bodies and the aspect web, from two parallel calls
Code
Node.js - no SDK, runnable as shown

Updated

Two calls

POST /v1/western/natal/chart returns tropical planets with ecliptic longitude (0-360), twelve house cusps with cusp_longitude, and the ascendant and midheaven. It does not include aspects; POST /v1/western/natal/aspects does, as from / to / aspect / orb, including aspects to ASC and MC. Both take the same body, so send them together. Excerpt for 15 Jul 1990, 14:30 BST, London:

json
{
  "ascendant": {
    "longitude": 211.96813086625957,
    "sign": "Scorpio",
    "degree": 1.9681308662595711
  },
  "midheaven": {
    "longitude": 133.04877551114896,
    "sign": "Leo",
    "degree": 13.04877551114896
  },
  "planets": [
    {
      "planet": "Sun",
      "longitude": 112.80577712210936,
      "latitude": 0.0001745672823859288,
      "sign": "Cancer",
      "degree_in_sign": 22.80577712210936,
      "retrograde": false,
      "house": 9
    },
    "… 12 more"
  ],
  "houses": [
    {
      "house": 1,
      "cusp_longitude": 211.96813086625957,
      "sign": "Scorpio",
      "degree_in_sign": 1.9681308662595711
    },
    "… 11 more"
  ],
  "meta": {
    "zodiac": "tropical",
    "house_system": "placidus",
    "aspect_set": "ptolemaic",
    "orb_set": "standard",
    "engine_version": "1.2.1"
  }
}

The default house system is Placidus; send house_system (koch, equal, whole-sign, porphyry) to change it. Placidus cusps are unequal, which is why the wheel must use cusp_longitude rather than 30° steps.

The rotation

Put the ascendant at 180° (9 o'clock) and let longitude increase counter-clockwise: screen angle = 180° + longitude − ascendant. SVG's y axis points down, so subtract the sine. That one function places everything:

natal-wheel.mjs

Node.js
// natal-wheel.mjs - node natal-wheel.mjs > wheel.svg
const API = process.env.ASTRONODE_API_URL ?? "https://api.astronode.dev";
const KEY = process.env.ASTRONODE_API_KEY;

const post = async (path, body) => {
  const res = await fetch(API + path, {
    method: "POST",
    headers: { authorization: `Bearer ${KEY}`, "content-type": "application/json" },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`${path} ${res.status}`);
  return (await res.json()).data;
};

const birth = { date: "1990-07-15", time: "14:30:00", tz_offset_minutes: 60, lat: 51.5074, lng: -0.1278 };
const [chart, { aspects }] = await Promise.all([
  post("/v1/western/natal/chart", birth), // planets + Placidus cusps + Asc/MC
  post("/v1/western/natal/aspects", birth), // the lines across the middle
]);

// Ascendant at 9 o'clock, zodiac running counter-clockwise. SVG's y axis points down.
const C = 250;
const asc = chart.ascendant.longitude;
const at = (lon, r) => {
  const a = ((180 + lon - asc) * Math.PI) / 180;
  return [+(C + r * Math.cos(a)).toFixed(1), +(C - r * Math.sin(a)).toFixed(1)];
};

const lon = Object.fromEntries(chart.planets.map((p) => [p.planet, p.longitude]));
lon.ASC = asc;
lon.MC = chart.midheaven.longitude;

const svg = [`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">`,
  `<circle cx="${C}" cy="${C}" r="230" fill="none" stroke="#999"/>`,
  `<circle cx="${C}" cy="${C}" r="120" fill="none" stroke="#999"/>`];
for (const h of chart.houses) { // cusp lines
  const [x1, y1] = at(h.cusp_longitude, 120), [x2, y2] = at(h.cusp_longitude, 230);
  svg.push(`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${h.house % 3 === 1 ? "#000" : "#bbb"}"/>`);
}
for (const p of chart.planets) {
  const [x, y] = at(p.longitude, 195);
  svg.push(`<text x="${x}" y="${y}" font-size="11" text-anchor="middle">${p.planet.slice(0, 2)}${p.retrograde ? "R" : ""}</text>`);
}
const majors = aspects.filter((a) => ["conjunction", "opposition", "trine", "square", "sextile"].includes(a.aspect) && a.from in lon && a.to in lon);
for (const a of majors) {
  const [x1, y1] = at(lon[a.from], 118), [x2, y2] = at(lon[a.to], 118);
  svg.push(`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${["square", "opposition"].includes(a.aspect) ? "#c33" : "#36c"}" stroke-width="0.8"/>`);
}
svg.push("</svg>");
console.log(svg.join("\n"));

console.error(`asc ${chart.ascendant.sign} ${chart.ascendant.degree.toFixed(2)} at ${at(asc, 230)}, mc ${chart.midheaven.sign} at ${at(lon.MC, 230)}`);
console.error(`sun ${lon.Sun.toFixed(2)} at ${at(lon.Sun, 195)}; ${chart.planets.length} bodies, ${chart.houses.length} cusps (${chart.meta.house_system}), ${majors.length} of ${aspects.length} aspects drawn`);

stderr:

text
asc Scorpio 1.97 at 20,250, mc Leo at 205.8,24.3
sun 112.81 at 281.1,57.5; 13 bodies, 12 cusps (placidus), 35 of 35 aspects drawn

Sanity checks from that output: the ascendant lands exactly at the left edge (20, 250); the midheaven (Leo 13°) is near the top; the Sun in Cancer, in the 9th house, sits upper-right of centre. If your MC comes out at the bottom, the sign of the sine is flipped.

Finishing the drawing

  • Collisions. Planets within ~5° overlap (Sun and Jupiter here are 0.24° apart). Sort by longitude and nudge labels outward or sideways, keeping a short tick at the true position.
  • Bodies you may not want. The response includes Chiron, TrueNode and SouthNode next to the ten planets; filter by name for a classic ten-planet wheel.
  • Sign ring. Add a band between the outer circle and the cusps with twelve 30° segments, each starting at at(i * 30, r); it rotates with the ascendant like everything else.
  • Aspect styling. The sample colours squares and oppositions red and the rest blue; orb is in the response if you want opacity to fall off with orb.
  • Glyphs. Unicode astrological symbols (U+2609 and up) render inconsistently across fonts; ship an SVG symbol set for production.

For a Vedic chart the shape is a grid or diamond, not a wheel - see North or South Indian chart. Western and Vedic positions differ by the ayanamsa (about 24° today); the ayanamsa guide explains why.

Questions

What do I end up with?
An SVG wheel: 12 cusps, 13 bodies and the aspect web, from two parallel calls. The code is in Node.js.
Which endpoints does this recipe call, and in what order?
2 endpoints, in this order: Western Natal Chart (POST /v1/western/natal/chart), then Western Natal Aspects (POST /v1/western/natal/aspects).