How to invert the grid in d3.js

后端 未结 2 769
心在旅途
心在旅途 2020-12-12 00:40

Hi i have drawn a grid with 5 x-lines and 5 y-lines. The problem is that in svg the y direction falling downwards so my grid y lines falling downwards, to get grid in upward

2条回答
  •  北海茫月
    2020-12-12 01:18

    It's not clear to me exactly what you want to achieve. If you want to change the mapping of Y values so that more positive data values correspond to a position "higher" on the page, then, as others have suggested, scales are the right approach.

    If you simply want to change the text that's shown on mouseover events, you can do that in the code directly, e.g.

    .text("X:" + pos[0] + ";Y:" + (y_max - pos[1]));
    

提交回复
热议问题