Pie chart: Gods


This chart is generated from the data returned by the /rv/v3/mandal/{n}/sungfor endpoint.

To see a larger image, click the image.

pie chart of gods in rig veda


On this page


What this chart shows

At first glance, the following things stand out immediately:

From this chart, one might be inclined to think rituals (Agni, Soma) matter as much as gods (Indra) and that the central religious theme is situational (objects are gods) rather than god-centered.

What to explore next

Endpoint to use for this pie chart

Fetch, and save, the results for all mandals one by one by using /mandal/{n}/sungfor.

{
  "mandal": 3,
  "sungfor": {
    "Aditi": 1,
    "Aditya": 4,
    "Agni": 43,
...
}

Algorithm

Aggregates category counts across multiple source collections, ranks them by frequency, and progressively decomposes low-frequency categories into successive levels of detail by using a cascade of pie charts. A 3-level hierarchical visualisation is created.

  1. Primary chart: Top categories + aggregated remainder
  2. Secondary chart: Breakdown of the remainder above a second threshold
  3. Tertiary chart: Further breakdown of the secondary remainder above a third threshold

Prerequisites

Procedure

  1. Aggregate the counts across all collections.
    1. Initialise an empty map: total_counts
    2. For each collection:
      • For each (category, count) pair:
        • Add the count to total_counts[category].
  2. Sort the categories by descending frequency, to establish a ranking from the most frequent to the least frequent.
    1. Convert total_counts into a list of (category, count) pairs.
    2. Sort by count in descending order.
  3. Compute the grand total.
  4. Make the first-level grouping (Figure 1):
    1. Select the primary categories.
    2. Initialise main_labels, main_values, others_labels, others_values.
    3. For each sorted category, calculate percentage = count / grand_total × 100.
    4. Include in the main chart only if:
      • It is within the top N ranked categories.
      • Its percentage is greater than or equal to the minimum percentage threshold.
      • Otherwise move it into the Others group.
    5. Create first remainder bucket:
      1. Sum all deferred categories: others_total = sum(others_values)
      2. Append "Others" (others_total) to the main chart.
  5. Make the second-level grouping (Figure 2a):
    1. Break down the first remainder:
      1. Take all categories in Others.
      2. Initialise second_labels, second_values, others2_labels, others2_values.
      3. For each category:
        • If count ≥ second-level threshold, include in the second chart.
        • Otherwise, move it into Others2.
    2. Create the second remainder bucket:
      1. Sum the deferred values: others2_total = sum(others2_values)
      2. If non-zero: append "Others2".
  6. Make the third-level grouping (Figure 2b):
    1. Break down the second remainder:
      1. Take all categories in Others2.
      2. Initialise third_labels, third_values, others3_labels, others3_values.
      3. For each category:
        • If count ≥ third-level threshold, include in the third chart.
        • Otherwise, move it into Others3.
    2. Create the third remainder bucket:
      1. Sum the deferred values: others3_total = sum(others3_values).
      2. If non-zero: append "Others3".
  7. Render the charts:
    1. Create a multi-panel layout containing:
      • One large left panel for Figure 1.
      • Two smaller stacked right panels for Figures 2a and 2b.
    2. From the metadata, render the header (title) and footer.
    3. Render each pie chart. For each chart:
      1. Assign colours cyclically.
      2. Draw pie slices proportionally.
      3. Apply border styling.
      4. Add chart title.
    4. Place the labels. For each slice:
      1. If the slice is large, place the label inside the slice.
      2. If the slice is small, place the label outside the slice and connect it with a leader line.
    5. Generate the legends. For each chart, create a legend showing the category name, raw count, and, for the main chart, percentage.
  8. Draw a border frame around the full visualisation area, flush to the edges.
  9. Export the output. Save the rendered chart as an image file with high resolution.

Pseudocode

function generateHierarchicalPieCharts(collections):

    total_counts = empty map

    # Aggregate all counts
    for each collection in collections:
        for each (category, count) in collection:
            total_counts[category] += count

    # Sort descending
    sorted_counts = sort total_counts by count descending

    grand_total = sum(all counts)

    --------------------------------------------------
    # LEVEL 1
    --------------------------------------------------

    main = []
    others = []

    for each ranked (category, count):
        percentage = count / grand_total * 100

        if rank < TOP_N and percentage >= MIN_PERCENT:
            main.append(category, count)
        else:
            others.append(category, count)

    main.append("Others", sum(others))

    --------------------------------------------------
    # LEVEL 2
    --------------------------------------------------

    second = []
    others2 = []

    for each (category, count) in others:
        if count >= SECOND_LEVEL_MIN_COUNT:
            second.append(category, count)
        else:
            others2.append(category, count)

    if others2 is not empty:
        second.append("Others2", sum(others2))

    --------------------------------------------------
    # LEVEL 3
    --------------------------------------------------

    third = []
    others3 = []

    for each (category, count) in others2:
        if count >= THIRD_LEVEL_MIN_COUNT:
            third.append(category, count)
        else:
            others3.append(category, count)

    if others3 is not empty:
        third.append("Others3", sum(others3))

    --------------------------------------------------
    # VISUALISATION
    --------------------------------------------------

    create canvas with 3-panel layout

    add global title
    add footer

    render pie chart for main
    render pie chart for second
    render pie chart for third

    for each chart:
        assign colours
        place labels
        add legends

    draw outer frame

    save image

Related