d3.max() is indeed returning the maximum value... however, it is returning the maximum value among strings, not among numbers.
The explanation is that, by default,
d3.csv() will load all the values as strings, even if they are numbers. Therefore, when you do:
var value = record[year];
var myArray = [1, 65, 9, 32, 42]; console.log(d3.max(myArray));
That's the expected value. But look what happens if we use strings:
var myArray = ["1", "65", "9", "32", "42"]; console.log(d3.max(myArray));
Solution: change your values to numbers:
var value = +record[year];
- d3.max() not returning the max value in an array?
- D3 - Returning the whole array with the max count
- getBoundingClientRect() not returning the correct value on window restore down
- C3 bargraph going upper-side if we give y axis max value and the data array are same
- x-axis tick is not incremented correctly and it is set to the max value of y
- d3.js - max and min value from json data which has array of values
- Why is my call to selection.join() not returning the enter selection?
- How to get the specific JSON array from a value in that array
- D3.js: "On the fly" added elements to array are not refreshing the svg graphic
- Get the real max of an array in D3
- Return value from JSON, not the children count
- Chart is not showing the data array of objects
- d3 js transition over the array of rectangles does not work
- d3js:The xaxis time is not showing the complete date value
- Line chart not hitting the right value on chart and has a smooth line
- Find the max value in a column in d3.js
- Get max value from array with multiple columns
- Find the max value for Y axis scaling across an arbitrary number of columns referenced indirectly
- Add line for y value based on the max x value
- d3 axis not showing tick label if two ticks have the same value
- D3 v4 url(#gradient) not returning the fill color
- Why the maximum variable take the d3.max() value but the minimum one d3.min() does not work properly?
- D3 : get value from the array
- D3 Accessing max value in 2d array of objects - brushing Y axis
- Maximum value of the second column of an array
- D3.js Traverse Through Nested Array to Find Max Value
- Understanding D3 data join using the new syntax - Array data is update but DOM not
- How to find min and max value in a array of objects
More Query from same tag
- d3.js Bar Chart transitions not working properly
- Change domain in D3
- How to use SVG gradients to display varying colors relative to the size of the colored region
- How to selectively zoom x and/or y in d3.js -- dynamically?
- D3.js Barchart: getting x-axis labels to line up with bars, and rotate them slightly
- Tooltips for multiple lines chart with legend click d3.js
- How to save the state of the Map view using angularjs and in JSON format?
- Where to store remote data in Svelte for responsive data vizualisations with Svelte and D3 (best practices)
- zoomable icicle d3 add label in chart
- D3 Force layout fix positions
- Real-time data with D3
- Why does ngDirective `template` allow for correct `clientHeight` but `templateUrl` gives 0
- The legend is not displayed correctly (text cut off) You can test it with jsbin
- How to create a line chart with vertical line and different backgrounds?
- D3 selectAll multiple classes AND or OR
- blank web page with d3.json(bardata.php) but works with d3.json(bardata.json)
- Click table, update line, hover over line, update table
- dc.js: stacked barchart cant display
- Customize stroke width of land
- D3 v4: Node position set to NaN
- How to fit the text in rectangle box of my svg in d3.js?
- d3 unable to append full data after filtering
- How to get the exact offset included in getBoundingClientRect top and bottom?
- Simple D3: turn a date object into an attractive string?
- D3JS line chart inverted issue
- Browser hangs when parsing dates
- d3js Moving SVG elements inside a transforming group
- Issue creating overlapping multiple pie charts (circular progress bars)
- How do I change the value of the y-axis by 30 instead of 10?