import React from 'react'; import { Chart, ChartAxis, ChartGroup, ChartLine, ChartScatter, ChartThemeColor, ChartVoronoiContainer } from '@patternfly/react-charts'; export default class ScatterLineChart extends React.Component { constructor(props) { super(props); this.containerRef = React.createRef(); this.state = { width: 0, series: "", }; this.handleResize = () => { if (this.containerRef.current && this.containerRef.current.clientWidth) { this.setState({ width: this.containerRef.current.clientWidth }); } }; } componentDidMount() { this.handleResize(); window.addEventListener('resize', this.handleResize); } componentWillUnmount() { window.removeEventListener('resize', this.handleResize); } render() { const { width } = this.state; var conv = [] var maxYAxis = 0 this.props.data.forEach(e => { var floatValue = parseFloat(e.value); if(floatValue > maxYAxis) { maxYAxis = floatValue } const date = new Date(e.date) const dateString = `${date.getDate()}/${date.getMonth() + 1}` conv.unshift({ name: this.props.target, x: dateString, y: floatValue }) }); const series = [ { datapoints: conv, legendItem: { name: 'Conversion' } } ]; return (