Options
All
  • Public
  • Public/Protected
  • All
Menu

A FigureModel holds a mirror copy of the state of a FigureWidget on the Python side. There is a one-to-one relationship between JavaScript FigureModels and Python FigureWidgets. The JavaScript FigureModel is initialized as soon as a Python FigureWidget initialized, this happens even before the widget is first displayed in the Notebook

Hierarchy

  • DOMWidgetModel
    • FigureModel

Index

Constructors

constructor

  • new FigureModel(attributes?: any, options?: any): FigureModel
  • Parameters

    • Optional attributes: any
    • Optional options: any

    Returns FigureModel

Properties

attributes

attributes: Partial<any>

changed

changed: Partial<any>

cid

cid: string

cidPrefix

cidPrefix: string

collection

collection: Collection<FigureModel>

Optional comm

comm: IClassicComm

id

id: string | number

idAttribute

idAttribute: string

model_id

model_id: string

module

module: string

name

name: string

state_change

state_change: Promise<any>

url

url: () => string

Returns the relative URL where the model's resource would be located on the server.

Type declaration

    • (): string
    • Returns string

urlRoot

urlRoot: _Result<string>

validationError

validationError: any

Optional views

views: {}

Type declaration

  • [key: string]: Promise<WidgetView>

widget_manager

widget_manager: IWidgetManager

Static model_module

model_module: any = ...

Static model_module_version

model_module_version: string = ...

Static model_name

model_name: string = "FigureModel"

Static serializers

serializers: ISerializers = ...

Static view_module

view_module: any = ...

Static view_module_version

view_module_version: string = ...

Static view_name

view_name: string = "FigureView"

Accessors

comm_live

  • get comm_live(): boolean
  • set comm_live(x: boolean): any
  • Returns boolean

  • Parameters

    • x: boolean

    Returns any

Methods

_handle_comm_closed

  • _handle_comm_closed(msg: ICommCloseMsg<"iopub" | "shell">): void
  • Handle when a widget comm is closed.

    Parameters

    • msg: ICommCloseMsg<"iopub" | "shell">

    Returns void

_handle_comm_msg

  • _handle_comm_msg(msg: ICommMsgMsg<"iopub" | "shell">): Promise<void>
  • Handle incoming comm msg.

    Parameters

    • msg: ICommMsgMsg<"iopub" | "shell">

    Returns Promise<void>

_handle_status

  • _handle_status(msg: IStatusMsg): void
  • Handle status msgs.

    execution_state : ('busy', 'idle', 'starting')

    Parameters

    • msg: IStatusMsg

    Returns void

Private _normalize_trace_indexes

  • _normalize_trace_indexes(trace_indexes?: null | number | number[]): number[]
  • Input a trace index specification and return an Array of trace indexes where:

    • null|undefined -> Array of all traces
    • Trace index as Number -> Single element array of input index
    • Array of trace indexes -> Input array unchanged

    Parameters

    • Optional trace_indexes: null | number | number[]

    Returns number[]

    Array of trace indexes

bind

  • bind(eventName: string, callback: EventHandler, context?: any): FigureModel
  • bind(eventMap: EventMap, context?: any): FigureModel
  • Parameters

    • eventName: string
    • callback: EventHandler
    • Optional context: any

    Returns FigureModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureModel

callbacks

  • callbacks(view?: WidgetView): ICallbacks
  • Create msg callbacks for a comm msg.

    Parameters

    • Optional view: WidgetView

    Returns ICallbacks

chain

  • chain(): any
  • Returns any

changedAttributes

  • changedAttributes(attributes?: Partial<any>): false | Partial<any>
  • Return an object containing all the attributes that have changed, or false if there are no changed attributes. Useful for determining what parts of a view need to be updated and/or what attributes need to be persisted to the server. Unset attributes will be set to undefined. You can also pass an attributes object to diff against the model, determining if there would be a change.

    Parameters

    • Optional attributes: Partial<any>

    Returns false | Partial<any>

clear

  • Parameters

    • Optional options: Silenceable

    Returns FigureModel

clone

  • clone(): Model<any, ModelSetOptions, any>
  • Returns Model<any, ModelSetOptions, any>

close

  • close(comm_closed?: boolean): Promise<void>
  • Close model

    Parameters

    • Optional comm_closed: boolean

      true if the comm is already being closed. If false, the comm will be closed.

    Returns Promise<void>

    • a promise that is fulfilled when all the associated views have been removed.

