function estimateIslandContours (projection, subclusters, options) {
const {
padding,
estimatorBandwidth,
estimatorThresholds,
numContours
} = options
const clusterR = (0.5 * getBoundingSquareSize(subclusters)) + padding
const estimatorSize = Math.round((clusterR / 3.0) * 600)
const estimatorProject = d3.scaleLinear()
.domain([-clusterR, clusterR])
.range([0, estimatorSize])
const projectedPapers = Array.prototype.concat.apply(
[],
subclusters.map(subcluster => {
const { papers } = subcluster
return papers.map(paper => {
return {
x: estimatorProject(paper.x + subcluster.x),
y: estimatorProject(paper.y + subcluster.y)
}
})
})
)
const densityEstimator = d3.contourDensity()
.size([estimatorSize, estimatorSize])
.x(d => d.x)
.y(d => d.y)
.bandwidth(estimatorBandwidth)
.thresholds(estimatorThresholds)
const contours = densityEstimator(projectedPapers)
return {
contours: contours.slice(0, numContours),
domain: [-clusterR, clusterR],
estimatorSize: estimatorSize
}
}