javascript - How to center title over SVG chart with d3.js? -
demo: http://jsfiddle.net/29j6ozqn/
i've created simple svg 2 axes , appended text
element serve title of chart. can't find reliable way center title on midpoint of chart. i'd middle of text element aligned on '0.5' tick on x-axis. me, visually, that's middle of chart.
i'd solution generic, meaning doesn't matter how long text string is, middle on '0.5'. shouldn't matter type of axis x-axis (whether it's linear, ordinal, etc.)
use text-anchor: middle
or text-align: center
instead of text-anchor: start
: fiddle.
javascript css svg d3.js text-align
No comments:
Post a Comment