Skip to content

Instantly share code, notes, and snippets.

@grahampullan
Last active April 8, 2018 00:28
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 grahampullan/6c79f396a87ff386ef56fa6dde170cb0 to your computer and use it in GitHub Desktop.
Save grahampullan/6c79f396a87ff386ef56fa6dde170cb0 to your computer and use it in GitHub Desktop.
dbslice.d3LineSeries
license: mit

A minimal dbslice.d3LineSeries plot example.

The github repository for dbslice is here.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="http://dbslice.org/dbslice.css">
</head>
<body>
<div id = "target" style = "width:400px"> </div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
<script src="http://dbslice.org/d3-tip.js"></script>
<script src="http://dbslice.org/dbslice.js"></script>
<script>
var series = [];
var n = 50;
var m = 10;
for ( var j = 0.; j < m; ++j ) {
var line = {
data : [],
label : "Line " + j
};
for ( var i = 0.; i < n; ++i ) {
var point = {
x : i/n,
y : 0.125 * Math.cos( i/n * 2 * Math.PI) * (1 - Math.cos( j/m * 2 * Math.PI) )
};
line.data.push( point );
}
series.push( line );
}
var data = { series : series };
var layout={ height : 400, xAxisLabel : "x axis", yAxisLabel : "y axis" };
dbslice.d3LineSeries.make( document.getElementById("target"), data, layout);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment