An interactive D3.js force-directed network that visualizes how India's constitutional actors, courts, tribunals, professional bodies, and citizens connect through appointments, funding, oversight, and operational relationships. This repository powers the d3lem experience shown in index.html.
🌐 Live Version: https://friedso.com/apps/d3lem/
- Clone or download the repository.
- Open
index.htmlin any modern desktop browser (Chrome, Edge, Firefox, Safari). - Use the on-page controls:
- Drag nodes to isolate clusters—only directly connected nodes move with the one you drag.
- Hover to highlight a node’s inbound/outbound connections plus tooltip labels.
- Filter by entity, relationship type, or entity/relationship group to reduce clutter.
- Toggle views (arrow map ↔ table) with the “Show Table View” button.
- Edit/Export: unlock edits with the password prompt (configure via
access-control.local.js→applyAccessControlOverrides) and download the current data to Excel from the table view.
- Copy
access-control.local.example.jstoaccess-control.local.js. - Replace the placeholder password/IP settings with your real values.
- The new file is already listed in
.gitignore, so your credentials never end up in a commit or on GitHub. - When deploying, ship your
access-control.local.jsalongside the rest of the static assets so the browser can load the overrides at runtime.
| File | Purpose |
|---|---|
index.html |
Application shell, instructions card, modal containers, and script includes |
style.css |
All scoped styles for the visualization, table view, modals, filters, and footer |
data.js |
Data source: groupingData, relationshipGroupingData, judicialEntityMapData, and visualization config/accessControlConfig |
helpers.js |
Utility functions shared by the visualization (dedupe nodes, link generation, label helpers) |
network-diagram.js |
Core D3 logic (LegalSystemVisualization class) covering simulations, forces, link paths, label optimization, grouping, and edit hooks |
main.js |
Bootstraps the experience, wires DOM controls to visualization methods, handles filters, view switching, orientation guard, and password gating |
embed.js / embed.html |
Lightweight embed script and demo markup |
- Diagram view (default): force-directed layout constrained to an ellipse for readability. Nodes interpolate to valid positions before the simulation starts, then continue to settle while remaining draggable.
- Hover highlight: outlines the focused node, fades unrelated nodes/links, and displays relationship labels along the relevant arrows.
- Filter toolkit:
- Entity filter: isolates a single actor and its direct edges.
- Relationship filter: shows only relationships that match a label (e.g., “appoints”, “funds”).
- Group filter: switch between entity clusters (Judiciary, Legislative & Regulatory, etc.) or relationship groupings (Funding, Oversights, Appointments, Governance, Accountability, Establishment, Operations, Hierarchy, Directives).
- Table view: presents the same dataset in tabular form for quick scanning, editing, or export. The table honors active filters.
- Editing workflow (optional): click Edit Table, enter the access password defined in your local
access-control.local.js, and use the inline controls to modify relationships. Changes stay in memory until saved/exported.
| Group key | Description | Hex |
|---|---|---|
:LegislativeAndRegulatory |
Parliament, ministries, commissions | #2E8B57 (Sea Green) |
:Judiciary |
Courts, judges, registries | #4169E1 (Royal Blue) |
:TribunalsAndArbitration |
Tribunals, arbitration ecosystem | #FF6347 (Tomato) |
:PeopleAndOfficeholders |
Staff, legal professionals, citizens | #9370DB (Medium Purple) |
:NonAdministrativeEntities |
Appointment bodies, oversight boards | #DAA520 (Goldenrod) |
Each node inherits its ring color from this mapping. Links default to the source entity’s group color unless a relationship group override applies.
Funding #4CAF50, Oversights #FF9800, Appointments #2196F3, Governance #9C27B0, Accountability #F44336, Establishment #00BCD4, Operations #FFC107, Hierarchy #795548, Directives #E91E63.
When a relationship label appears in relationshipGroupingData, its arrow uses the palette above, enabling quick scanning of the dominant action type.
Arrowheads still communicate flow from source → target, but color is now semantic (group/action) rather than the previous “blue = outgoing / red = incoming” system, so any documentation or UI copy should refer to the palettes above.
groupingData: per-entity metadata (node,label,belongsTokeys) used for node coloring and legend building.relationshipGroupingData: maps relationship labels (e.g., “appoints”, “funds”) to the high-level groupings listed earlier.judicialEntityMapData: the primary edge list. Each object includessource,target,label,count, and optionalisProcessFlowflag for dotted connectors.config: width/height, node radius, force settings, and overall simulation behavior.colorMap: retained for backwards compatibility (used when exporting simple data-only bundles) but arrows in the UI now derive their colors fromgroupColors/relationshipGroupColors.accessControlConfig: password + IP whitelist toggle for enabling edit mode on shared deployments. The repository ships with an empty password; configure yours viaaccess-control.local.js(gitignored) or on your hosting environment before going live.
To add/modify nodes or relationships, update data.js and reload the page. No build step is required.
“Subordinate Court” appears as a single aggregate node. India’s district and taluka courts span thousands of institutions; rendering each court individually would overwhelm the force layout and degrade readability. A dedicated visualization with drill-down capability and geographic/contextual layers is recommended for that hierarchy.
- Large additions to
judicialEntityMapDatamay require tuningconfig.chargeStrength,linkDistance, or the ellipse bounds innetwork-diagram.js → ticked()to maintain spacing. - Edit mode currently operates in-memory; persist changes by exporting to Excel and re-generating
data.js(or piping the edited JSON into your preferred backend).
- Layout: tweak
configindata.js(width, height, forces) to suit different canvases or host pages. - Color system: adjust
this.groupColors/this.relationshipGroupColorsinsidenetwork-diagram.jsto align with your branding, then update the legend styles instyle.css. - Embedding: use
embed.jswith the provided example inembed.htmlto drop the visualization into other sites while honoring read-only mode. - Data regeneration: run
convert_excel_to_data.pyif you need to regeneratedata.jsfrom the original Excel workbook. Pandas + openpyxl are auto-installed by the script.
- D3.js v7 for force simulation, interaction handling, SVG rendering.
- Vanilla JavaScript modules for application orchestration and table tooling.
- SheetJS (xlsx) for client-side Excel export from the table view.
- No external build tooling; everything runs directly in the browser.
MIT License. See LICENSE for the full text.