Skip to content Skip to sidebar Skip to footer

D3 Workaround For Svg Transform In Chrome

I've created an inner dimension to cut off plotting in d3. Here is the code: var svg = d3.select('body').append('svg') .attr('width', width) .attr('height', height)

Solution 1:

You can set x and y attributes on your nested SVG to create a translation of coordinates.

var svg = d3.select("body").append("svg")
        .attr("width", width)
        .attr("height", height);

var nestedSVG = svg.append('svg') 
        .attr("width", innerWidth)
        .attr("height", innerHeight)
        .attr("x", margin.left)
        .attr("y", margin.top);

For more complicated transforms, you would use a parent or child <g> element and transform that, as you mentioned in comments to your previous question.

Post a Comment for "D3 Workaround For Svg Transform In Chrome"