Options
All
  • Public
  • Public/Protected
  • All
Menu

A FigureView manages the visual presentation of a single Plotly.js figure for a single notebook output cell. Each FigureView has a reference to FigureModel. Multiple views may share a single model instance, as is the case when a Python FigureWidget is displayed in multiple notebook output cells.

Hierarchy

  • DOMWidgetView
    • FigureView

Index

Constructors

constructor

  • new FigureView(options?: ViewOptions<WidgetModel, HTMLElement> & { options?: any }): FigureView
  • Public constructor.

    Parameters

    • Optional options: ViewOptions<WidgetModel, HTMLElement> & { options?: any }

    Returns FigureView

Properties

$el

$el: any

attributes

attributes: Record<string, any>

cid

cid: string

Optional className

className: string

collection

collection: Collection<any>

displayed

displayed: Promise<WidgetView>

A promise that resolves to the parent view when a child view is displayed.

el

el: HTMLElement

Optional id

id: string

layoutPromise

layoutPromise: Promise<any>

luminoWidget

luminoWidget: Widget

model

model: WidgetModel

options

options: any

stylePromise

stylePromise: Promise<any>

tagName

tagName: string

viewID

viewID: string

Accessors

pWidget

  • get pWidget(): Widget
  • deprecated

    Use luminoWidget instead (Since 8.0).

    Returns Widget

Methods

$

  • $(selector: string): JQuery<HTMLElement>
  • Parameters

    • selector: string

    Returns JQuery<HTMLElement>

Protected _createElement

  • _createElement(tagName: string): void
  • Parameters

    • tagName: string

    Returns void

Protected _ensureElement

  • _ensureElement(): void
  • Returns void

_removeElement

  • _removeElement(): void
  • Returns void

Private _sendLayoutDelta

  • _sendLayoutDelta(layout_edit_id: any): void
  • Construct layout delta object and send layoutDelta message to the Python side

    Parameters

    • layout_edit_id: any

      Edit ID of message that triggered the creation of the layout delta

    Returns void

Private _sendTraceDeltas

  • _sendTraceDeltas(trace_edit_id: any): void
  • Construct trace deltas array for the requested trace indexes and send traceDeltas message to the Python side Array of indexes of traces for which to compute deltas

    Parameters

    • trace_edit_id: any

      Edit ID of message that triggered the creation of trace deltas

    Returns void

Private _send_points_callback_message

  • _send_points_callback_message(data: any, event_type: string): void
  • Build and send a points callback message to the Python side

    Parameters

    • data: any

      data object as provided by the plotly_click, plotly_hover, plotly_unhover, or plotly_selected events

    • event_type: string

      Name of the triggering event. One of 'plotly_click', 'plotly_hover', 'plotly_unhover', or 'plotly_selected'

    Returns void

_setAttributes

  • _setAttributes(attrs: ObjectHash): void
  • Parameters

    • attrs: ObjectHash

    Returns void

_setElement

  • _setElement(el: HTMLElement): void
  • Parameters

    • el: HTMLElement

    Returns void

autosizeFigure

  • autosizeFigure(): void
  • Returns void

bind

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

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

    Returns FigureView

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureView

buildInputDeviceStateObject

  • buildInputDeviceStateObject(data: any): null | InputDeviceState
  • Build InputDeviceState data structure from data supplied by the plotly_click, plotly_hover, or plotly_select events

    Parameters

    • data: any

    Returns null | InputDeviceState

buildPointsObject

  • buildPointsObject(data: any): null | Points
  • Build Points data structure from data supplied by the plotly_click, plotly_hover, or plotly_select events

    Parameters

    • data: any

    Returns null | Points

buildSelectorObject

  • buildSelectorObject(data: any): null | Selector
  • Build Selector data structure from data supplied by the plotly_select event

    Parameters

    • data: any

    Returns null | Selector

callbacks

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

    Returns ICallbacks

create_child_view

  • create_child_view<VT>(child_model: DOMWidgetModel, options?: any): Promise<VT>
  • create_child_view<VT>(child_model: WidgetModel, options?: any): Promise<VT>
  • Create and promise that resolves to a child view of a given model

    Type parameters

    • VT: DOMWidgetView<VT> = DOMWidgetView

    Parameters

    • child_model: DOMWidgetModel
    • Optional options: any

    Returns Promise<VT>

  • Type parameters

    • VT: WidgetView<VT> = WidgetView

    Parameters

    • child_model: WidgetModel
    • Optional options: any

    Returns Promise<VT>

