score:1
Accepted answer
With multiple lines of code, your arrow function needs curly braces
d3.json(url).then(function(data) {
for (let i = 0; i < data.data.length; i++) arr[i] = data.data[i];
}).then(() => {
yScale = d3.scaleLinear()
.domain([0, d3.max(arr, (d) => d[1])])
.range([460, 0]);
svg.selectAll('rect')
.data(arr)
.enter()
.append('rect')
.attr('fill', 'blue')
.attr('height', d => d[1])
.attr('width', 3)
.attr('x', (d, i) => 4 * i)
.attr('y', (d, i) => yScale(d[1]))
});
Source: stackoverflow.com
Related Query
- How to set up the scale with d3js?
- how to set up the scale of yAxis in D3.js with a csv file with multiple columns
- how to set the domain and scale on an axis on a nvd3.js multiBarChart
- D3js: How do I clear the zoom scale set by the d3.zoom event?
- How to set the domain and scale on an yaxis on a discreteBarChart nvd3.js
- How can I set the position of a drop down list with D3.js?
- d3js gantt chart with date/time scale at the top and current day blue line
- D3, Scale How to set the scale?
- How to define a scale with intervals with d3js
- How to set up custom color scale with multiple sub-parts in D3?
- D3JS how to get the y postition with bisector?
- How to set the browser window size according to D3JS graph?
- d3js - Stacked Bar Chart in Horizontal Axis - How do I set x so the bars are seperated?
- How to scale bars of barchart so it shows the complete graph with data
- How to set a scale for the time series, current x scale gives me NaN?
- d3js - how to filter the array with values and pass in to data?
- How to control the number of tick values in a graph with d3js
- how to make text on d3js graph scale together with graph?
- how do I set up a grouping query on the server side. I want set up the query so I can use it for a pie chart in front end, using d3js
- How to combine two CSV files into the same graph with d3js
- How to create a bar chart with C3 that doesn't group all columns in the same set
- D3js linear color scale with custom dates in top of the margin
- How can I bring a circle to the front with d3?
- How to set multiple attributes with one value function?
- How to set the background-color of a D3.js svg?
- d3.js - How can I set the cursor to hand when mouseover these elements on SVG container?
- D3: Create a continuous color scale with many strings/inputs for the range and dynamically changing values of the domain
- How to customize the color scale in a D3 line chart?
- D3js how to append 2 children at the same level in .enter context
- MultiBar chart with nvd3 / d3 only shows labels for every other tick on the x-axis. How can I get them all to show up?
More Query from same tag
- D3 - Add a raw symbol
- In D3.js how do I rotate SVG's in a continous circular fashion
- Formatting D3.js chart for months end
- d3.js: Drag is disabled when use zoom
- Add labels under every bar of the grouped bar chart on D3
- Sorting the bars and getting the group data in a grouped bar chart
- Register mouse events on overlapping Elements
- D3 data format like zoomable sunburst chart
- Making a D3 widget scrollable
- how to show properties of a featureCollection in d3 (using the mouse)
- How to change table cell color based on numeric value from .csv report AND when tables are dynamically created?
- Append css to svg in D3
- Wrong labels in x-axis when using time-series bar chart
- How to fix CORS error to serve fake development data
- Map D3.js - ogr2ogr installation
- D3.js - Create multi-ring donut chart dataset from JSON
- Unable to parse date format in Javascript
- D3 - drawing a line between two object not intersecting other objects
- issue with displaying png images of tree layout are not getting displayed in safari browser(windows)
- Filtering Leaflet Map based on dropdown selection in D3
- Drop down button to filter a d3.js graph
- c3js Multi color design
- Aster Plot legend labels along with the arc
- Transitions occur slowly while a d3.drag() is occuring
- D3,js on mouse event CLICK appending only the first image from data set
- Unable to sort the element in nested json
- Replace broken image using ONLY javascript
- D3.js is not recognized by PyCharm
- Cannot run python SImpleHTTPServer on windows 10 for d3.js testing (issue changing environment variable)
- AngularJS directive not updating D3 circle pack chart