Detect mouseover of certain points within an HTML canvas?

前端 未结 7 1134
予麋鹿
予麋鹿 2020-12-02 14:45

I\'ve built an analytical data visualization engine for Canvas and have been requested to add tooltip-like hover over data elements to display detailed metrics for the data

相关标签:
7条回答
  • 2020-12-02 15:19

    This can't be done (well, at least not that easily), because objects you draw on the canvas (paths) are not represented as the same objects in the canvas. What I mean is that it is just a simple 2D context and once you drawn something on it, it completely forgets how it was drawn. It is just a set of pixels for it.

    In order to watch mouseover and the likes for it, you need some kind of vector graphics canvas, that is SVG or implement your own on top of existing (which is what Sam Hasler suggested)

    0 讨论(0)
提交回复
热议问题