delegate

  • delegate(eventName: string, listener: Function): FigureView
  • delegate(eventName: string, selector: string, listener: Function): FigureView
  • Make an event delegation handler for the given eventName and selector and attach it to this.el. If selector is empty, the listener will be bound to this.el. If not, a new handler that will recursively traverse up the event target's DOM hierarchy looking for a node that matches the selector. If one is found, the event's delegateTarget property is set to it and the return the result of calling bound listener with the parameters given to the handler.

    This does not properly handle selectors for things like focus and blur (see https://github.com/jquery/jquery/blob/7d21f02b9ec9f655583e898350badf89165ed4d5/src/event.js#L442 for some similar exceptional cases).

    Parameters

    • eventName: string
    • listener: Function

    Returns FigureView

  • Parameters

    • eventName: string
    • selector: string
    • listener: Function

    Returns FigureView

delegateEvents

  • delegateEvents(events?: _Result<EventsHash>): FigureView
  • Parameters

    • Optional events: _Result<EventsHash>

    Returns FigureView

destroy

  • destroy(): void
  • Purge Plotly.js data structures from the notebook output display element when the view is destroyed

    Returns void

do_addTraces

  • do_addTraces(): void
  • Handle Plotly.addTraces request

    Returns void

do_animate

  • do_animate(): void
  • Handle Plotly.animate request

    Returns void

do_deleteTraces

  • do_deleteTraces(): void
  • Handle Plotly.deleteTraces request

    Returns void

do_moveTraces

  • do_moveTraces(): void
  • Handle Plotly.moveTraces request

    Returns void

do_relayout

  • do_relayout(): void
  • Handle Plotly.relayout request

    Returns void

do_restyle

  • do_restyle(): void
  • Handle Plotly.restyle request

    Returns void

do_update

  • do_update(): void
  • Handle Plotly.update request

    Returns void

events

  • events(): EventsHash
  • Events hash or a method returning the events hash that maps events/selectors to methods on your View. For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... }; That works only if you set it in the constructor or the initialize method.

    Returns EventsHash

getFullData

  • getFullData(): any
  • Return the figure's _fullData array merged with its data array

    The merge ensures that for any properties that el._fullData and el.data have in common, we return the version from el.data

    Named colorscales are one example of why this is needed. The el.data array will hold named colorscale strings (e.g. 'Viridis'), while the el._fullData array will hold the actual colorscale array. e.g.

     el.data[0].marker.colorscale == 'Viridis' but
     el._fullData[0].marker.colorscale = [[..., ...], ...]
    

    Performing the merge allows our FigureModel to retain the 'Viridis' string, rather than having it overridded by the colorscale array.

    Returns any

getFullLayout

  • getFullLayout(): any
  • Return the figure's _fullLayout object merged with its layout object

    See getFullData documentation for discussion of why the merge is necessary

    Returns any

handle_message

  • handle_message(content: any): void
  • Handle message sent to the front end.

    Used to focus or blur the widget.

    Parameters

    • content: any

    Returns void

handle_plotly_click

  • handle_plotly_click(data: any): void
  • Handle plotly_click events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_deselect

  • handle_plotly_deselect(data: any): void
  • Handle plotly_deselect events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_doubleclick

  • handle_plotly_doubleclick(data: any): void
  • Stub for future handling of plotly_doubleclick

    Parameters

    • data: any

    Returns void

handle_plotly_hover

  • handle_plotly_hover(data: any): void
  • Handle plotly_hover events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_relayout

  • handle_plotly_relayout(data: any): void
  • Handle plotly_relayout events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_restyle

  • handle_plotly_restyle(data: any): void
  • Handle ploty_restyle events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_selected

  • handle_plotly_selected(data: any): void
  • Handle plotly_selected events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_unhover

  • handle_plotly_unhover(data: any): void
  • Handle plotly_unhover events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

handle_plotly_update

  • handle_plotly_update(data: any): void
  • Handle plotly_update events emitted by the Plotly.js library

    Parameters

    • data: any

    Returns void

