Created
October 3, 2022 13:49
-
-
Save PaulieScanlon/6c556396aa3cfb34f2891364c4382a5b to your computer and use it in GitHub Desktop.
Creating the Guides
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 }) => { | |
... | |
return ( | |
<svg viewBox={`0 0 ${chartWidth} ${chartHeight}`} role="presentation"> | |
... | |
+ {guides.map((_, index) => { | |
+ const ratio = index / guides.length; | |
+ const y = chartHeight - paddingY - chartHeight * ratio; | |
+ | |
+ return <polyline key={index} className="stroke-gray-200" fill="none" strokeWidth={1} points={`${paddingX / 2},${y} ${chartWidth - paddingX / 2},${y}`} />; | |
+ })} | |
... | |
</svg> | |
); | |
}; | |
export default LineChart; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment