Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as React from "react"
import { XYFrame } from "../../components"
import DocumentComponent from "../layout/DocumentComponent"
import { randomNormal } from "d3-random"
import { scaleThreshold } from "d3-scale"
import { hexbinning, heatmapping } from "../../components/svg/areaDrawing"
// eslint-disable-next-line
const components = []
const pointTestData = []
const nRando = randomNormal(0, 1000)
const pRando = randomNormal(0, 1000)
const steps = ["none", "#FBEEEC", "#f3c8c2", "#e39787", "#ce6751", "#b3331d"]
const thresholds = scaleThreshold()
.domain([0.01, 0.25, 0.5, 0.75, 1])
.range(steps)
for (let x = 1; x < 100; x++) {
pointTestData.push({
x: nRando() * 2 - 3000,
y: 2000 + nRando(),
color: "#00a2ce"
})
}
for (let x = 1; x < 100; x++) {
pointTestData.push({
es6Require(["test/DataFactory", "src/chart/HexBin"], function (DataFactory, HexBin) {
const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
const points = d3Range(2000).map(function () { return [randomX(), randomY()]; });
callback(new HexBin()
.xAxisType("linear")
.yAxisType("linear")
.columns(DataFactory.ND.subjects.columns)
.data(points)
);
});
}
function restart () {
const sqrtNumParticles = Math.ceil(Math.sqrt(settings.particles))
const numParticles = sqrtNumParticles * sqrtNumParticles
console.log(`Using ${numParticles} particles`)
const distributions = [
d3.randomNormal(2 * Math.random() - 1, Math.random() * 0.5),
d3.randomNormal(2 * Math.random() - 1, Math.random()),
d3.randomNormal(2 * Math.random() - 1, Math.random() * 0.75)
]
const percToDistrOne = Math.random() / 2
const percToDistrTwo = Math.random() / 2 + percToDistrOne
const initialParticleState = new Float32Array(numParticles * 4)
for (let i = 0; i < numParticles; ++i) {
const coinToss = Math.random()
const rand = coinToss < percToDistrOne ? distributions[0] : coinToss < percToDistrTwo ? distributions[1] : distributions[2]
initialParticleState[i * 4] = rand()
initialParticleState[i * 4 + 1] = rand()
initialParticleState[i * 4 + 2] = rand()
initialParticleState[i * 4 + 3] = (2 * Math.random() - 1) * settings.excitability / 10000
}
const initialPrevParticleState = new Float32Array(numParticles * 4)
const rand = () => (Math.random() - 0.5) * 0.03
values: range(0, 2000).map(randomNormal(5, 1))
},
{
group: "Group 2",
label: "Gene 2",
values: range(0, 2000).map(randomNormal(3, 1))
},
{
group: "Group 2",
label: "Gene 3",
values: range(0, 2000).map(randomNormal(1, 1))
},
{
group: "Group 3",
label: "Gene 1",
values: range(0, 2000).map(randomNormal(2, 1))
},
{
group: "Group 3",
label: "Gene 2",
values: range(0, 2000).map(randomNormal(3, 1))
},
{
group: "Group 3",
label: "Gene 3",
values: range(0, 2000).map(randomNormal(5, 1))
}
],
transcriptTracks: {
"exons": {
"ENST00000311595.9": [
{
_update() {
theta += deltaTheta;
randomX = randomNormal(width / 2 + 80 * Math.cos(theta), 80),
randomY = randomNormal(height / 2 + 80 * Math.sin(theta), 80);
for (let j = 0; j < k; ++j) {
i = (i + 1) % n;
points[i][0] = randomX();
points[i][1] = randomY();
}
this.setState({ points });
}
values: range(0, 2000).map(randomNormal(5, 1))
},
{
group: "Group 1",
label: "Gene 3",
values: range(0, 2000).map(randomNormal(10, 1))
},
{
group: "Group 2",
label: "Gene 1",
values: range(0, 2000).map(randomNormal(5, 1))
},
{
group: "Group 2",
label: "Gene 2",
values: range(0, 2000).map(randomNormal(3, 1))
},
{
group: "Group 2",
label: "Gene 3",
values: range(0, 2000).map(randomNormal(1, 1))
},
{
group: "Group 3",
label: "Gene 1",
values: range(0, 2000).map(randomNormal(2, 1))
},
{
group: "Group 3",
label: "Gene 2",
values: range(0, 2000).map(randomNormal(3, 1))
},
export const createData = (dataSize, barChart = true) => {
const gen1 = randomNormal(70, 15);
const gen2 = randomNormal(50, 8);
const gen = i => (i % 3 ? gen1() : gen2());
const data = new Array(dataSize).fill(0).map((d, index) => ({
x: gen(index),
y: barChart ? `Point-${index}` : gen(index),
label: `Point ${index}`,
color: '#12939A'
}));
if (barChart) {
data.sort((a, b) => b.x - a.x);
}
return data;
};
{ px: 500, py: 500 },
{ px: 100, py: 500 }
]
},
{
id: "shape2",
coordinates: [
{ px: 800, py: 800 },
{ px: 600, py: 1700 },
{ px: 1500, py: 1600 }
]
}
]
const pointTestData = []
const nRando = randomNormal(0, 1000)
const pRando = randomNormal(0, 1000)
for (let x = 1; x < 100; x++) {
pointTestData.push({
px: nRando() * 2 - 4000,
py: 2000 + nRando(),
step: pointTestData.length,
cat: "#00a2ce"
})
}
for (let x = 1; x < 100; x++) {
pointTestData.push({
px: 2000 + pRando(),
py: 2000 + pRando() * 2,
step: pointTestData.length,
cat: "#4d430c"
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";
import { HexBin } from "@hpcc-js/chart";
const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
const points = d3Range(2000).map(function () { return [randomX(), randomY()]; });
new HexBin()
.target("target")
.columns(["x", "y"])
.data(points)
.xAxisType("linear")
.yAxisType("linear")
.render()
;
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";
import { Contour } from "@hpcc-js/chart";
const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
const points = d3Range(2000).map(function () { return [randomX(), randomY()]; });
new Contour()
.target("target")
.columns(["x", "y"])
.data(points)
.xAxisType("linear")
.yAxisType("linear")
.contourBandwidth(8)
.render()
;