Skip to content

Commit

Permalink
Match d3 types to installed version per package
Browse files Browse the repository at this point in the history
This should provide more accurate types.
  • Loading branch information
victorlin committed Nov 20, 2024
1 parent f9d7ec7 commit 94b3b63
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 446 deletions.
575 changes: 139 additions & 436 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,19 @@
},
"devDependencies": {
"@playwright/test": "^1.48.2",
"@types/d3": "^7.4.3",
"@types/d3-array": "^2.2.0",
"@types/d3-axis": "^1.0.6",
"@types/d3-brush": "^1.0.4",
"@types/d3-color": "^1.0.3",
"@types/d3-ease": "^1.0.3",
"@types/d3-format": "^1.3.0",
"@types/d3-interpolate": "^1.1.5",
"@types/d3-scale": "^1.0.5",
"@types/d3-selection": "^1.1.0",
"@types/d3-shape": "^1.2.0",
"@types/d3-timer": "^1.0.7",
"@types/d3-transition": "^1.2.0",
"@types/d3-zoom": "^1.1.3",
"@types/leaflet": "^1.9.3",
"@types/node": "^18.15.11",
"@types/webpack-env": "^1.18.2",
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/phyloTree/change.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Selection, Transition } from "d3";
import { Selection } from "d3-selection";
import { Transition } from "d3-transition";
import { timerFlush } from "d3-timer";
import { calcConfidenceWidth } from "./confidence";
import { applyToChildren, setDisplayOrder } from "./helpers";
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/phyloTree/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NODE_VISIBLE } from "../../../util/globals";
import { timerStart, timerEnd } from "../../../util/perf";
import { ReduxNode } from "../../../reducers/tree/types";
import { Distance, PhyloNode } from "./types";
import { ScaleContinuousNumeric } from "d3-scale";

/** get a string to be used as the DOM element ID
* Note that this cannot have any "special" characters
Expand Down Expand Up @@ -253,7 +254,7 @@ function areNucleotideMutationsPresent(observedMutations) {
* removing the need to guess.
*/
export function guessAreMutationsPerSite(
scale: d3.ScaleContinuousNumeric<number, number>,
scale: ScaleContinuousNumeric<number, number>,
): boolean {
const maxDivergence = max(scale.domain());
return maxDivergence <= 5;
Expand Down
8 changes: 4 additions & 4 deletions src/components/tree/phyloTree/layouts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-multi-spaces */
/* eslint-disable space-infix-ops */
import { scaleLinear, scalePoint } from "d3-scale";
import { scaleLinear, ScalePoint, scalePoint } from "d3-scale";
import { timerStart, timerEnd } from "../../../util/perf";
import { getTraitFromNode, getDivFromNode } from "../../../util/treeMiscHelpers";
import { stemParent, nodeOrdering } from "./helpers";
Expand Down Expand Up @@ -523,8 +523,8 @@ const JITTER_MIN_STEP_SIZE = 50; // pixels

function padCategoricalScales(
domain: string[],
scale: d3.ScalePoint<string>,
): d3.ScalePoint<string> {
scale: ScalePoint<string>,
): ScalePoint<string> {
if (scale.step() > JITTER_MIN_STEP_SIZE) return scale.padding(0.5); // balanced padding when we can jitter
if (domain.length<=4) return scale.padding(0.4);
if (domain.length<=6) return scale.padding(0.3);
Expand All @@ -537,7 +537,7 @@ function padCategoricalScales(
*/
function jitter(
axis: "x" | "y",
scale: d3.ScalePoint<string>,
scale: ScalePoint<string>,
nodes: PhyloNode[],
): void {
const step = scale.step();
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/phyloTree/regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sum } from "d3-array";
import { formatDivergence, guessAreMutationsPerSite} from "./helpers";
import { NODE_VISIBLE } from "../../../util/globals";
import { PhyloNode, PhyloTreeType, Regression } from "./types";
import { ScaleContinuousNumeric } from "d3-scale";


/**
Expand Down Expand Up @@ -62,7 +63,7 @@ export function calculateRegression(this: PhyloTreeType) {
export function makeRegressionText(
regression: Regression,
layout: string,
yScale: d3.ScaleContinuousNumeric<number, number>,
yScale: ScaleContinuousNumeric<number, number>,
): string {
if (layout==="clock") {
if (guessAreMutationsPerSite(yScale)) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/tree/phyloTree/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDomId, setDisplayOrder } from "./helpers";
import { makeRegressionText } from "./regression";
import { getEmphasizedColor } from "../../../util/colorHelpers";
import { Callbacks, Distance, Params, PhyloNode, PhyloTreeType } from "./types";
import { Selection } from "d3";
import { Selection } from "d3-selection";
import { Layout, ScatterVariables } from "../../../reducers/controls";
import { ReduxNode, Visibility } from "../../../reducers/tree/types";

Expand Down
2 changes: 1 addition & 1 deletion src/components/tree/phyloTree/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Selection } from "d3";
import { Selection } from "d3-selection";
import { Layout, PerformanceFlags, ScatterVariables } from "../../../reducers/controls";
import { ReduxNode, Visibility } from "../../../reducers/tree/types";
import { change, modifySVG, modifySVGInStages } from "./change";
Expand Down

0 comments on commit 94b3b63

Please sign in to comment.