Anaconda Enterprise: Documentation

# bokeh.models.transforms

Represent transformations of data to happen on the client (browser) side.

class `bokeh.models.transforms.``CustomJSTransform`(**kwargs)

  Bases: `bokeh.models.transforms.Transform`

  Apply a custom defined transform to data.

  `args`

    property type: `Dict` ( `String` , `Instance` ( `Model` ) )

    A mapping of names to Bokeh plot objects. These objects are made available to the callback code snippet as the values of named parameters to the callback.

  `func`

    property type: `String`

    A snippet of JavaScript code to transform a single value. The variable `x` will contain the untransformed value and can be expected to be present in the function namespace at render time. The snippet will be into the body of a function and therefore requires a return statement.

    Example:

    >     func = '''
    >     return Math.floor(x) + 0.5
    >     '''

  `v_func`

    property type: `String`

    A snippet of JavaScript code to transform an array of values. The variable `xs` will contain the untransformed array and can be expected to be present in the function namespace at render time. The snippet will be into the body of a function and therefore requires a return statement.

    Example:

    >     v_func = '''
    >     new_xs = new Array(xs.length)
    >     for(i = 0; i < xs.length; i++) {
    >         new_xs[i] = xs[i] + 0.5
    >     }
    >     return new_xs
    >     '''

    Warning

    The vectorized function, `v_func`, must return an array of the same length as the input `xs` array.

  classmethod `from_coffeescript`(func, v_func, args={})

    Create a CustomJSTransform instance from a pair of CoffeeScript snippets. The function bodies are translated to JavaScript functions using node and therefore require return statements.

    The `func` snippet namespace will contain the variable `x` (the untransformed value) at render time. The `v_func` snippet namespace will contain the variable `xs` (the untransformed vector) at render time.

    Example:

        func = "return Math.cos(x)"
        v_func = "return [Math.cos(x) for x in xs]"

        transform = CustomJSTransform.from_coffeescript(func, v_func)

    Parameters: | func (str) – a coffeescript snippet to transform a single `x` value v_func (str) – a coffeescript snippet function to transform a vector `xs`
    Returns: | CustomJSTransform

  classmethod `from_py_func`(func, v_func)

    Create a CustomJSTransform instance from a pair of Python functions. The function is translated to JavaScript using PyScript.

    The python functions must have no positional arguments. It’s possible to pass Bokeh models (e.g. a ColumnDataSource) as keyword arguments to the functions.

    The `func` function namespace will contain the variable `x` (the untransformed value) at render time. The `v_func` function namespace will contain the variable `xs` (the untransformed vector) at render time.

    Warning

    The vectorized function, `v_func`, must return an array of the same length as the input `xs` array.

    Example:

        def transform():
            from flexx.pyscript.stubs import Math
            return Math.cos(x)

        def v_transform():
            from flexx.pyscript.stubs import Math
            return [Math.cos(x) for x in xs]

        customjs_transform = CustomJSTransform.from_py_func(transform, v_transform)

    Parameters: | func (function) – a scalar function to transform a single `x` value v_func (function) – a vectorized function to transform a vector `xs`
    Returns: | CustomJSTransform

JSON Prototype

    {
      "args": {},
      "func": "",
      "id": "8875ebcc-92d6-426e-a981-9a993aba4013",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "subscribed_events": [],
      "tags": [],
      "v_func": ""
    }

class `bokeh.models.transforms.``Dodge`(**kwargs)

  Bases: `bokeh.models.transforms.Transform`

  Apply either fixed dodge amount to data.

  `range`

    property type: `Instance` ( `Range` )

    When applying `Dodge` to categorical data values, the corresponding `FactorRange` must be supplied as the `range` property.

  `value`

    property type: `Float`

    The amount to dodge the input data.

JSON Prototype

    {
      "id": "a8975ebf-fa25-4818-b590-9bdf1c475448",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "range": null,
      "subscribed_events": [],
      "tags": [],
      "value": 0
    }

