Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_createTimeContext() {
const pixelsPerSecond = this.pixelsPerSecond;
const width = this.width;
const xScale = d3Scale.linear()
.domain([0, 1])
.range([0, pixelsPerSecond]);
this.timeContext = new ViewTimeContext();
// all child context inherits the max duration allowed in container per default
this.timeContext.duration = width / pixelsPerSecond;
this.timeContext.xScale = xScale;
}
it("uses data to distinguish between time and linear scales", () => {
const props = {scale: {x: d3Scale.linear()}};
const scaleType = Scale.getScaleType(props, "x");
expect(Scale.getScaleFromProps).calledWith(props, "x").and.returned(props.scale.x);
expect(Scale.getScaleTypeFromData).calledWith(props, "x").and.returned("linear");
expect(scaleType).to.equal("linear");
});
getStyles(fakeData) {
const { springParamsStd } = this.props.app;
const { width } = this.state;
const xScale = linear()
.domain([0, 100])
.range([0.1 * width, 0.9 * width]);
const yScale = linear()
.domain([0, 100])
.range([0.9 * width, 0.1 * width]);
const configs = {};
fakeData.map((d, i) => {
configs['point' + i] = {
x: spring(xScale(d.x), springParamsStd),
y: spring(yScale(d.y), springParamsStd),
r: spring(50 * Math.random(), springParamsStd),
};
});
return configs;
}
getStyles(fakeData) {
const { springParamsStd } = this.props.app;
const { width } = this.state;
const xScale = linear()
.domain([0, 100])
.range([0.1 * width, 0.9 * width]);
const yScale = linear()
.domain([0, 100])
.range([0.9 * width, 0.1 * width]);
const configs = {};
fakeData.map((d, i) => {
configs['point' + i] = {
x: spring(xScale(d.x), springParamsStd),
y: spring(yScale(d.y), springParamsStd),
r: spring(50 * Math.random(), springParamsStd),
};
});
return configs;
}