Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created October 3, 2022 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulieScanlon/6c556396aa3cfb34f2891364c4382a5b to your computer and use it in GitHub Desktop.
Save PaulieScanlon/6c556396aa3cfb34f2891364c4382a5b to your computer and use it in GitHub Desktop.
Creating the Guides
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