Skip to main content

ObjectPropertyBag

A dynamic property bag that provides convenient access to an object's properties.

This class uses a JavaScript Proxy to allow accessing properties directly by name:

viewer.props.showAxes = true;  // Instead of: viewer.setOptions({showAxes: true})
console.log(viewer.props.color);

The Proxy intercepts property access and routes it through the underlying property system, which handles type conversion and validation.

Note: Due to the dynamic Proxy nature, TypeScript cannot provide compile-time type checking for property access. Use getProperties() to discover available properties at runtime.

Example

// Access viewer properties
const scatter = view.scatterPlot();
scatter.props.xColumnName = 'age';
scatter.props.yColumnName = 'weight';

// Enumerate available properties
for (const prop of scatter.props.getProperties()) {
console.log(prop.name, prop.propertyType);
}

Constructors

new ObjectPropertyBag()

new ObjectPropertyBag(source, x): ObjectPropertyBag

Parameters

ParameterTypeDefault value
sourceanyundefined
xanynull

Returns

ObjectPropertyBag

Source

src/widgets/base.ts:78

Properties

PropertyTypeDescription
sourceanyThe source object whose properties are being wrapped

Methods

get()

get(propertyName): object

Gets the value of the specified property

Parameters

ParameterTypeDescription
propertyNamestring

Returns

object

Source

src/widgets/base.ts:127


getProperties()

getProperties(): Property[]

Returns

Property[]

Source

src/widgets/base.ts:147


getProperty()

getProperty(name): Property

Gets property by name (case-sensitive).

Parameters

ParameterTypeDescription
namestring

Returns

Property

Source

src/widgets/base.ts:154


hasProperty()

hasProperty(name): boolean

Parameters

ParameterTypeDescription
namestring

Returns

boolean

Source

src/widgets/base.ts:164


resetDefault()

resetDefault(): void

Clears the previously remembered default settings for viewers of this type. See also: [setDefault]

Returns

void

Source

src/widgets/base.ts:185


set()

set(propertyName, propertyValue): void

Sets the value of the specified property

Parameters

ParameterTypeDescription
propertyNamestring
propertyValueobject

Returns

void

Source

src/widgets/base.ts:136


setAll()

setAll(params): void

Sets all properties according to the passed object containing key-value pairs

Parameters

ParameterType
paramsobject

Returns

void

Source

src/widgets/base.ts:141


setDefault()

setDefault(data, style): void

Sets the current state of viewer properties as the default configuration used to create new viewer instances of this type. Equivalent to the "Pick Up / Apply | Set as Default" context menu command. Read more about viewer commands: https://datagrok.ai/help/visualize/viewers/#common-actions

Parameters

ParameterTypeDefault valueDescription
databooleanfalseindicates if data settings should be copied.
stylebooleantrueindicates if style (non-data) settings should be copied.

Returns

void

Source

src/widgets/base.ts:173


setDefaultProperty()

static setDefaultProperty(viewerType, propertyName, propertyValue): void

Parameters

ParameterType
viewerTypestring
propertyNamestring
propertyValueany

Returns

void

Source

src/widgets/base.ts:180