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.
On this page
What this chart shows
At first glance, the following things stand out immediately:
- Indra dominates.
- Agni is almost as important as Indra.
- There’s a huge
Otherscategory. So huge, in fact, that the long tail gets exploded into two smaller charts, and still ends up with a largeOtherscategory. - Soma, a drink, is at #3.
- Vishnu and Rudra rank lower (they appear only in Figure 2a) than the Ashwini twins, who’re very visible in Figure 1.
- The third chart (Figure 2b) is full of things that feel strange as objects of hymns. Subandhu’s spirit?!
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
- Why do some gods dominate? Fetch all hymns for a specific deity (use the
/sungfor/...series of endpoints). See whether they cluster in any mandals (use themandals/{n}/sungforendpoint). See whether those mandals are dominated by any poet family (use the/sungby/...series of endpoints, and look for patronymic names). - Who are the gods that make up such a long tail, such small slices that each contribute very little to the total on their own but, collectively, are 27% of the corpus where the #1 rankholder is 17%? Minor gods, abstract forces, ancestors, or ritual objects?
- Why are objects such as doors and grass, gods? Do they have entire suktas to themselves alone, or do they share the honours with others (use the
mandal-suktacombinations in the expanded response to the/sungfor/...series of endpoints)? - What about pairings? Are some gods always invoked solo or do they always appear along with other specific gods? If they are often paired or grouped, who are these other gods they are invoked along with (use the
mandal-suktacombinations in the expanded response to the/sungfor/...series of endpoints)?
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.
- Primary chart: Top categories + aggregated remainder
- Secondary chart: Breakdown of the remainder above a second threshold
- Tertiary chart: Further breakdown of the secondary remainder above a third threshold
Prerequisites
- Collections: A list of grouped datasets, where each set contains category to count mappings.
- Top
N: Maximum number of categories shown in the first chart - Minimum percentage: Minimum share required for inclusion in the first chart
- Second-level minimum count: Threshold for inclusion in the second chart
- Third-level minimum count: Threshold for inclusion in the third chart
- Colour palette: List of display colours
- Chart metadata:
- Header text
- Footer text
- Background and frame styling
Procedure
- Aggregate the counts across all collections.
- Initialise an empty map:
total_counts - For each collection:
- For each
(category, count)pair:- Add the count to
total_counts[category].
- Add the count to
- For each
- Initialise an empty map:
- Sort the categories by descending frequency, to establish a ranking from the most frequent to the least frequent.
- Convert
total_countsinto a list of(category, count)pairs. - Sort by count in descending order.
- Convert
- Compute the grand total.
- Make the first-level grouping (Figure 1):
- Select the primary categories.
- Initialise
main_labels,main_values,others_labels,others_values. - For each sorted category, calculate
percentage = count / grand_total × 100. - Include in the main chart only if:
- It is within the top
Nranked categories. - Its percentage is greater than or equal to the minimum percentage threshold.
- Otherwise move it into the
Othersgroup.
- It is within the top
- Create first remainder bucket:
- Sum all deferred categories:
others_total = sum(others_values) - Append
"Others"(others_total) to the main chart.
- Sum all deferred categories:
- Make the second-level grouping (Figure 2a):
- Break down the first remainder:
- Take all categories in
Others. - Initialise
second_labels,second_values,others2_labels,others2_values. - For each category:
- If count ≥ second-level threshold, include in the second chart.
- Otherwise, move it into
Others2.
- Take all categories in
- Create the second remainder bucket:
- Sum the deferred values:
others2_total = sum(others2_values) - If non-zero:
append "Others2".
- Sum the deferred values:
- Break down the first remainder:
- Make the third-level grouping (Figure 2b):
- Break down the second remainder:
- Take all categories in
Others2. - Initialise
third_labels,third_values,others3_labels,others3_values. - For each category:
- If count ≥ third-level threshold, include in the third chart.
- Otherwise, move it into
Others3.
- Take all categories in
- Create the third remainder bucket:
- Sum the deferred values:
others3_total = sum(others3_values). - If non-zero:
append "Others3".
- Sum the deferred values:
- Break down the second remainder:
- Render the charts:
- Create a multi-panel layout containing:
- One large left panel for Figure 1.
- Two smaller stacked right panels for Figures 2a and 2b.
- From the metadata, render the header (title) and footer.
- Render each pie chart. For each chart:
- Assign colours cyclically.
- Draw pie slices proportionally.
- Apply border styling.
- Add chart title.
- Place the labels. For each slice:
- If the slice is large, place the label inside the slice.
- If the slice is small, place the label outside the slice and connect it with a leader line.
- Generate the legends. For each chart, create a legend showing the category name, raw count, and, for the main chart, percentage.
- Create a multi-panel layout containing:
- Draw a border frame around the full visualisation area, flush to the edges.
- 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
