Your other option is to ensure the former 'canvasBars' variable is actually the canvas.
var svgSelection = d3.select("#chart1").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) var baseGroup = svgSelection.append("g") .attr("transform", "translate("+margin.left+","+margin.top+")");
Your former 'canvasBars' I have renamed to 'svgSelection'. If you want to modify the "canvas" directly, your former idea will now work.
svgSelection.attr("width", width + margin.left + margin.right);
- D3: Select SVG attribute and change it
- D3 how to change the width and length of SVG
- Change a shadow opacity partially in svg using filters and d3.js
- viewBox attribute with svg height and width attributes set
- How to change json file in d3.js and update chart using select options
- Select specific elements and change style of one
- Change height and width of the path tag in SVG Image
- How to use d3.js to select an svg element and modify its attr?
- Filter nodes by weight and change attribute
- D3.js: change bar color AND another svg color on click
- button ouside d3.js svg to select and modify d3.js elements
- d3.js: tooltip and attribute change on mouseover
- Cleaner and better way to select and change colour of circles in d3
- How can I choose an specific SVG in d3 and change its attributes?
- Responsive SVG with d3.js and height attribute
- D3 - Select SVG center path when drilled into and display zoom out background image
- d3 Select and modify g elements within svg elements
- d3.js select nodes and change their style
- Two overlaying svg texts - select and copy just one
- How to select a particular element in g elements and change its status in D3.js
- I cannot select the ("text") in my svg when I want to change the values
- D3 arc and SVG 2d to 3d perspective change
- D3.js cluster rollover - how to select and change another element
- D3 and jQuery - Ajax success function fill color change is not applied to D3 SVG
- How do I save/export an SVG file after creating an SVG with D3.js (IE, safari and chrome)?
- State of SVG Performance on iOS and other Tablets?
- Difference between svg and canvas in d3.js
- Title Attribute not working for an SVG Rect on Safari
More Query from same tag
- Resize function for responsive d3
- Improper transition along path in d3 with leaflet
- Map zoom and pan in d3 js v4 + scale limit
- Flatten D3.js Nested Data or Map it to new Dataset
- Django and d3.js: CSV data
- D3 line() setting d attribute returns NaN
- Linechart with JSON object in dc.js
- d3 image is rendering outside the table
- D3js: "How to append distinct paths for distinct values?"
- get point coordination using path.getPointAtLength after rotation in d3 and svg
- D3 Animate One Path Series At a Time
- Pass params to q.defer (d3.csv)
- How can i add an image inside nvd3 piechart slices?
- How to change easing in d3 pathTween function
- D3.js: How to select data from graph's brushed area?
- d3.js parallel coordinates line thickness issue
- How to get identical colors for categories between different plots in Dimple
- Coordinates of each center's arc in a pie chart
- D3, Multidimensional data and enter()
- add more circles to my emananting animation in d3.js
- How to generate multiple SVG's in a Meteor.js #each wrapper
- d3 pie chart all black fill, d3.schemeCategory20c not being called
- d3.js translate header text above or below a circle based on array index
- D3 - X Axis labels are overlapping
- Uncaught SyntaxError: missing ) after argument list when using Object.assign await
- Change the height of rect element drawn by d3.js with a jQuery ui slider
- Updating graph as I drag a point around
- Remove white space in d3 table
- dc.js responive geojson US map