defaults

  • defaults(): { _config: {}; _data: never[]; _js2py_layoutDelta: null; _js2py_pointsCallback: null; _js2py_relayout: null; _js2py_restyle: null; _js2py_traceDeltas: null; _js2py_update: null; _last_layout_edit_id: number; _last_trace_edit_id: number; _layout: {}; _model_module: any; _model_module_version: string; _model_name: string; _py2js_addTraces: null; _py2js_animate: null; _py2js_deleteTraces: null; _py2js_moveTraces: null; _py2js_relayout: null; _py2js_removeLayoutProps: null; _py2js_removeTraceProps: null; _py2js_restyle: null; _py2js_update: null; _view_module: any; _view_module_version: string; _view_name: string }
  • Returns { _config: {}; _data: never[]; _js2py_layoutDelta: null; _js2py_pointsCallback: null; _js2py_relayout: null; _js2py_restyle: null; _js2py_traceDeltas: null; _js2py_update: null; _last_layout_edit_id: number; _last_trace_edit_id: number; _layout: {}; _model_module: any; _model_module_version: string; _model_name: string; _py2js_addTraces: null; _py2js_animate: null; _py2js_deleteTraces: null; _py2js_moveTraces: null; _py2js_relayout: null; _py2js_removeLayoutProps: null; _py2js_removeTraceProps: null; _py2js_restyle: null; _py2js_update: null; _view_module: any; _view_module_version: string; _view_name: string }

    • _config: {}
    • _data: never[]
    • _js2py_layoutDelta: null
    • _js2py_pointsCallback: null
    • _js2py_relayout: null
    • _js2py_restyle: null
    • _js2py_traceDeltas: null
    • _js2py_update: null
    • _last_layout_edit_id: number
    • _last_trace_edit_id: number
    • _layout: {}
    • _model_module: any
    • _model_module_version: string
    • _model_name: string
    • _py2js_addTraces: null
    • _py2js_animate: null
    • _py2js_deleteTraces: null
    • _py2js_moveTraces: null
    • _py2js_relayout: null
    • _py2js_removeLayoutProps: null
    • _py2js_removeTraceProps: null
    • _py2js_restyle: null
    • _py2js_update: null
    • _view_module: any
    • _view_module_version: string
    • _view_name: string

destroy

  • destroy(options?: ModelDestroyOptions): false | JQueryXHR
  • Parameters

    • Optional options: ModelDestroyOptions

    Returns false | JQueryXHR

do_addTraces

  • do_addTraces(): void
  • Handle addTraces message

    Returns void

do_animate

  • do_animate(): void
  • Handle animate message

    Returns void

do_data

  • do_data(): void
  • Log changes to the _data trait

    This should only happed on FigureModel initialization

    Returns void

do_deleteTraces

  • do_deleteTraces(): void
  • Handle deleteTraces message

    Returns void

do_layout

  • do_layout(): void
  • Log changes to the _layout trait

    This should only happed on FigureModel initialization

    Returns void

do_moveTraces

  • do_moveTraces(): void
  • Handle moveTraces message

    Returns void

do_relayout

  • do_relayout(): void
  • Handle relayout message

    Returns void

do_removeLayoutProps

  • do_removeLayoutProps(): void
  • Handle removeLayoutProps message

    Returns void

do_removeTraceProps

  • do_removeTraceProps(): void
  • Handle removeTraceProps message

    Returns void

do_restyle

  • do_restyle(): void
  • Handle restyle message

    Returns void

do_update

  • do_update(): void
  • Handle update message

    Returns void

escape

  • escape(attribute: string): string
  • Parameters

    • attribute: string

    Returns string

fetch

  • fetch(options?: ModelFetchOptions): JQueryXHR
  • Parameters

    • Optional options: ModelFetchOptions

    Returns JQueryXHR

get

  • get<A>(attributeName: A): any
  • For strongly-typed access to attributes, use the get method only privately in public getter properties.

    example

    get name(): string { return super.get("name"); }

    Type parameters

    • A: string

    Parameters

    • attributeName: A

    Returns any

get_state

  • get_state(drop_defaults?: boolean): JSONObject
  • Get the serializable state of the model.

    If drop_default is truthy, attributes that are equal to their default values are dropped.

    Parameters

    • Optional drop_defaults: boolean

    Returns JSONObject

has

  • has(attribute: string): boolean
  • Parameters

    • attribute: string

    Returns boolean

hasChanged

  • hasChanged(attribute?: string): boolean
  • Parameters

    • Optional attribute: string

    Returns boolean

