javascript - d3 map mouseover event slow response -
I am working with the D3 map and a mouseover event on polygon (areas) is required . I have to do this work, but it is a bit slow and I do not know why! Here's one.
Even what a stranger is that I have a GeoGeon file that is even bigger than the above (in KB), yet it is!
What's going on here? And how mouseover event
map code
var width = 1000; Var Height = 1100; Var rotate = 60; // so that [-60, 0] becomes the starting center of the launch, maximum max = 55; // clip north and south pole (infinity in Mercator) / Normally you want to see this point is in the middle of the UK West Center = [-1.485000, 52.567000]; // Projection object var projection = immediate D. 3.geo.conicConformal () Center (center) .clipAngle (180) // Map size yourself, you may want to play with this // regarding the size of your canvas .ccale (10000) // map between the center canvas . Transselate ([width / 2, height / 2]) .precision (.1); Var zoom = d3.behavior.zoom () .scaleExtent ([1, 15]) .on ("zoom", zoomed out); Var svg = d3.select ('# map'). Attached ('svg') .attr ('width', width) .attr ('height', height); Var g = svg.append ("g"); Svg.call (zoom) .call (zoom.event); Var path = D. 3.geo.path (). Launch (projection); D3.json ("Data / Map-England.Jason", function (fault, data) {g.selectAll ('path'). Data (data.) .endra (). Append ('path') .attr ' D ', path) .attr (' class', 'border') .attr ('stroke-width', '.5') .attr ('id', function (d) {return d.properties.Name;} ). ("Mouseover", function (d) {d3.select (this) .Categorized ("active", true);}) .on ("mouseout", function (d) {d3.select (this). "Active", incorrect);});}); Function zoom () {g.attr ("conversion", "translation (" + d3.event.translate + ") scale (" + d3.event.scale + ")"); }
The answer to simplifying the path of the map was the answer. You will need a node, and its topopus will be required.
On Windows, I could not find this package running. I had major issues with my dependency that supported Windows and dependency versions ... etc.
So I installed a virtual machine to run Ubuntu and I was moving up and running.
I ran the command Simplify-ratios and came back a simple version of the path. The map was super smooth and very sensitive.
Comments
Post a Comment