*! googlechart_writehtml v0.1.1 2026-06-28 *! Assemble the self-contained HTML for a googlechart chart. *! *! Page structure mirrors sparkta2's chart writehtml (Texas 2036 brand *! tokens, sidebar controls panel, optional under-chart export footer, *! collapsible data-table panel) -- but the renderer is Google Charts *! and the loader.js comes from gstatic.com (CDN-only by Google ToS). *! *! NOT OFFLINE. An open .html file requires network access at view time *! so the Google Charts loader and per-package code can fetch. For *! offline-capable maps and charts, use sparkta2 instead. program define googlechart_writehtml version 17.0 syntax , ENGPATH(string) ROWJSON(string) METAJSON(string) FILTERJSON(string) /// EXPORT(string) /// TYPE(string) SCHEME(string) TITLE(string) /// WIDTH(integer) HEIGHT(integer) /// ISDOWNload(integer) ISDATAtable(integer) ISANImate(integer) /// ISTX2036Style(integer) ISSTACKed(integer) ISNORMAlize(integer) /// ISDIRECTlabels(integer) /// [ SUBtitle(string) NOTE(string) /// XLAbel(string) YLAbel(string) /// XVAR(string) YVAR(string) NAME(string) OVER(string) /// LEVel(string) LEVELORDer(string) CENTERlevel(string) /// TIME(string) /// DOWNLOADPos(string) /// INNERradius(real 0) /// BUCKETSize(real 0) /// GEOREGion(string) GEORESolution(string) /// COMBOTypes(string) COMBODefault(string) /// NAMELabel(string) VALUELabel(string) /// LABELWRap(string) /// LEGENDPos(string) /// ISTBLSEArch(integer 0) /// ISTBLSTIcky(integer 0) /// TBLFROZencols(integer 0) ] if "`downloadpos'" == "" local downloadpos "side" if "`labelwrap'" == "" local labelwrap "auto" tempname fh quietly file open `fh' using `"`export'"', write text replace local esc_title : subinstr local title `"&"' `"&"', all local esc_title : subinstr local esc_title `"<"' `"<"', all local esc_title : subinstr local esc_title `">"' `">"', all file write `fh' `""' _n file write `fh' `""' _n file write `fh' `""' _n file write `fh' `""' _n file write `fh' `"`esc_title'"' _n * tx2036style: Montserrat from Google Fonts. if `istx2036style' { file write `fh' `""' _n file write `fh' `""' _n file write `fh' `""' _n } * Google Charts loader -- CDN-only by ToS. Per-package fetches happen * later when google.charts.load() runs. file write `fh' `""' _n file write `fh' `""' _n * Body class so per-type CSS can target without inline styles. local _btype = lower("`type'") file write `fh' `""' _n file write `fh' `"
"' _n file write `fh' `"

`esc_title'

"' _n if "`subtitle'" != "" { local esc_sub : subinstr local subtitle `"&"' `"&"', all file write `fh' `"

`esc_sub'

"' _n } file write `fh' `"
"' _n file write `fh' `"
"' _n file write `fh' `"
"' _n file write `fh' `"
"' _n file write `fh' `"
"' _n if "`note'" != "" { local esc_note : subinstr local note `"&"' `"&"', all file write `fh' `"

`esc_note'

"' _n } file write `fh' `"
"' _n * --- JSON payload + engine injection ---------------------------------- file write `fh' `""' _n * Inline the engine source (one self-contained file). googlechart_embedjs, fh(`fh') path("`engpath'") outpath(`"`export'"') file write `fh' `""' _n file write `fh' `""' _n file close `fh' end