initialize

  • initialize(): void
  • Initialize FigureModel. Called when the Python FigureWidget is first constructed

    Returns void

invert

  • invert(): any
  • Returns any

isEmpty

  • isEmpty(): boolean
  • Returns boolean

isNew

  • isNew(): boolean
  • Test to see if the model has been synced with the server.

    Notes

    As of backbone 1.1, backbone ignores patch if it thinks the model has never been pushed.

    Returns boolean

isValid

  • isValid(options?: any): boolean
  • Parameters

    • Optional options: any

    Returns boolean

keys

  • keys(): string[]
  • Returns string[]

listenTo

  • listenTo(object: any, events: string, callback: EventHandler): FigureModel
  • listenTo(object: any, eventMap: EventMap): FigureModel
  • Parameters

    • object: any
    • events: string
    • callback: EventHandler

    Returns FigureModel

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns FigureModel

listenToOnce

  • listenToOnce(object: any, events: string, callback: EventHandler): FigureModel
  • listenToOnce(object: any, eventMap: EventMap): FigureModel
  • Parameters

    • object: any
    • events: string
    • callback: EventHandler

    Returns FigureModel

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns FigureModel

matches

  • matches(attrs: any): boolean
  • Parameters

    • attrs: any

    Returns boolean

off

  • off(eventName?: null | string, callback?: null | EventHandler, context?: any): FigureModel
  • Parameters

    • Optional eventName: null | string
    • Optional callback: null | EventHandler
    • Optional context: any

    Returns FigureModel

omit

  • omit<A>(keys: A[]): Partial<_Omit<any, A>>
  • omit<A>(...keys: A[]): Partial<_Omit<any, A>>
  • omit(fn: (value: any, key: any, object: any) => any): Partial<any>
  • Type parameters

    • A: string

    Parameters

    • keys: A[]

    Returns Partial<_Omit<any, A>>

  • Type parameters

    • A: string

    Parameters

    • Rest ...keys: A[]

    Returns Partial<_Omit<any, A>>

  • Parameters

    • fn: (value: any, key: any, object: any) => any
        • (value: any, key: any, object: any): any
        • Parameters

          • value: any
          • key: any
          • object: any

          Returns any

    Returns Partial<any>

on

  • on(eventName: string, callback: EventHandler, context?: any): FigureModel
  • on(eventMap: EventMap, context?: any): FigureModel
  • Parameters

    • eventName: string
    • callback: EventHandler
    • Optional context: any

    Returns FigureModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureModel

on_some_change

  • on_some_change(keys: string[], callback: (...args: any[]) => void, context: any): void
  • on_some_change(['key1', 'key2'], foo, context) differs from on('change:key1 change:key2', foo, context). If the widget attributes key1 and key2 are both modified, the second form will result in foo being called twice while the first will call foo only once.

    Parameters

    • keys: string[]
    • callback: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • context: any

    Returns void

once

  • once(events: string, callback: EventHandler, context?: any): FigureModel
  • once(eventMap: EventMap, context?: any): FigureModel
  • Parameters

    • events: string
    • callback: EventHandler
    • Optional context: any

    Returns FigureModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureModel

pairs

  • pairs(): any[]
  • Returns any[]

parse

  • parse(response: any, options?: any): any
  • Parameters

    • response: any
    • Optional options: any

    Returns any

pick

  • pick<A>(keys: A[]): Partial<Pick<any, A>>
  • pick<A>(...keys: A[]): Partial<Pick<any, A>>
  • pick(fn: (value: any, key: any, object: any) => any): Partial<any>
  • Type parameters

    • A: string

    Parameters

    • keys: A[]

    Returns Partial<Pick<any, A>>

  • Type parameters

    • A: string

    Parameters

    • Rest ...keys: A[]

    Returns Partial<Pick<any, A>>

  • Parameters

    • fn: (value: any, key: any, object: any) => any
        • (value: any, key: any, object: any): any
        • Parameters

          • value: any
          • key: any
          • object: any

          Returns any

    Returns Partial<any>

preinitialize

  • preinitialize(attributes?: any, options?: any): void
  • For use with models as ES classes. If you define a preinitialize method, it will be invoked when the Model is first created, before any instantiation logic is run for the Model.

    see

    https://backbonejs.org/#Model-preinitialize

    Parameters

    • Optional attributes: any
    • Optional options: any

    Returns void

previous

  • previous<A>(attribute: A): any
  • Type parameters

    • A: string

    Parameters

    • attribute: A

    Returns any

