Closed cbartram closed 4 years ago
this seems to be because you are misusing the tooltip prop. tooltip expects a memoized object that has align and anchor properties see this example.
@cbartram did @tylerthehaas 's example solve the issue for you?
It did thank you
question about this issue though, because in this other example from the docs that I am using, there is no align or anchor properties, but I still get the cannot read 0 of null error
function CustomTooltip({ getStyle, primaryAxis, datum }) {
const data = React.useMemo(
() =>
datum
? [
{
data: datum.group.map(d => ({
primary: d.series.label,
secondary: d.secondary,
color: getStyle(d).fill
}))
}
]
: [],
[datum, getStyle]
)
https://react-charts.js.org/examples/custom-tooltip
*Edit, and I am only displaying one series
this seems to be because you are misusing the tooltip prop. tooltip expects a memoized object that has align and anchor properties see this example.
Does it though? Because As I was stepping through the code, if they are not there on the passed in tooltip, Charts will just add it on itself.
I am prettu sure it doesnt, because even if you delete those 2 options from the example in the sandbox, it still works perfectly fine.
I think this issue also ties into this other issue https://github.com/tannerlinsley/react-charts/issues/129, because when my secondary data point is equal to 0, the chart does not show the point, I get no error, and the chart renders with missing points. However, when I add .000001, to my secondary data points, the points all render and the line is drawn (if i leave out the tooltip)
I am trying to render a simple line chart with multiple series. My data is formatted like this according to the example:
Whenever the data renders in the chart it throws the following error:
Here is my component and how I am using the it:
Oddly enough changing out the data with the example data seems to solve the issue. I just dont understand why its happening with my data because they are both formatted exactly the same.