Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let canvas;
document.getElementById("regl").innerText = "";
if ((document.getElementById("debug") as HTMLInputElement).checked) {
canvas = document.createElement("canvas");
document.getElementById("regl").appendChild(canvas);
}
const maxY = (data.data as Float32Array).reduce(
(agg, val) => Math.max(agg, val),
0
);
// compute nice bin boundaries
const binConfigX = bin({ maxbins: binsx, extent: [0, points - 1] });
const binConfigY = bin({ maxbins: binsy, extent: [0, maxY] });
start = Date.now();
compute(data, binConfigX, binConfigY, canvas).then(heatmapData => {
document.getElementById("computetime").innerText = `${(Date.now() - start) /
1000} seconds`;
heatmap(heatmapData, binConfigX, binConfigY);
});
}
extent.push(extent[0] === 1 ? extent[0] + 0.1 : extent[0] + 1);
}
// the performance distribution is always [0, 1]
const binIdxes = d3.range(0, this.binCount - 2);
const binFunction = d3.scaleQuantile()
.domain(d3.merge([
this.flatCounts.correct.concat(this.flatCountsRewrite.correct) as number[],
this.flatCounts.incorrect.concat(this.flatCountsRewrite.incorrect) as number[]]))
.range(binIdxes);
this.scale.attrScale_continue.domain(extent);
let bins = d3.merge([
[extent[0]],binFunction.quantiles(),
[extent[1]]]).filter(utils.uniques) as number[];
if ( (bins[bins.length-1] - bins[0] <= 1) || bins.length < this.binCount * 0.6) {
const bins_ = vegaStat.bin({extent: extent, nice: false, maxbins: this.binCount });
this.scale.bins = d3.range(bins_.start, bins_.stop + bins_.step, bins_.step);
} else {
//bins.push(extent[1] === 1 ? extent[1] + 0.1 : extent[1] + 1);
this.scale.bins = bins;
}
} else {
this.scale.bins = this.domain.slice();//this.attr.stats.map(s => s.value);
this.scale.attrScale_discrete.domain(this.scale.bins as string[]);
}
/*
if (this.props.attr.name === "groundtruths_length") {
this.scale.attrScale_continue.domain([1, 20]);
this.scale.bins = [1, 2, 3, 4, 5, 6, 7, 8, 20]
}
if (this.props.attr.name === "prediction_length") {
this.scale.attrScale_continue.domain([1, 50]);
lineChart(data);
let canvas;
document.getElementById("regl").innerText = "";
if ((document.getElementById("debug") as HTMLInputElement).checked) {
canvas = document.createElement("canvas");
document.getElementById("regl").appendChild(canvas);
}
const maxY = (data.data as Float32Array).reduce(
(agg, val) => Math.max(agg, val),
0
);
// compute nice bin boundaries
const binConfigX = bin({ maxbins: binsx, extent: [0, points - 1] });
const binConfigY = bin({ maxbins: binsy, extent: [0, maxY] });
start = Date.now();
compute(data, binConfigX, binConfigY, canvas).then(heatmapData => {
document.getElementById("computetime").innerText = `${(Date.now() - start) /
1000} seconds`;
heatmap(heatmapData, binConfigX, binConfigY);
});
}
prototype._bins = function(_) {
if (this.value && !_.modified()) {
return this.value;
}
var field = _.field,
bins = bin(_),
start = bins.start,
stop = bins.stop,
step = bins.step,
a, d;
if ((a = _.anchor) != null) {
d = a - (start + step * Math.floor((a - start) / step));
start += d;
stop += d;
}
var f = function(t) {
var v = field(t);
if (v == null) {
return null;
} else {
prototype._bins = function(_) {
if (this.value && !_.modified()) {
return this.value;
}
var field = _.field,
bins = bin(_),
step = bins.step,
start = bins.start,
stop = start + Math.ceil((bins.stop - start) / step) * step,
a, d;
if ((a = _.anchor) != null) {
d = a - (start + step * Math.floor((a - start) / step));
start += d;
stop += d;
}
var f = function(t) {
var v = field(t);
return v == null ? null
: v < start ? -Infinity
: v > stop ? +Infinity