MCPcopy Index your code
hub / github.com/bqplot/bqplot / create_panzoom_model

Method create_panzoom_model

js/src/FigureModel.ts:117–152  ·  view source on GitHub ↗

* Creates a panzoom interaction widget for the this model. * * It will discover the relevant scales of this model.

()

Source from the content-addressed store, hash-verified

115 * It will discover the relevant scales of this model.
116 */
117 private create_panzoom_model(): Promise<PanZoomModel> {
118 return this.widget_manager
119 .new_widget({
120 model_name: 'PanZoomModel',
121 model_module: 'bqplot',
122 model_module_version: this.get('_model_module_version'),
123 view_name: 'PanZoom',
124 view_module: 'bqplot',
125 view_module_version: this.get('_view_module_version'),
126 })
127 .then((model: PanZoomModel) => {
128 return Promise.all(this.get('marks')).then((marks: any[]) => {
129 const x_scales = [],
130 y_scales = [];
131 for (let i = 0; i < marks.length; ++i) {
132 const preserve_domain = marks[i].get('preserve_domain');
133 const scales = marks[i].getScales();
134 _.each(scales, (v, k) => {
135 const dimension = marks[i].get('scales_metadata')[k]['dimension'];
136 if (dimension === 'x' && !preserve_domain[k]) {
137 x_scales.push(scales[k]);
138 }
139 if (dimension === 'y' && !preserve_domain[k]) {
140 y_scales.push(scales[k]);
141 }
142 });
143 }
144 model.set('scales', {
145 x: x_scales,
146 y: y_scales,
147 });
148 model.save_changes();
149 return model;
150 });
151 });
152 }
153
154 /**
155 * Reset the scales, delete the PanZoom widget, set the figure

Callers 1

panzoomMethod · 0.95

Calls 1

getScalesMethod · 0.45

Tested by

no test coverage detected