chart

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package chart is the chart plugin: one canonical chart-v1 spec, two renderers that must agree. The server renders a static SVG (chart/ssr) so the page works with JavaScript off; the sandboxed Observable Plot frame hydrates it into an interactive chart. The host adapter hides the SSR node when the frame reports ready — the decision that keeps this plugin core-free (pluginhost.MountConfig has no initial-children slot, and none was added).

Index

Constants

View Source
const (
	Name             = "chart"
	Version          = "0.1.0"
	RoutePrefix      = "/__gofastr/plugin/chart"
	ChartHTMLURL     = RoutePrefix + "/chart.html"
	ChartJSURL       = RoutePrefix + "/chart.js"
	ChartCSSURL      = RoutePrefix + "/chart.css"
	AdapterScriptURL = RoutePrefix + "/adapter.js"
	SaveURL          = RoutePrefix + "/save"
	DemoURL          = "/chart"
	SchemaVersion    = ssr.SchemaVersion
)

Identity and route constants. The Go plugin, host/adapter.js, and the frame bundle hard-code these exactly. The demo lives at /chart.

Variables

This section is empty.

Functions

func DefaultCapabilities

func DefaultCapabilities() []string

DefaultCapabilities is the grant set: no uploads, no network — document read/write plus theme bridging is the whole surface.

func Mount

func Mount(cfg MountConfig) render.HTML

Mount renders the SSR chart in a wrapper element followed by the normal mount marker and hidden field. With JavaScript off the SSR SVG is the page; with JavaScript on, host/adapter.js hides the wrapper when the frame reports ready (and un-hides it if the frame fails to boot).

func UIHostOption

func UIHostOption() uihost.Option

UIHostOption injects the platform broker and this plugin's adapter.

Types

type MountConfig

type MountConfig struct {
	// DocID is the persistence key.
	DocID string
	// SpecField is the hidden input name that carries the spec JSON.
	SpecField string
	// MinHeight is the initial iframe height before first resize.
	MinHeight string
	// Spec is the canonical chart JSON. It is rendered server-side into
	// the SSR wrapper AND placed on the marker for the frame's init.
	Spec []byte
}

MountConfig configures Mount.

type Option

type Option func(*Plugin)

func WithCapabilities

func WithCapabilities(caps ...string) Option

func WithDemoPage

func WithDemoPage() Option

func WithDevGrantAll

func WithDevGrantAll() Option

func WithSaveHandler

func WithSaveHandler(fn func(ctx context.Context, req SaveRequest) error) Option

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is the chart plugin. It implements framework.Plugin.

func New

func New(opts ...Option) *Plugin

New constructs a Plugin. The platform manifest is built and Validate()'d here so a bad isolation/sandbox config aborts construction rather than silently de-opaquing the frame at runtime.

func (*Plugin) Capabilities

func (p *Plugin) Capabilities() []string

func (*Plugin) Init

func (p *Plugin) Init(app *framework.App) error

Init registers every asset and RPC route on the app's router.

func (*Plugin) LoadDoc

func (p *Plugin) LoadDoc(ctx context.Context, docID string) (spec []byte, ok bool)

LoadDoc returns the last-saved normalized spec JSON for docID.

func (*Plugin) Manifest

func (p *Plugin) Manifest() pluginhost.Manifest

func (*Plugin) Name

func (p *Plugin) Name() string

type SaveRequest

type SaveRequest struct {
	DocID         string
	Spec          []byte // normalized canonical spec JSON
	SchemaVersion string
}

Directories

Path Synopsis
Package ssr renders a chart-v1 spec to a standalone SVG in pure Go.
Package ssr renders a chart-v1 spec to a standalone SVG in pure Go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL