Skip to content

Commit

Permalink
Release 11.2.0 (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: dvvanessastoiber <[email protected]>
Co-authored-by: Martin Weigl <[email protected]>
Co-authored-by: dvdanielamoitzi <[email protected]>
fix(vis): histogram selection logic for scatter vis (#392)
  • Loading branch information
4 people authored Jul 2, 2024
1 parent facd63b commit df8fa55
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "visyn_core",
"description": "Core repository for datavisyn applications.",
"version": "11.1.2",
"version": "11.2.0",
"author": {
"name": "datavisyn GmbH",
"email": "[email protected]",
Expand Down
12 changes: 12 additions & 0 deletions src/icons/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ export const dvHeatmap: IconDefinition = {
],
};

export const dvOncoprint: IconDefinition = {
prefix: 'dv' as IconPrefix,
iconName: 'oncoprint' as IconName,
icon: [
512,
512,
[],
null,
'M52.6424 493.5H52.6512H465.861C481.112 493.5 493.5 481.489 493.5 466.643C493.5 451.796 481.112 439.786 465.861 439.786H66.6H66.5843L66.5689 439.787L66.5665 439.787L66.5555 439.787L66.5078 439.79C66.4648 439.792 66.3998 439.794 66.3149 439.796C66.1452 439.799 65.8963 439.8 65.5855 439.791C64.9631 439.771 64.0959 439.709 63.1202 439.536C61.157 439.189 58.8143 438.408 57.1143 436.701C55.4153 434.994 54.6334 432.643 54.2837 430.672C54.1099 429.693 54.0455 428.822 54.0246 428.197C54.0142 427.885 54.0147 427.636 54.0177 427.465C54.0192 427.38 54.0213 427.315 54.023 427.271L54.0251 427.223L54.0257 427.212L54.0258 427.21L54.0258 427.21L54.0267 427.195V427.181V28.2357C54.0267 12.935 42.0613 0.5 27.2633 0.5C12.4654 0.5 0.499985 12.935 0.499985 28.2357L0.499977 440.286L0.499992 440.288L0.999985 440.286C0.499992 440.288 0.499993 440.289 0.499995 440.289L0.500002 440.29L0.500031 440.294L0.500161 440.311L0.500833 440.373C0.501508 440.428 0.502698 440.51 0.504766 440.616C0.508902 440.829 0.516548 441.141 0.5306 441.542C0.558704 442.344 0.612442 443.502 0.71501 444.929C0.920092 447.782 1.32065 451.714 2.10298 456.027C3.66234 464.623 6.75771 474.851 12.9472 481.013C19.0137 487.053 28.9817 490.16 37.3465 491.766C41.5429 492.572 45.3637 493.005 48.1354 493.237C49.5215 493.353 50.6462 493.419 51.4252 493.455C51.8147 493.474 52.1179 493.485 52.3243 493.491C52.4275 493.495 52.5064 493.497 52.5599 493.498L52.6208 493.499L52.6365 493.5L52.6407 493.5L52.6418 493.5C52.6419 493.5 52.642 493.5 52.6422 493.494C52.6427 493.474 52.6444 493.386 52.6512 493L52.6424 493.5ZM133 20.5H90C86.9624 20.5 84.5 22.9624 84.5 26V116C84.5 119.038 86.9624 121.5 90 121.5H133C136.038 121.5 138.5 119.038 138.5 116V26C138.5 22.9624 136.038 20.5 133 20.5ZM216 20.5H173C169.962 20.5 167.5 22.9624 167.5 26V116C167.5 119.038 169.962 121.5 173 121.5H216C219.038 121.5 221.5 119.038 221.5 116V26C221.5 22.9624 219.038 20.5 216 20.5ZM299 20.5H256C252.962 20.5 250.5 22.9624 250.5 26V116C250.5 119.038 252.962 121.5 256 121.5H299C302.038 121.5 304.5 119.038 304.5 116V26C304.5 22.9624 302.038 20.5 299 20.5ZM216 163.5H173C169.962 163.5 167.5 165.962 167.5 169V259C167.5 262.038 169.962 264.5 173 264.5H216C219.038 264.5 221.5 262.038 221.5 259V169C221.5 165.962 219.038 163.5 216 163.5ZM299 163.5H256C252.962 163.5 250.5 165.962 250.5 169V259C250.5 262.038 252.962 264.5 256 264.5H299C302.038 264.5 304.5 262.038 304.5 259V169C304.5 165.962 302.038 163.5 299 163.5ZM382 163.5H339C335.962 163.5 333.5 165.962 333.5 169V259C333.5 262.038 335.962 264.5 339 264.5H382C385.038 264.5 387.5 262.038 387.5 259V169C387.5 165.962 385.038 163.5 382 163.5ZM299 306.5H256C252.962 306.5 250.5 308.962 250.5 312V402C250.5 405.038 252.962 407.5 256 407.5H299C302.038 407.5 304.5 405.038 304.5 402V312C304.5 308.962 302.038 306.5 299 306.5ZM382 306.5H339C335.962 306.5 333.5 308.962 333.5 312V402C333.5 405.038 335.962 407.5 339 407.5H382C385.038 407.5 387.5 405.038 387.5 402V312C387.5 308.962 385.038 306.5 382 306.5ZM465 306.5H422C418.962 306.5 416.5 308.962 416.5 312V402C416.5 405.038 418.962 407.5 422 407.5H465C468.038 407.5 470.5 405.038 470.5 402V312C470.5 308.962 468.038 306.5 465 306.5Z',
],
};

export const dvCorrelationplot: IconDefinition = {
prefix: 'dv' as IconPrefix,
iconName: 'correlationplot' as IconName,
Expand Down
31 changes: 25 additions & 6 deletions src/vis/scatter/ScatterVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function ScatterVis({
scales,
shapes,
config.showLabels,
selectedMap,
]);

const lineStyleToPlotlyShapeLine = (lineStyle: { colors: string[]; colorSelected: number; width: number; dash: PlotlyTypes.Dash }) => {
Expand Down Expand Up @@ -334,7 +335,7 @@ export function ScatterVis({
const yAxis = event.points[0].xaxis.anchor;
result = regression.results.find((r) => r.xref === xAxis && r.yref === yAxis) || null;
}
statsCallback(result.stats);
statsCallback(result?.stats);
}
}}
onUnhover={() => {
Expand All @@ -347,11 +348,19 @@ export function ScatterVis({
useResizeHandler
style={{ width: '100%', height: '100%' }}
onClick={(event) => {
const clickedId = (event.points[0] as any).id;
if (selectedMap[clickedId]) {
selectionCallback(selectedList.filter((s) => s !== clickedId));
// @ts-ignore
if (event.points[0]?.binNumber !== undefined) {
// @ts-ignore
const selInidices = event.points?.map((d) => d?.pointIndices).flat(1);
const indices = event.points[0]?.data?.customdata?.filter((_, i) => selInidices.includes(i)) as string[];
selectionCallback(indices);
} else {
selectionCallback([...selectedList, clickedId]);
const clickedId = (event.points[0] as any).id;
if (selectedMap[clickedId]) {
selectionCallback(selectedList.filter((s) => s !== clickedId));
} else {
selectionCallback([...selectedList, clickedId]);
}
}
}}
onLegendClick={() => false}
Expand All @@ -365,7 +374,17 @@ export function ScatterVis({
d3.select(id).selectAll('.legend').selectAll('.traces').style('opacity', 1);
}}
onSelected={(sel) => {
selectionCallback(sel ? sel.points.map((d) => (d as any).id) : []);
if (sel) {
// @ts-ignore
if (sel.points[0]?.binNumber !== undefined) {
// @ts-ignore
const selInidices = sel.points?.map((d) => d?.pointIndices).flat(1);
const indices = sel.points[0]?.data?.customdata?.filter((_, i) => selInidices.includes(i)) as string[];
selectionCallback(indices);
} else {
selectionCallback(sel ? sel.points?.map((d) => (d as any).id) : []);
}
}
}}
/>
</>
Expand Down
17 changes: 16 additions & 1 deletion src/vis/scatter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export async function createScatterTraces(
scales: Scales,
shapes: string[] | null,
showLabels: ELabelingOptions,
selectedMap: { [key: string]: boolean },
): Promise<PlotlyInfo> {
let plotCounter = 1;

Expand Down Expand Up @@ -319,9 +320,11 @@ export async function createScatterTraces(
validCols.forEach((xCurr) => {
// if on the diagonal, make a histogram.
if (xCurr.info.id === yCurr.info.id) {
const ids = xCurr.resolvedValues.map((v) => v.id?.toString());
plots.push({
data: {
x: xCurr.resolvedValues.map((v) => v.val),
customdata: ids, // had to use customdata instead of ids because otherwise binning would not work
xaxis: plotCounter === 1 ? 'x' : `x${plotCounter}`,
yaxis: plotCounter === 1 ? 'y' : `y${plotCounter}`,
type: 'histogram',
Expand All @@ -332,7 +335,19 @@ export async function createScatterTraces(
marker: {
color: VIS_NEUTRAL_COLOR,
},
opacity: alphaSliderVal,
// @ts-ignore
selected: {
marker: {
opacity: 1,
color: selectionColorDark,
},
},
unselected: {
marker: {
opacity: alphaSliderVal,
},
},
selectedpoints: ids.reduce((acc, id, i) => (selectedMap[id] ? acc.concat(i) : acc), [] as number[]),
},
xLabel: plotCounter > validCols.length * (validCols.length - 1) ? columnNameWithDescription(xCurr.info) : null,
yLabel: plotCounter === 1 + validCols.length * yIdx ? columnNameWithDescription(yCurr.info) : null,
Expand Down

0 comments on commit df8fa55

Please sign in to comment.