Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderYAxis () {
const {yScale} = this.state
const {opportunityDatasetName, width, height} = this.props
const tickFormat = format('.3s')
// make sure that the top tick is not off the screen
const maxYValueWithTextOnScreen = yScale.invert(TEXT_HEIGHT / 2)
const trimmedYScale = scalePow()
.exponent(Y_AXIS_EXPONENT)
.domain([0, maxYValueWithTextOnScreen])
.range([height, TEXT_HEIGHT / 2])
// y scale
const yTicks = trimmedYScale.ticks(5)
const toRender = yTicks.map((tick, i, arr) => {
const yoff = yScale(tick)
const valueText = tickFormat(tick)
// highest valued tick gets label, move ticks down a little so the middle of the text is on
// the line.
const tickText = i === arr.length - 1
? `${valueText} ${opportunityDatasetName}`
filterCanvasImgdata(imgdata, w, h) {
const components = 4;
const zoom = this.map.getZoom();
const exp = zoom < 11 ? 0.3 + (zoom - 3) / 20 : 1;
const myscale = scalePow()
.exponent(exp)
.domain([0, 256])
.range([0, 256]);
for (let i = 0; i < w; ++i) {
for (let j = 0; j < h; ++j) {
const pixelPos = (j * w + i) * components;
const intensity = imgdata[pixelPos + 1];
imgdata[pixelPos] = 151; // eslint-disable-line
imgdata[pixelPos + 1] = 189; // eslint-disable-line
imgdata[pixelPos + 2] = 61; // eslint-disable-line
imgdata[pixelPos + 3] = // eslint-disable-line
zoom < 13 ? myscale(intensity) * 0.8 : intensity * 0.8;
}
return Object.values(commit.stats).reduce(
(memo: number, bundle) =>
memo +
(bundle && typeof bundle.name === 'string' && activeBundles.indexOf(bundle.name) > -1
? valueAccessor(bundle)
: 0),
0
);
});
const range = [height - (margin.top + margin.bottom), 0];
const domain = [0, maxDateVal * PERCENT_Y_HEADROOM];
switch (yScaleType) {
case YScaleType.POW:
return scalePow().exponent(4).range(range).domain(domain);
case YScaleType.LINEAR:
default:
return scaleLinear().range(range).domain(domain);
}
}
}
function createScaleFromType<output>(type: ScaleType) {
switch (type) {
case ScaleType.LINEAR:
return scaleLinear<output>();
case ScaleType.LOG:
return scaleLog<output>();
case ScaleType.POW:
return scalePow<output>();
case ScaleType.SQRT:
return scaleSqrt<output>();
case ScaleType.SYMLOG:
return undefined;
case ScaleType.TIME:
return scaleTime<output>();
case ScaleType.UTC:
return scaleUtc<output>();
case ScaleType.QUANTILE:
return scaleQuantile<output>();
case ScaleType.QUANTIZE:
return scaleQuantize<output>();
case ScaleType.THRESHOLD:
return scaleThreshold();
case ScaleType.BIN_ORDINAL:
return scaleOrdinal<{ toString(): string }, Output>();</output></output></output></output></output></output></output></output></output>
function setScale(ranges) {
colorScale = scalePow()
.domain(ranges)
.range(buckets);
}
const initialState = {
zoomEnabled: false,
selectedNode: null,
showFilters: false,
showIsolated: false,
showManyNodesWarning: false,
overrideManyNodesWarning: false
};
const opacityScale = scalePow()
.exponent(0.01)
.range([0.4, 1])
.clamp(true);
const nodeSizeScale = scalePow()
.range([5, 10])
.clamp(true);
const DEFAULT_TWEAKER = {
enter: (selection) => selection,
exit: (selection) => selection,
update: (selection) => selection
};
const simulation = forceSimulation()
.force("link", forceLink().id(d => d.id))
.force("charge", forceManyBody().strength(-110).distanceMin(1).distanceMax(400))
.force("x", forceX())
.force("y", forceY())
.alphaTarget(0);
const dataTypeSource = {
line: linesSource,
area: areasSource,
point: pointsSource
}
const annotationType = {
line: exampleAnnotations,
area: pointAnnotations,
point: pointAnnotations
}
const customScaleType = {
none: undefined,
pow: scalePow().exponent(2)
}
let finalAnnotations = []
if (this.state.annotations === "on") {
finalAnnotations = annotationType[this.state.dataType]
}
if (this.state.axisAnnotatable === "on") {
finalAnnotations = [...finalAnnotations, this.state.axisAnnotation]
}
const undefinedOptions = {}
if (this.state.frame === "ResponsiveXYFrame")
undefinedOptions.responsiveWidth = true
const displayFrame = (
if (this.ordinals_exists()) {
this.d3Scale.domain(this.ordinals());
}
this.parser = null;
this.formatter = null;
break;
case "linear":
this.d3Scale = d3ScaleLinear();
if (this.low_exists() && this.high_exists()) {
this.d3Scale.domain([this.lowValue(), this.highValue()]);
}
this.parser = null;
this.formatter = this.tickFormat_exists() ? d3Format(this.tickFormat()) : null;
break;
case "pow":
this.d3Scale = d3ScalePow()
.exponent(this.powExponent())
;
if (this.low_exists() && this.high_exists()) {
this.d3Scale.domain([this.lowValue(), this.highValue()]);
}
this.parser = null;
this.formatter = this.tickFormat_exists() ? d3Format(this.tickFormat()) : null;
break;
case "log":
this.d3Scale = d3ScaleLog()
.base(this.logBase())
;
if (this.low_exists() && this.high_exists()) {
this.d3Scale.domain([this.lowValue(), this.highValue()]);
}
this.parser = null;
var power = (function (_ref) {
var range = _ref.range,
rangeRound = _ref.rangeRound,
domain = _ref.domain,
exponent = _ref.exponent,
_ref$nice = _ref.nice,
nice = _ref$nice === undefined ? false : _ref$nice,
_ref$clamp = _ref.clamp,
clamp = _ref$clamp === undefined ? false : _ref$clamp;
var scale = scalePow();
if (range) scale.range(range);
if (rangeRound) scale.rangeRound(rangeRound);
if (domain) scale.domain(domain);
if (nice) scale.nice();
if (clamp) scale.clamp(true);
if (exponent) scale.exponent(exponent);
return scale;
});
if (_.isUndefined(min) || _.isUndefined(max)) {
scale = null;
} else if (type === "linear") {
scale = scaleLinear()
.domain([min, max])
.range([y0, y1])
.nice();
} else if (type === "log") {
const base = yaxis.props.logBase || 10;
scale = scaleLog()
.base(base)
.domain([min, max])
.range([y0, y1]);
} else if (type === "power") {
const power = yaxis.props.powerExponent || 2;
scale = scalePow()
.exponent(power)
.domain([min, max])
.range([y0, y1]);
}
return scale;
}