This example demonstrates how to build a nested hierarchy from a streaming datasource.
Groups in the hierarchy are generated and sorted "on demand" as they are pulled from the data$
Observable.
Rx.Observable.groupBy()
produces GroupedObservable
s which are scanned
into arrays and then combined using flatMapLatest(Rx.Observable.combineLatest)
.
(Note: It's important to shareReplay
the GroupedObservables
)
This example also uses babel-standalone
to enable in-browser ES6 features.
xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.4/babel.min.js"></script>
<title>Streaming Hierarchy</title>
</head>
<body>
<script>
d3.text('script.js', function(source) {
var compiled = Babel.transform(source, { presets: ['es2015'] }).code;
(new Function(compiled))();
});
/* global Babel, d3 */
</script>
</body>
</html>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.all.min.js
https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.4/babel.min.js