initialize

  • initialize(parameters: IInitializeParameters<WidgetModel>): void
  • Public constructor

    Parameters

    • parameters: IInitializeParameters<WidgetModel>

    Returns void

listenTo

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

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

    Returns FigureView

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns FigureView

listenToOnce

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

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

    Returns FigureView

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns FigureView

off

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

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

    Returns FigureView

on

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

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

    Returns FigureView

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureView

once

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

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

    Returns FigureView

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns FigureView

perform_render

  • perform_render(): void
  • The perform_render method is called by processLuminoMessage after the widget's DOM element has been attached to the notebook output cell. This happens after the initialize of the FigureModel, and it won't happen at all if the Python FigureWidget is never displayed in a notebook output cell

    Returns void

preinitialize

  • preinitialize(options?: ViewOptions<WidgetModel, HTMLElement>): void
  • For use with views as ES classes. If you define a preinitialize method, it will be invoked when the view is first created, before any instantiation logic is run.

    see

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

    Parameters

    • Optional options: ViewOptions<WidgetModel, HTMLElement>

    Returns void

processLuminoMessage

  • processLuminoMessage(msg: any): void
  • Respond to phosphorjs events

    Parameters

    • msg: any

    Returns void

remove

  • remove(): any
  • Returns any

render

  • render(): any
  • Render a view

    Returns any

    the view or a promise to the view.

send

  • send(content: {}, buffers?: ArrayBuffer[] | ArrayBufferView[]): void
  • Send a custom msg associated with this view.

    Parameters

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

    Returns void

setElement

  • setElement(element: HTMLElement | JQuery<HTMLElement>): FigureView
  • Parameters

    • element: HTMLElement | JQuery<HTMLElement>

    Returns FigureView

setLayout

  • setLayout(layout: LayoutModel, oldLayout?: LayoutModel): void
  • Parameters

    • layout: LayoutModel
    • Optional oldLayout: LayoutModel

    Returns void

setStyle

  • setStyle(style: StyleModel, oldStyle?: StyleModel): void
  • Parameters

    • style: StyleModel
    • Optional oldStyle: StyleModel

    Returns void

set_mapped_classes

  • set_mapped_classes(class_map: Dict<string[]>, trait_name: string, el?: HTMLElement): void
  • Parameters

    • class_map: Dict<string[]>
    • trait_name: string
    • Optional el: HTMLElement

    Returns void

stopListening

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

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

    Returns FigureView

touch

  • touch(): void
  • Returns void

trigger

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

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

    Returns FigureView

unbind

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

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

    Returns FigureView

undelegate

  • undelegate(eventName: string, selector?: string, listener?: Function): FigureView
  • undelegate(selector: string, listener?: Function): FigureView
  • Parameters

    • eventName: string
    • Optional selector: string
    • Optional listener: Function

    Returns FigureView

  • Parameters

    • selector: string
    • Optional listener: Function

    Returns FigureView

undelegateEvents

  • Returns FigureView

update

  • update(options?: any): void
  • Triggered on model change.

    Update view to be consistent with this.model

    Parameters

    • Optional options: any

    Returns void

updateTabindex

  • updateTabindex(): void
  • Returns void

updateTooltip

  • updateTooltip(): void
  • Returns void

update_classes

  • update_classes(old_classes: string[], new_classes: string[], el?: HTMLElement): void
  • Update the DOM classes applied to an element, default to this.el.

    Parameters

    • old_classes: string[]
    • new_classes: string[]
    • Optional el: HTMLElement

    Returns void

update_mapped_classes

  • update_mapped_classes(class_map: Dict<string[]>, trait_name: string, el?: HTMLElement): void
  • Update the DOM classes applied to the widget based on a single trait's value.

    Given a trait value classes map, this function automatically handles applying the appropriate classes to the widget element and removing classes that are no longer valid.

    Parameters

    class_map: dictionary Dictionary of trait values to class lists. Example: { success: ['alert', 'alert-success'], info: ['alert', 'alert-info'], warning: ['alert', 'alert-warning'], danger: ['alert', 'alert-danger'] }; trait_name: string Name of the trait to check the value of. el: optional DOM element handle, defaults to this.el Element that the classes are applied to.

    Parameters

    • class_map: Dict<string[]>
    • trait_name: string
    • Optional el: HTMLElement

    Returns void

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