Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Image

Connect an <img> with a signal name to the backend.

The signal message is placed directly into the src attribute of the image tag. For matplotlib, that formatting can be done with the utility function fig_to_src() (see example below).

In index.html:

<img alt="my plot" data-signal="mpl" />

In analysis.py:

import matplotlib.pyplot as plt
...
fig = plt.figure()
...
self.emit('mpl', databench.fig_to_src(fig))

Hierarchy

Index

Constructors

constructor

Properties

actionName

actionName: string

idCount

idCount: number

node

node: HTMLImageElement & HTMLDatabenchElement

wireSignal

wireSignal: string | object

Static idCounter

idCounter: number = 0

Methods

actionFormat

  • actionFormat(value: any): any
  • Formats the payload of an action.

    Parameters

    • value: any

      Original payload.

    Returns any

    Modified payload.

determineActionName

  • determineActionName(node: HTMLElement): string
  • Determine the name of the action that should be associated with the node.

    The action name is determined from the tag's data-action, name or id attribute (in that order).

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns string

    Name of action or null.

determineWireSignal

  • determineWireSignal(node: HTMLElement): string | object
  • Determine the name of the signal that should be listened to from the backend.

    The signal name is determined from the data-signal, data-action, name or id attribute (in that order.) For all attributes apart from data-signal, the value is wrapped in an object like { data: value-of-attribute }. The data-signal value can contain a : which will be used to create an object as well. That means that data-signal="data:myvalue" gives the same result as data-action="myvalue".

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns string | object

    Name of a signal or null.

getSrc

  • getSrc(): string

setSrc

  • setSrc(v: string): Image
  • Sets theSrc.

    Parameters

    • v: string

    Returns Image

Static skipWire

  • skipWire(node: HTMLElement): boolean
  • Determine whether to skip this element.

    This can be forced by adding a data-skipwire=true attribute to the HTML tag.

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns boolean

Static wire

  • wire(conn: Connection, root?: Document | HTMLElement): void
  • Wire all text inputs.

    Parameters

    • conn: Connection
    • Optional root: Document | HTMLElement

    Returns void

Generated using TypeDoc