(mouse_pos, delta)
| 223 | } |
| 224 | |
| 225 | _zoom(mouse_pos, delta) { |
| 226 | if (delta) { |
| 227 | if (delta > 0) { |
| 228 | this.d3el.style('cursor', 'zoom-in'); |
| 229 | } else { |
| 230 | this.d3el.style('cursor', 'zoom-out'); |
| 231 | } |
| 232 | const mouse = { x: mouse_pos[0], y: mouse_pos[1] }; |
| 233 | const factor = Math.exp(-delta * 0.001); |
| 234 | return this.scale_promises.then((scale_views) => { |
| 235 | ['x', 'y'].forEach((dimension) => { |
| 236 | scale_views[dimension].forEach((view: any, index) => { |
| 237 | if (view.scale.invert) { |
| 238 | // Categorical scales don't have an inversion. |
| 239 | const scale = view.scale; //.copy().domain(this.domains_in_order[dimension][index]); |
| 240 | // convert the initial domain to pixel coordinates |
| 241 | let [domain_min, domain_max] = view.model.getDomainSliceInOrder(); |
| 242 | const pixel_min = scale(domain_min); |
| 243 | const pixel_max = scale(domain_max); |
| 244 | // take a weighted average between the mouse pos and the original pixel coordinate |
| 245 | // and translate that back to the domain |
| 246 | domain_min = scale.invert( |
| 247 | (1 - factor) * mouse[dimension] + factor * pixel_min |
| 248 | ); |
| 249 | domain_max = scale.invert( |
| 250 | (1 - factor) * mouse[dimension] + factor * pixel_max |
| 251 | ); |
| 252 | view.model.set('min', domain_min); |
| 253 | view.model.set('max', domain_max); |
| 254 | view.touch(); |
| 255 | } |
| 256 | }); |
| 257 | }); |
| 258 | }); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | active: boolean; |
| 263 | scale_promises: Promise<Dict<Scale[]>>; |
no outgoing calls
no test coverage detected