Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created October 3, 2022 13:41
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/b16d63c6e1cce99d6dbe581a034f5823 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/b16d63c6e1cce99d6dbe581a034f5823 to your computer and use it in GitHub Desktop.
Line Chart Properties
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