Module

Chartjs.Scriptable

Package
purescript-chartjs
Repository
philippedev101/purescript-chartjs

Encoder machinery for Chart.js scriptable options (#20).

Mirrors Chartjs.Colors in spirit: takes Scriptable / ScriptableIndexable values from Chartjs.Types and produces Foreign suitable for the overlay merge in Chartjs.FFI. SVal / SIVal / SIArray round-trip through the caller-supplied inner encoder (a -> Foreign); SFn / SIFn are wrapped as JS closures that apply the inner encoder to the scriptable function's return value at Chart.js's option-resolution time.

Consumed by Chartjs.Colors for dataset field overlay extraction (#21 colors, #22 remaining properties).

#scriptableToForeign Source

scriptableToForeign :: forall a. (a -> Foreign) -> Scriptable a -> Foreign

Encode a Scriptable a to Foreign. Static SVal values pass through the supplied encoder; SFn functions become JS closures that apply the encoder to their return value at call time — which is what Chart.js expects when it resolves scriptable options at draw time.

#scriptableIndexableToForeign Source

scriptableIndexableToForeign :: forall a. (a -> Foreign) -> ScriptableIndexable a -> Foreign

Encode a ScriptableIndexable a to Foreign. SIVal / SIArray pass through the inner encoder directly (arrays are mapped element-wise); SIFn follows the same closure-wrapping treatment as SFn.

#hasScriptable Source

hasScriptable :: forall a. Scriptable a -> Boolean

true when the value needs the overlay path because it holds a function.

#hasScriptableIndexable Source

hasScriptableIndexable :: forall a. ScriptableIndexable a -> Boolean

true when the value needs the overlay path because it holds a function.