MCPcopy
hub / github.com/antonycourtney/tad / setHistogramBrushFilter

Function setHistogramBrushFilter

packages/tadviewer/src/actions.ts:532–573  ·  view source on GitHub ↗
(
  colId: string,
  range: [number, number] | null,
  stateRef: StateRef<AppState>
)

Source from the content-addressed store, hash-verified

530};
531
532export const setHistogramBrushFilter = (
533 colId: string,
534 range: [number, number] | null,
535 stateRef: StateRef<AppState>
536) => {
537 let baseFE: FilterExp;
538 if (range !== null) {
539 const appState = mutableGet(stateRef);
540 const prevFE = appState.viewState.viewParams.filterExp;
541 // ensure that prevFE is either null or a top-level "AND" operator:
542 if (prevFE != null) {
543 if (prevFE.op !== "AND") {
544 log.info(
545 "setHistogramBrushFilter: unexpected structure for current filter expression, ignoring brush filter"
546 );
547 return;
548 }
549 // drop any previous mentions of colId from the filter expression:
550 const cleanOpArgs = prevFE.opArgs.filter((subExp: SubExp) => {
551 if (subExp.expType === "BinRelExp") {
552 const lhs = subExp.lhs;
553 if (lhs.expType === "ColRef" && lhs.colName === colId) {
554 return false;
555 }
556 }
557 return true;
558 });
559 baseFE = new FilterExp("AND", cleanOpArgs);
560 } else {
561 baseFE = and();
562 }
563 const nextFE = baseFE
564 .ge(col(colId), constVal(range[0]))
565 .le(col(colId), constVal(range[1]));
566 update(
567 stateRef,
568 vpUpdate(
569 (viewParams) => viewParams.set("filterExp", nextFE) as ViewParams
570 )
571 );
572 }
573};
574
575export const setHistogramBrushRange = (
576 colId: string,

Callers

nothing calls this directly

Calls 7

andFunction · 0.90
colFunction · 0.90
constValFunction · 0.90
vpUpdateFunction · 0.85
filterMethod · 0.80
leMethod · 0.80
geMethod · 0.80

Tested by

no test coverage detected