class `bokeh.models.transforms.``Interpolator`(**kwargs)

  Bases: `bokeh.models.transforms.Transform`

  Base class for interpolator transforms.

  Interpolators return the value of a function which has been evaluated between specified (x, y) pairs of data. As an example, if two control point pairs were provided to the interpolator, a linear interpolaction at a specific value of ‘x’ would result in the value of ‘y’ which existed on the line conneting the two control points.

  The control point pairs for the interpolators can be specified through either

  - A literal sequence of values:
  - or a pair of columns defined in a ColumnDataSource object:

  This is the base class and is not intended to end use. Please see the documentation for the final derived classes (Jitter, LineraInterpolator, StepInterpolator) for mor information on their specific methods of interpolation.

  Note

  This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

  `clip`

    property type: `Bool`

    Determine if the interpolation should clip the result to include only values inside its predefined range. If this is set to False, it will return the most value of the closest point.

  `data`

    property type: `Instance` ( `ColumnarDataSource` )

    Data which defines the source for the named columns if a string is passed to either the `x` or `y` parameters.

  `x`

    property type: `Either` ( `String` , `Seq` ( `Float` ) )

    Independant coordiante denoting the location of a point.

  `y`

    property type: `Either` ( `String` , `Seq` ( `Float` ) )

    Dependant coordinate denoting the value of a point at a location.

JSON Prototype

    {
      "clip": true,
      "data": null,
      "id": "08cab9f1-8184-44c4-b09e-5edb0f98cfda",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "subscribed_events": [],
      "tags": [],
      "x": null,
      "y": null
    }

class `bokeh.models.transforms.``Jitter`(**kwargs)

  Bases: `bokeh.models.transforms.Transform`

  Apply either a uniform or normally sampled random jitter to data.

  `distribution`

    property type: `Enum` ( `JitterRandomDistribution` )

    The random distribution upon which to pull the random scatter

  `mean`

    property type: `Float`

    The central value for the random sample

  `range`

    property type: `Instance` ( `Range` )

    When applying Jitter to Categorical data values, the corresponding `FactorRange` must be supplied as the `range` property.

  `width`

    property type: `Float`

    The width (absolute for uniform distribution and sigma for the normal distribution) of the random sample.

JSON Prototype

    {
      "distribution": "uniform",
      "id": "0f9b1fac-9872-48dd-a782-d454ddf9d5e2",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "mean": 0,
      "name": null,
      "range": null,
      "subscribed_events": [],
      "tags": [],
      "width": 1
    }

class `bokeh.models.transforms.``LinearInterpolator`(**kwargs)

  Bases: `bokeh.models.transforms.Interpolator`

  Compute a linear interpolation between the control points provided through the `x`, `y`, and `data` parameters.

JSON Prototype

    {
      "clip": true,
      "data": null,
      "id": "ecb0c814-42d5-4f54-91c5-2615c6853347",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "subscribed_events": [],
      "tags": [],
      "x": null,
      "y": null
    }

class `bokeh.models.transforms.``StepInterpolator`(**kwargs)

  Bases: `bokeh.models.transforms.Interpolator`

  Compute a step-wise interpolation between the points provided through the `x`, `y`, and `data` parameters.

  `mode`

    property type: `Enum` ( `StepMode` )

    Adjust the behavior of the returned value in relation to the control points. The parameter can assume one of three values:

    - `after` (default): Assume the y-value associated with the nearest x-value which is less than or equal to the point to transform.
    - `before`: Assume the y-value associated with the nearest x-value which is greater than the point to transform.
    - `center`: Assume the y-value associated with the nearest x-value to the point to transform.

JSON Prototype

    {
      "clip": true,
      "data": null,
      "id": "083ae23e-99cd-48c5-8fd7-1ff0185bb385",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "mode": "after",
      "name": null,
      "subscribed_events": [],
      "tags": [],
      "x": null,
      "y": null
    }

class `bokeh.models.transforms.``Transform`(**kwargs)

  Bases: `bokeh.model.Model`

  Base class for `Transform` models that represent a computation to be carried out on the client-side.

  JavaScript implementations should implement the following methods:

  Note

  This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

JSON Prototype

    {
      "id": "7746dd79-29f8-4ae4-b8b0-77baa8c0e764",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "subscribed_events": [],
      "tags": []
    }