Hey I'm having a lot of trouble trying to implement this example into my React project. The example is different to how I've set mine up and I can't convert it from their way to my way. I have a graph but I really would like the gradient colors to be included. This is as far as I got....
import React from 'react'
import { Chart } from 'react-charts'
class GraphClub extends React.Component {
constructor(props) {
super(props)
this.state = {
chartData: [
{
label: 'Won',
data: [
[0, 0],
],
},
],
}
}
componentDidMount() {
//Get chartData
}
render() {
return (
<>
<Chart
data={this.state.chartData}
axes={[
{
primary: true,
type: 'linear',
position: 'bottom',
show: this.props.axis,
},
{
type: 'linear',
position: 'left',
show: this.props.axis,
},
]}
series={{ type: 'line', showPoints: false }}
tooltip
/>
</>
)
}
}
export default GraphClub
The graph works but when I try and add the colors I can't get very far without getting errors. Would love some help.
Thanks
My first error is
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
Which is obvious seeing as it's a class component and not a functional on this line const [{ activeSeriesIndex, activeDatumIndex }, setState] = React.useState({