Last active
November 14, 2020 02:55
-
-
Save enthal/060290a72e8c29d9f160 to your computer and use it in GitHub Desktop.
series normalization per mouse-x (D3.js): https://bl.ocks.org/enthal/060290a72e8c29d9f160
This file contains hidden or 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> | |
| <meta charset="utf-8"> | |
| <style> | |
| svg .chart { | |
| fill: none; | |
| stroke: #000; | |
| stroke-width: 0.5px; | |
| } | |
| </style> | |
| <body></body> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script> | |
| <script> | |
| var series = []; | |
| for (var i=0;i<15;i++) { series.push(Math.pow(2,i)); } | |
| var width = 960, | |
| height = 500; | |
| var x = d3.scale.linear().range([0, width]); | |
| var y = d3.scale.linear().range([height, 0]); | |
| x.domain([0, series.length]); | |
| y.domain(d3.extent(series)); | |
| var svg = d3.select("body").append("svg") | |
| .attr("width", width) | |
| .attr("height", height); | |
| var chart = svg.append('g').classed('chart', true); | |
| chart | |
| .append('path').classed('series', true) | |
| .attr('d', d3.svg.line() | |
| .interpolate('basis') | |
| .x(function(d,i) { return x(i); }) | |
| .y(function(d) { return y(d); }) | |
| (series) ); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment