Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
D3.js 什么是d3.geo.pipeline?_D3.js_Pipeline_Geography - Fatal编程技术网

D3.js 什么是d3.geo.pipeline?

D3.js 什么是d3.geo.pipeline?,d3.js,pipeline,geography,D3.js,Pipeline,Geography,如果你关注Mike Bostock的bl.ocks,你就会知道在过去的8个月里,d3.geo.pipeline()一直是他项目中经常使用的组件 但它能做什么 你看到他这样设置管道: var sketch = d3.geo.pipeline() .source(d3.geo.jsonSource) .pipe(resample, .020) .pipe(jitter, .004) .pipe(smooth, .005) .sink(d3.

如果你关注Mike Bostock的bl.ocks,你就会知道在过去的8个月里,d3.geo.pipeline()一直是他项目中经常使用的组件

但它能做什么

你看到他这样设置管道:

var sketch = d3.geo.pipeline()
      .source(d3.geo.jsonSource)
      .pipe(resample, .020)
      .pipe(jitter, .004)
      .pipe(smooth, .005)
      .sink(d3.geo.jsonSink);

文档中没有文档

代码示例中使用的未发布D3中的一些美化JS揭示了此功能:

lo.geo.pipeline = function() {
        var n = [];
        return {
            source: function() {
                return n[0] = arguments, this
            },
            pipe: function() {
                return n.push(arguments), this
            },
            sink: function() {
                for (var t, e = arguments[0].apply(null, [].slice.call(arguments, 1)), r = e; t = n.pop();) {
                    var u = [].slice.call(t, 1);
                    u.push(e), e = t[0].apply(null, u)
                }
                return function() {
                    return e.apply(this, arguments), r.value && r.value()
                }
            }
        }
它也出现在这些bl.OCK中:


我不熟悉
d3.js
,但我查看了它的源代码,发现该功能位于分支
图形管道中

例如,您可以在此处找到相关代码:


演示其工作原理的小代码段:

var管道=函数(){
var管道=[];
返回{
资料来源:函数(){
管道[0]=参数;
归还这个;
},
管道:函数(){
管道。推送(参数);
归还这个;
},
接收器:函数(){
var sink=arguments[0]。应用(null,[].slice.call(arguments,1)),
管
while(pipe=pipes.pop()){
var args=[].slice.call(管道,1);
推进(下沉);
sink=pipe[0]。应用(null,args);
}
回流槽;
}
};
};
var log=document.getElementById('log');
函数f(){
var argsastring=Array.prototype.join.call(参数“,”);
var resultName='r'+f.callCounter++;
log.innerHTML+=resultName+'=f('+argsaString+')
; 返回结果名; } f、 callCounter=1; 管道()。 来源(f,'a',1)。 管道(f,'b',2)。 管道(f,'c',3)。 水槽(f,'d',4)
我确实在问题中发布了该功能的代码,但源链接是helpful@Incodeveritas,我添加了一些关于此功能的评论。@Incodeveritas,我再次更新了我的答案-也许现在它更有用了。