kcnarf / d3-voronoi-map Goto Github PK
View Code? Open in Web Editor NEWD3 plugin which computes a map (one-level treemap) based on a Voronoi tesselation
License: BSD 3-Clause "New" or "Revised" License
D3 plugin which computes a map (one-level treemap) based on a Voronoi tesselation
License: BSD 3-Clause "New" or "Revised" License
Code line: https://github.com/Kcnarf/d3-voronoi-map/blob/master/src/flickering-mitigation.js#L129
It logs flickering mitigation ratio: X.XX
when really it shouldn't unless in development mode
I don't fully understand what this function does! But I found while processing large trees, sometimes this function loops forever.
For a test case, I logged the following mapPoints data after 10,000 iterations:
[
{
index: 0,
targetedArea: 6.63625453479814,
data: {
index: 0,
weight: 15,
initialPosition: [Array],
initialWeight: 1.253514745461871,
originalData: [Object]
},
x: 605.9975186232019,
y: 328.2152273626913,
weight: 4318.240094720243
},
{
index: 1,
targetedArea: 0.4424169689865427,
data: {
index: 1,
weight: 1,
initialPosition: [Array],
initialWeight: 1.253514745461871,
originalData: [Object]
},
x: 607.1700362606578,
y: 329.4272560895722,
weight: 4320.083905965173
},
{
index: 2,
targetedArea: 0.4424169689865427,
data: {
index: 2,
weight: 1,
initialPosition: [Array],
initialWeight: 1.253514745461871,
originalData: [Object]
},
x: 607.3920808696175,
y: 329.9778254838309,
weight: 4320.73147549891
}
]
It seems to be endlessly increasing the weights without stopping.
Note if I switch to handleOverweightedVariant = 0 I don't have this problem (but I'm not sure what the implications of the two algorithms are)
Thanks for this great library @Kcnarf ! Really enjoying exploring data with this lib and the d3-voronoi-treemap
. I want to be able to create a deterministic layout so if I send the same data and parameters it always creates the same layout voronoi. What is the best way to achieve this?
I want to try this code on svelte REPL, and after I write
import { voronoiMapSimulation } from 'd3-voronoi-map'
it shows warning:
'default' is not exported by https://unpkg.com/[email protected]/src/index.js, imported by https://unpkg.com/[email protected]/build/d3-weighted-voronoi.js
because I use REPL, so I didn't use npm install for dependencies
Hi, I am using this library to draw Voronoi map and meet a weird bug keep reporting:
The error keeps popping out and flushed the console. And sometimes the script stops at the following breakpoint:
console.log('at least 1 site has no area, which is not supposed to arise');debugger;
I have paid lots of efforts to filter out other possible origins of the bug and please see a minimal example for the bug as follows. Please note that this bug seems to be present at random, and you may need to refresh the browser multiple times to see the complaints.
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v5.min.js"></script>
<script src="https://rawcdn.githack.com/Kcnarf/d3-weighted-voronoi/v1.0.0/build/d3-weighted-voronoi.js"></script>
<script src="https://rawcdn.githack.com/Kcnarf/d3-voronoi-map/v2.0.0/build/d3-voronoi-map.js"></script>
<style>
#glyphDiv {
height: 800px;
width: 1000px;
overflow: scroll;
}
</style>
</head>
<body>
<div id='glyphDiv'>
</div>
</body>
<script type="text/javascript">
var data = [
{size: 0.1},
{size: 0.2},
{size: 0.3},
{size: 0.4},
]
var simu_list = [];
function test () {
var simulation = d3.voronoiMapSimulation(data)
.clip([[-6,10],[-12,0],[-62,0],[-31,54]])
.weight(function(d) {return d.size})
simu_list.push(simulation);
}
for(var i = 0; i < 100; i ++) {
test();
}
</script>
</html>
Could anyone help me out?
I don't think there is any random element in the following observable
https://beta.observablehq.com/@fil/voronoi-weighted-maps
yet the results vary between runs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.