{"size": 711, "ext": "js", "max_stars_repo_path": "react/data_generator/src/utils/get-converted-scale.js", "max_stars_repo_name": "Michael1104Smith/Michael1104Smith.github.io", "max_stars_repo_stars_event_min_datetime": "2020-02-04T16:58:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-04T16:58:53.000Z", "max_issues_repo_path": "react/data_generator/src/utils/get-converted-scale.js", "max_issues_repo_name": "wdev733/wdev733.github.io", "max_issues_repo_issues_event_min_datetime": "2017-03-13T10:20:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T09:51:42.000Z", "max_forks_repo_path": "react/data_generator/src/utils/get-converted-scale.js", "max_forks_repo_name": "wdev733/wdev733.github.io", "max_forks_repo_forks_event_min_datetime": "2022-01-30T13:17:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T13:17:36.000Z"}
{"max_stars_count": 1, "max_issues_count": 16, "max_forks_count": 1, "avg_line_length": 32.3181818182, "max_line_length": 119, "alphanum_fraction": 0.7496483826}
import { scaleLinear } from 'd3-scale'

const getConvertedScale = ({height, width, chartProportion, marginProportionLeft, xUpper, xLower, yUpper, yLower}) => {
	const chartHeight = height * chartProportion
	const chartWidth = width * chartProportion
	const margin = {
		y: height - chartHeight,
		x: width - chartWidth
	}
	const marginProportionRight = 1 - marginProportionLeft

	const leftMargin = margin.x * marginProportionLeft
	const topMargin = margin.y * marginProportionRight

	return {
		x: scaleLinear().domain([xLower, xUpper]).range([leftMargin, chartWidth + leftMargin]),
		y: scaleLinear().domain([yLower, yUpper]).range([chartHeight + topMargin, topMargin])
	}
}

export default getConvertedScale
