Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from 'd3-timer';
// Test now definition
const now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
/**
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from 'd3-timer';
// Test now definition
const now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
/**
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from 'd3-timer';
// Test now definition
let now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
//TODO make new legend
// select('.legend').selectAll('.rectLegend').remove()
//
// let legend = svglegend.legendColor()
// legend.scale(self.legendScale);
// legend.shapeWidth((that.svgWidth)/8);
// d3.select('.legend').call(legend);
self.dotDataColloection.forEach(dot =>{
[dot.x,dot.y] = self.projection([dot.longitude,dot.latitude])
})
let simulation = forceSimulation(self.dotDataColloection)
.force('collide',forceCollide().radius(5).iterations(10))
.stop();
timeout(function(){
for (var i = 0,
n = Math.ceil(Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay()));
i < n; ++i) {
simulation.tick();}
let circles = draw.selectAll('circle').data(self.dotDataColloection);
circles.exit().remove();
circles = circles.enter()
.append('circle')
.merge(circles);
circles.attr('cx',(d:any)=>d.x)
.attr('cy',(d:any)=>d.y)
.attr('r',4)
.attr('fill',(d:any)=>self.mapManager.scaleFunction(d.dataVal))
.attr('id',(d:any)=>'circle_' + d.ID)
.on("mouseover", function(d:any) {
}
// Cancel any pre-empted transitions.
else if (+i < id) {
o.state = ENDED;
o.timer.stop();
o.on.call("cancel", node, node.__data__, o.index, o.group);
delete schedules[i];
}
}
// Defer the first tick to end of the current frame; see d3/d3#1576.
// Note the transition may be canceled after start and before the first tick!
// Note this must be scheduled before the start event; see d3/d3-transition#16!
// Assuming this is successful, subsequent callbacks go straight to tick.
timeout(function() {
if (self.state === STARTED) {
self.state = RUNNING;
self.timer.restart(tick, self.delay, self.time);
tick(elapsed);
}
});
// Dispatch the start event.
// Note this must be done before the tween are initialized.
self.state = STARTING;
self.on.call("start", node, node.__data__, self.index, self.group);
if (self.state !== STARTING) return; // interrupted
self.state = STARTED;
// Initialize the tween, deleting null tween.
tween = new Array(n = self.tween.length);
value = lazy.get.call(model);
on(`.${key}`, () => {
var newValue = lazy.get.call(model);
if (newValue === value) return;
update(newValue);
});
} else
prop.set = function (newValue) {
if (newValue === value) return;
// Schedule change event at the next event loop tick
timeout(() => {
update(newValue);
});
};
timeout(() => {
properties.get('').call('change', model);
});
return prop;
}