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
| Parameter | Type | Default value |
|---|---|---|
source | any | undefined |
x | any | null |
Returns
Source
Properties
| Property | Type | Description |
|---|---|---|
source | any | The source object whose properties are being wrapped |
Methods
get()
get(
propertyName):object
Gets the value of the specified property
Parameters
| Parameter | Type | Description |
|---|---|---|
propertyName | string |
Returns
object
Source
getProperties()
getProperties():
Property[]
Returns
Property[]
Source
getProperty()
getProperty(
name):Property
Gets property by name (case-sensitive).
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string |
Returns
Source
hasProperty()
hasProperty(
name):boolean
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string |
Returns
boolean
Source
resetDefault()
resetDefault():
void
Clears the previously remembered default settings for viewers of this type. See also: [setDefault]
Returns
void
Source
set()
set(
propertyName,propertyValue):void
Sets the value of the specified property
Parameters
| Parameter | Type | Description |
|---|---|---|
propertyName | string | |
propertyValue | object |
Returns
void
Source
setAll()
setAll(
params):void
Sets all properties according to the passed object containing key-value pairs
Parameters
| Parameter | Type |
|---|---|
params | object |
Returns
void
Source
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
data | boolean | false | indicates if data settings should be copied. |
style | boolean | true | indicates if style (non-data) settings should be copied. |
Returns
void
Source
setDefaultProperty()
staticsetDefaultProperty(viewerType,propertyName,propertyValue):void
Parameters
| Parameter | Type |
|---|---|
viewerType | string |
propertyName | string |
propertyValue | any |
Returns
void