How to find the max/min of a nested array in javascript?

If you have a nested array of numbers (arrays = [[1, 2], [20, 3]]), nest d3.max: var max = d3.max(arrays, function(array) { return d3.max(array); }); Or equivalently, use array.map: var max = d3.max(arrays.map(function(array) { return d3.max(array); })); If you want to ignore string values, you can use array.filter to ignore strings: var max = d3.max(arrays, … Read more

Recharts: Turn off background hover for bar charts

You can use the cursor prop on the <Tooltip /> to achieve what you need: <Tooltip cursor={{fill: ‘#f00’}} /> Here‘s a working fiddle I made based on some example from their docs. You can simply use transparent as a value for the fill property. const {BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend} = Recharts; const … Read more

reversed Y-axis D3

Maybe this will help. http://jsfiddle.net/S575k/4/ A few notes: I reversed your y domain range from .range([0, h-margin]); to .range([h-margin, 0]); This will fix the issue of the y-axis marks going in the wrong direction because the browser consider’s the origin (0,0) point to the the upper-left corner, and not the bottom-left corner like in math. … Read more

SVG: why does external css override inline style for text?

Because in SVG, like HTML before it, styles trump attribute styling. fill=”red” below is NOT an “inline style”, style=”fill:green” IS an inline style. <svg width=”400″ height=”400″> <text x=”50″ y=”50″ fill=”red” style=”fill:green”>This will be green</text> </svg> Like wise, if you have a style defined outside, it will win. <style> text { fill: lime; } </style> <svg … Read more

How to use an arrow marker on an SVG element?

If you meant ‘how do I use an arrow marker on a <line> element?’ then here’s how you do that: <line x1=”100″ y1=”230″ x2=”300″ y2=”230″ marker-end=”url(#yourMarkerId)” stroke=”black” stroke-width=”10″/> Here’s a full example. And note that marker-end is a css property, so you can also put that part in a stylesheet if you want. If you … Read more