Forum Discussion
Which API will allow users to click and drag my visual
dm-p Can you tell me: do I need to build mouseDown, mouseUp and dragging handlers for my visual to achieve click and drag? Mine has a full height, full width rect element. If I remove suppressDefaultTitle, I can drag in the title area but not within the svg area. I guess Microsoft have built drag handlers, and they also differentiate between click (to select) and drag over, for example, segments within a pie chart. Can custom visual developers even access the x,y location of the sandbox? I can't see this in any examples online: https://github.com/microsoft/PowerBI-visuals-sampleBarChart/blob/main/src/barChart.ts
- dm-p2 years ago
Super User
It's not possible to affect the position or size of a custom visual programmatically. The behavior (whilst frustrating) is standard for all custom visuals. Anything in the 'General' properties menu cannot be read or written to, unless MS provides a specific API for it via the visual host services.
If you're comparing with the core visuals, there is a big difference in how there are integrated into a page - they are part of the same DOM. Custom visuals are comprised of a container (which is owned by MS and ocntains all 'standard' logic and events to make their behaviour consistent). This is also hosted in the same DOM, but then includes the sandboxed iframe that hosts your visual. As such the higher-level container that holds your visual's host element cannot be overridden using CSS or JS, as it cannot reach 'above' the iframe.