Created
October 3, 2022 13:41
-
-
Save PaulieScanlon/b16d63c6e1cce99d6dbe581a034f5823 to your computer and use it in GitHub Desktop.
Line Chart Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
const LineChart = ({ data }) => { | |
... | |
+ const properties = data.map((property, index) => { | |
+ const { total, date } = property; | |
+ const x = (index / data.length) * (chartWidth - paddingX) + paddingX / 2; | |
+ const y = chartHeight - offsetY - (total / maxY) * (chartHeight - (paddingY + offsetY)) - paddingY + offsetY; | |
+ return { | |
+ total: total, | |
+ date: date, | |
+ x: x, | |
+ y: y | |
+ }; | |
+ }); | |
return null; | |
}; | |
export default LineChart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment