简体   繁体   中英

d3.js radial line counterclockwise

Is there a way to draw the radial line in this example counterclockwise in order to have the arc on top/ in the upper-half?

http://bl.ocks.org/sjengle/5431779

You'll obviously have to make several changes to the example to rearrange the nodes, but the easiest way to reverse the direction of the arc is to change the range.

Existing code:

// scale to generate radians (just for lower-half of circle)
var radians = d3.scale.linear()
    .range([Math.PI / 2, 3 * Math.PI / 2]);

Modified version:

// scale to generate radians (just for upper-half of circle)
var radians = d3.scale.linear()
    .range([3 * Math.PI / 2, Math.PI / 2]);

Terrible (but working) solution: set the radius the negative value.

arc.radius(-xdist / 2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM