How to use the @jupyter-widgets/base.uuid function in @jupyter-widgets/base

To help you get started, we’ve selected a few @jupyter-widgets/base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bloomberg / bqplot / js / src / MarketMap.ts View on Github external
render(options?) {
        this.id = widgets.uuid();

        const figureSize = this.getFigureSize();
        this.width = figureSize.width;
        this.height = figureSize.height;

        this.scales = {};
        this.set_top_el_style();
        const that = this;
        this.margin = this.model.get("map_margin");
        this.num_rows = this.model.get("rows");
        this.num_cols = this.model.get("cols");
        this.row_groups = this.model.get("row_groups");
        this.enable_select = this.model.get("enable_select");

        this.update_data();
        // set the number of rows and columns in the map
github maartenbreddels / ipywebrtc / js / src / webrtc.js View on Github external
initialize() {
        super.initialize.apply(this, arguments);
        this.set('room_id',  widgets.uuid());
        this.room_id = this.get('room_id');
        this.room = this.get('room');
        this.peers = {}; // room_id (string) to WebRTCPeerModel
        window['last_webrtc_room_' + this.room_id] = this;
        const stream = this.get('stream');
        if (stream) {
            this.set('streams', [stream]);
        }
        this.save_changes();
        this.on('msg:custom', this.custom_msg, this);
    }
    custom_msg(content) {
github bloomberg / bqplot / js / src / Figure.js View on Github external
if (typeof min_width === "string" && min_width.endsWith('px')) {
            min_width = Number(min_width.slice(0, -2));
        } else {
            min_width = undefined;
        }
        if (typeof min_height === "string"  && min_height.endsWith('px')) {
            min_height = Number(min_height.slice(0, -2));
        } else {
            min_height = undefined;
        }

        var impl_dimensions = this._get_height_width(min_height, min_width);
        this.width = impl_dimensions["width"];
        this.height = impl_dimensions["height"];

        this.id = widgets.uuid();

        // Dictionary which contains the mapping for each of the marks id
        // to it's padding. Dictionary is required to not recompute
        // everything when a mark is removed.
        this.x_pad_dict = {};
        this.y_pad_dict = {};

        // this is the net padding in pixel to be applied to the x and y.
        // If there is no restriction on the plottable area of the figure,
        // then these two variables are the maximum of the values in the
        // corresponding variables x_pad_dict, y_pad_dict.
        this.x_padding_arr = {};
        this.y_padding_arr = {};

        this.figure_padding_x = this.model.get("padding_x");
        this.figure_padding_y = this.model.get("padding_y");
github jupyter-widgets / jupyterlab-sidecar / tests / src / utils.spec.ts View on Github external
function createTestModel(constructor: Constructor, attributes?: any): T {
  let id = widgets.uuid();
  let widget_manager = new DummyManager();
  let modelOptions = {
      widget_manager: widget_manager,
      model_id: id,
  }

  return new constructor(attributes, modelOptions);
}
github vidartf / jupyter-vtk-datawidgets / tests / src / utils.spec.ts View on Github external
function createTestModel(
    constructor: Constructor,
    attributes?: any,
    widget_manager?: DummyManager): T {
  let id = widgets.uuid();
  if (widget_manager === undefined) {
    widget_manager = new DummyManager();
  }
  let modelOptions = {
      widget_manager,
      model_id: id,
  }

  return new constructor(attributes, modelOptions);
}
github uber / deck.gl / test / modules / jupyter-widget / utils.spec.js View on Github external
export function createTestModel(constructor, attributes) {
  const id = widgets.uuid();
  const widget_manager = new DummyManager();
  const modelOptions = {
    widget_manager,
    model_id: id
  };
  return new constructor(attributes, modelOptions);
}
github bloomberg / bqplot / js / src / Map.ts View on Github external
render() {
        const base_render_promise = super.render();

        this.map = this.d3el.append("svg")
            .attr("viewBox", "0 0 1200 980");
        this.width = this.parent.plotarea_width;
        this.height = this.parent.plotarea_height;
        this.map_id = widgets.uuid();
        this.enable_hover = this.model.get("enable_hover");
        this.display_el_classes = ["event_layer"];
        this.displayed.then(() => {
            this.parent.tooltip_div.node().appendChild(this.tooltip_div.node());
            this.create_tooltip();
        });

        return base_render_promise.then(() => {
            this.event_listeners = {};
            this.process_interactions();
            this.create_listeners();
            this.draw();
        });
    }
github maartenbreddels / ipywebrtc / js / src / webrtc.js View on Github external
defaults() {
        return {...super.defaults(),
            _model_name: 'WebRTCRoomModel',
            //_view_name: 'WebRTCRoomView',
            _model_module: 'jupyter-webrtc',
            //_view_module: 'jupyter-webrtc',
            _model_module_version: semver_range,
            _view_module_version: semver_range,
            room: 'room',
            stream: null,
            room_id: widgets.uuid(),
            nickname: 'anonymous',
            peers: [],
            streams: []
        };
    }
    log() {
github bloomberg / bqplot / js / src / Mark.js View on Github external
render: function() {
        this.x_padding = 0;
        this.y_padding = 0;
        this.parent = this.options.parent;
        this.uuid = widgets.uuid();
        var scale_creation_promise = this.set_scale_views();
        var that = this;
        this.listenTo(this.model, "scales_updated", function() {
            this.set_scale_views().then(_.bind(this.draw, this));
        }, this);

        this.colors = this.model.get("colors");

        if(this.options.clip_id && this.model.get("apply_clip")) {
            this.d3el.attr("clip-path", "url(#" + this.options.clip_id + ")");
        }
        this.tooltip_div = d3.select(document.createElement("div"))
            .attr("class", "mark_tooltip")
            .attr("id", "tooltip_" + this.uuid)
            .style("display", "none")
            .style("opacity", 0);
github bloomberg / bqplot / js / src / Mark.ts View on Github external
render: function() {
        this.x_padding = 0;
        this.y_padding = 0;
        this.parent = this.options.parent;
        this.uuid = widgets.uuid();
        var scale_creation_promise = this.set_scale_views();
        this.listenTo(this.model, "scales_updated", function() {
            this.set_scale_views().then(_.bind(this.draw, this));
        }, this);

        this.colors = this.model.get("colors");

        if(this.options.clip_id && this.model.get("apply_clip")) {
            this.d3el.attr("clip-path", "url(#" + this.options.clip_id + ")");
        }
        this.tooltip_div = d3.select(document.createElement("div"))
            .attr("class", "mark_tooltip")
            .attr("id", "tooltip_" + this.uuid)
            .style("display", "none")
            .style("opacity", 0);