Built with blockbuilder.org
Created
January 30, 2019 03:06
-
-
Save cbertelegni/edd5b82134bb4e33bcf81a878a3aa452 to your computer and use it in GitHub Desktop.
Ellipse d3js
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
license: mit | |
scrolling: yes |
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
.ellipse-bg { fill: none; stroke:#000;stroke-width:1px} | |
.ellipse-data { fill: green; stroke: none;} | |
</style> | |
</head> | |
<body> | |
<script> | |
var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", 500) | |
let minMax = [1, 10] | |
let scaleX = d3.scaleLinear().domain(minMax).range([10, 50]) | |
let scaleY = d3.scaleLinear().domain(minMax).range([8, 25]) | |
console.log(scaleX(10)) | |
svg.append("ellipse") | |
.attr("cx", 150) | |
.attr("cy", 100) | |
.attr("rx", 50) | |
.attr("ry", 25) | |
.attr("class", "ellipse-bg") | |
let n = 5 | |
svg.append("ellipse") | |
.attr("cx", 150 + scaleX.range()[1] - scaleX(n)) | |
.attr("cy", 100) | |
.attr("rx", scaleX(n)) | |
.attr("ry", scaleY(n)) | |
.attr("class", "ellipse-data") | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment