How to Create Charts from Open Government Data

Quick summary: On any API-enabled resource page in Data Khoj, switch to Chart Analysis to build interactive 2D and 3D charts powered by Three.js. Accurate charting depends on matching field types to the right chart, choosing an appropriate aggregation, and verifying whether you are charting the current page or all matching records.
Editorial note: Data Khoj is an independent platform that indexes live metadata from data.gov.in. It is not affiliated with or endorsed by the Government of India.
Decision matrix mapping field types (category, date, numeric, multi-dimensional) to supported 2D and 3D chart types
Figure 1: Matching inferred field types to suitable chart types in the Chart Analysis workspace.

Choosing X-Axis, Y-Axis, and Aggregation

Data Khoj inspects the live records of your selected resource and infers whether each column is Numeric, Date/Time, Category, or Boolean. If a column has mixed values, you can override its type manually in the configuration panel.

  • Time series (Date + Numeric): Use Line or Area charts sorted chronologically.
  • Category comparisons (Category + Numeric): Use Column, Bar, Grouped Bar, or Stacked Bar charts.
  • Distributions & correlations: Use Histogram (1 numeric field), Scatter (2 numeric fields), or Bubble / 3D Scatter (3 numeric fields).
  • Aggregations: Select Sum, Average, Minimum, Maximum, or Count when multiple records share an X-axis category.

Current Page vs. All Matching Records

Because API records are paginated, charting only the current page can look very different from charting the full dataset. Data Khoj displays an explicit Records to Chart selector:

  1. Current page: Charts only the rows currently loaded in the table view.
  2. All matching records: Queries the backend proxy (/api/resources/{resourceId}/chart-data), which retrieves up to 5,000 records safely. If the dataset exceeds 5,000 rows, the badge clearly reads Sampled matching records (first 5,000).
Comparison of Current Page Only, All Matching Records up to 5,000, and Sampled Matching Records scopes
Figure 2: How Data Khoj labels chart data scope based on pagination and backend proxy limits.

Exporting and Saving Your Work

Once your chart is ready, you can download it as a PNG image, export the plotted values as CSV, or save the configuration locally to reopen later.