previousAttributes

  • previousAttributes(): Partial<any>
  • Returns Partial<any>

rememberLastUpdateFor

  • rememberLastUpdateFor(msgId: string): void
  • Parameters

    • msgId: string

    Returns void

save

  • save(attributes?: null | Partial<any>, options?: ModelSaveOptions): JQueryXHR
  • Parameters

    • Optional attributes: null | Partial<any>
    • Optional options: ModelSaveOptions

    Returns JQueryXHR

save_changes

  • save_changes(callbacks?: {}): void
  • Push this model's state to the back-end

    This invokes a Backbone.Sync.

    Parameters

    • Optional callbacks: {}

    Returns void

send

  • send(content: {}, callbacks: {}, buffers?: ArrayBuffer[] | ArrayBufferView[]): void
  • Send a custom msg over the comm.

    Parameters

    • content: {}
    • callbacks: {}
    • Optional buffers: ArrayBuffer[] | ArrayBufferView[]

    Returns void

send_sync_message

  • send_sync_message(state: JSONObject, callbacks?: any): string
  • Send a sync message to the kernel.

    If a message is sent successfully, this returns the message ID of that message. Otherwise it returns an empty string

    Parameters

    • state: JSONObject
    • Optional callbacks: any

    Returns string

serialize

  • serialize(state: Dict<any>): JSONObject
  • Serialize widget state.

    A serializer is a function which takes in a state attribute and a widget, and synchronously returns a JSONable object. The returned object will have toJSON called if possible, and the final result should be a primitive object that is a snapshot of the widget state that may have binary array buffers.

    Parameters

    • state: Dict<any>

    Returns JSONObject

set

  • set(key: any, val?: any, options?: any): any
  • Set one or more values.

    We just call the super method, in which val and options are optional. Handles both "key", value and {key: value} -style arguments.

    Parameters

    • key: any
    • Optional val: any
    • Optional options: any

    Returns any

set_state

  • set_state(state: Dict<unknown>): void
  • Handle when a widget is updated from the backend.

    This function is meant for internal use only. Values set here will not be propagated on a sync.

    Parameters

    • state: Dict<unknown>

    Returns void

stopListening

  • stopListening(object?: any, events?: string, callback?: EventHandler): FigureModel
  • Parameters

    • Optional object: any
    • Optional events: string
    • Optional callback: EventHandler

    Returns FigureModel

sync

  • sync(method: string, model: WidgetModel, options?: any): any
  • Handle sync to the back-end. Called when a model.save() is called.

    Make sure a comm exists.

    Parameters

    method : create, update, patch, delete, read create/update always send the full attribute set patch - only send attributes listed in options.attrs, and if we are queuing up messages, combine with previous messages that have not been sent yet model : the model we are syncing will normally be the same as this options : dict the attrs key, if it exists, gives an {attr: value} dict that should be synced, otherwise, sync all attributes.

    Parameters

    • method: string
    • model: WidgetModel
    • Optional options: any

    Returns any

toJSON

  • toJSON(options?: {}): string
  • Serialize the model. See the deserialization function at the top of this file and the kernel-side serializer/deserializer.

    Parameters

    • Optional options: {}

    Returns string

trigger

  • trigger(eventName: string, ...args: any[]): FigureModel
  • Parameters

    • eventName: string
    • Rest ...args: any[]

    Returns FigureModel

unbind

  • unbind(eventName?: string, callback?: EventHandler, context?: any): FigureModel
  • Parameters

    • Optional eventName: string
    • Optional callback: EventHandler
    • Optional context: any

    Returns FigureModel

unset

  • unset(attribute: string, options?: Silenceable): FigureModel
  • Parameters

    • attribute: string
    • Optional options: Silenceable

    Returns FigureModel

validate

  • validate(attributes: Partial<any>, options?: any): any
  • Parameters

    • attributes: Partial<any>
    • Optional options: any

    Returns any

values

  • values(): any[]
  • Returns any[]

Static _deserialize_state

  • _deserialize_state(state: JSONObject, manager: IWidgetManager): Promise<Dict<unknown>>
  • Returns a promise for the deserialized state. The second argument is an instance of widget manager, which is required for the deserialization of widget models.

    Parameters

    • state: JSONObject
    • manager: IWidgetManager

    Returns Promise<Dict<unknown>>

Static extend

  • extend(properties: any, classProperties?: any): any
  • Do not use, prefer TypeScript's extend functionality.

    Parameters

    • properties: any
    • Optional classProperties: any

    Returns any

Generated using TypeDoc