ArrField

viz.macros.ArrField
class ArrField(path: List[String], headAccessor: Option[Any], elementAccessorFactory: Option[Int => Any], tupleAccessors: Map[String, Any]) extends Selectable

Accessor for array fields in a Vega/Vega-Lite spec.

Provides type-safe modification of array-valued JSON fields. Unlike other field types, the += operator on arrays appends elements rather than deep merging.

For heterogeneous arrays (where elements have different structures), tuple-style accessors are available: _0, _1, _2, etc. Each accessor has the precise type of that specific element.

Value parameters

elementAccessorFactory

Optional factory function to create accessors for array elements at any index

headAccessor

Optional accessor for the first element of the array (if available)

path

The JSON path to this field as a list of field names

tupleAccessors

Map of tuple-style accessors (_0, _1, etc.) for precise per-element types

Attributes

Example
// Replace the entire array spec.build(_.data.values := json"[{\"a\": 1}, {\"a\": 2}]")
// Append a single element spec.build(_.data.values += json"{\"a\": 3}")
// Append multiple elements spec.build(_.signals += Vector(json"{\"name\": \"sig1\"}", json"{\"name\": \"sig2\"}"))
// Access first element's nested field spec.build(_.data.head.values := json"[{\"a\": 1}]")
// Access element at index 2 with tuple-style accessor (precise type) spec.build(_.layer._2.data.sequence.start :=
5)
// Access element at index 2 with apply (uses first element's type) spec.build(_.data(2).values := json"[{\"a\":
1}]") 
Graph
Supertypes
trait Selectable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def +=(j: Json): SpecMod

Append a single JSON element to the array.

Append a single JSON element to the array.

If the current value is not an array, creates a new array with this element.

Attributes

def +=(arr: Vector[Json]): SpecMod

Append multiple JSON elements to the array

Append multiple JSON elements to the array

Attributes

def +=(obj: JsonObject): SpecMod

Append a JSON object element to the array

Append a JSON object element to the array

Attributes

def :=(j: Json): SpecMod

Replace the entire array with arbitrary JSON

Replace the entire array with arbitrary JSON

Attributes

def :=(arr: Vector[Json]): SpecMod

Replace the entire array with a Vector of JSON values

Replace the entire array with a Vector of JSON values

Attributes

def apply(index: Int): Any

Access an element at a specific index in the array.

Access an element at a specific index in the array.

Returns an accessor for the element at the given index. The element type is determined by the first element in the array at compile time, so all elements are assumed to have the same structure.

Value parameters

index

The zero-based index of the element to access

Attributes

Returns

An accessor for the element at the specified index with the same type as .head

Example
spec.build(_.data(1).name := "updated")
def apply(j: Json): SpecMod
def apply(arr: Vector[Json]): SpecMod
def selectDynamic(name: String): Any