sparkta

Interactive graphs in Stata, created as self-contained HTML files.
One command. Zero dependencies. No Python. No R. No server.

Stata 17+ MIT License v3.5.111 Chart.js 4.4
ssc install sparkta, replace

One command

Runs inside your existing do-file. No environment setup, no context switch.

📁

Single file output

A self-contained .html file. Email it, archive it, USB it. No viewer dependencies.

📈

Fit lines & CI bands

7 scatter fit types: lfit, qfit, lowess, exp, log, power, ma. Add fitci for a CI band that recomputes live with sliders.

🎨

17 themes & palettes

Tableau, Okabe-Ito (colorblind-safe), viridis, neon and more. Dark/light variants: theme(dark_viridis).

📶

Fully offline

The offline flag bundles all JS into the HTML. Zero network requests. Suitable for air-gapped systems.

🎮

Unlimited live filters

filters(v1 v2 v3) adds dropdown menus. sliders(price mpg) adds dual-handle range controls. Stats panel updates live.

🎯

Reference annotations

19 options: yline() xband() apoint() aellipse() alabelpos(). Lines, bands, markers, ellipses.

500k obs in ~0.5s

Bulk SFI reads, O(N) group scan, lazy sparklines. 10× faster than v2.x on large datasets.

📊

CI charts/graphs match Stata

t-distribution intervals computed in Java, matching ci means exactly. Any level 1–99.

Live interactive chart/graph gallery

CI Bar Chart

Mean car price with 95% t-distribution confidence intervals by repair record. Statistics match Stata ci means exactly.

* Stata command
sysuse auto, clear
sparkta price, type(cibar) over(rep78) cilevel(95) ///
    title("Mean Price by Repair Record")

Violin Plot

Animated kernel density estimate with IQR box and Tukey whiskers. Unique to sparkta among Stata visualization packages.

* Stata command
sysuse auto, clear
sparkta price, type(violin) over(rep78) ///
    title("Price Distribution by Repair Record")

Filters & Range Sliders

Unlimited dropdown filters and dual-handle range sliders slice the chart/graph live. The stats panel updates with every interaction. No server required.

* Stata command
sysuse auto, clear
sparkta price, over(rep78) ///
    filters(foreign headroom) sliders(mpg price) ///
    title("Price by Repair Record")

Reference Annotations

Horizontal reference line with ylinelabel() and a shaded reference band with yband().

* Stata command
sysuse auto, clear
sparkta price, over(rep78) ///
    yline(6000) ylinelabel("Target") ///
    yband(4000 8000) ybandcolor(rgba(52,152,219,0.12))

Scatter with Groups

Price vs MPG coloured by domestic vs foreign origin using over(foreign). Hover any point for exact values.

* Stata command
sysuse auto, clear
sparkta price mpg, type(scatter) over(foreign) ///
    title("Price vs MPG by Origin")

100% Stacked Bar

Wage composition by race stacked to 100% — immediately reveals share rather than absolute values.

* Stata command
sysuse nlsw88, clear
sparkta wage, over(race) type(stackedbar100) by(collgrad) ///
    title("Wage Composition by Race and Education")

Panel Layout with by()

Separate panels for domestic and foreign cars via by(foreign). Each panel is independently interactive.

* Stata command
sysuse auto, clear
sparkta price, over(rep78) by(foreign) ///
    title("Price by Repair Record")

Dark Neon Theme

Dark background with neon palette using theme(dark_neon). All seven palettes work on both light and dark backgrounds.

* Stata command
sysuse auto, clear
sparkta price, over(rep78) theme(dark_neon) ///
    title("Price by Repair Record")

For sensitive and restricted data

All interactive chart/graph generation runs inside Stata on your local machine. The output HTML has no data-fetching code, no callbacks, and makes zero external network requests. The offline option embeds all JavaScript directly — suitable for IRB-restricted data, clinical records, financial data, and institutional networks that block external CDN requests. The file renders identically in any browser, years from now.

* Install
net install sparkta, from("https://raw.githubusercontent.com/fahad-mirza/sparkta_stata/main/ado/") replace

* Bar graph grouped by repair record
sysuse auto, clear
sparkta price, over(rep78)

* CI bar graph -- t-distribution intervals matching ci means exactly
sparkta price, type(cibar) over(rep78) cilevel(95)

* Violin plot with animated KDE density
sparkta price, type(violin) over(rep78)

* Scatter with fit line, CI band, and live slider
sparkta price mpg, type(scatter) fit(lfit) fitci sliders(mpg)

* Unlimited live filters + range sliders
sparkta price, over(rep78) filters(foreign headroom) sliders(mpg price)

* Reference annotations -- line, band, point marker
sparkta price, over(rep78) yline(6165) ylinelabel("Overall mean") ///
    yband(4000 8000) apoint(6165 3)

* Dark theme with colorblind-safe palette
sparkta price, over(rep78) theme(dark_viridis)

* Fully air-gapped -- all JS embedded, zero network requests when opened
sparkta price, type(cibar) over(rep78) offline export("~/secure/chart.html")

help sparkta  •  github.com/fahad-mirza/sparkta_stata