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

Method _create_panzoom_model

js/src/Toolbar.ts:109–149  ·  view source on GitHub ↗
(figure)

Source from the content-addressed store, hash-verified

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

Callers 1

panzoomMethod · 0.95

Calls 1

getScalesMethod · 0.45

Tested by

no test coverage detected