Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17 condition selector #126

Open
wants to merge 156 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
6279a01
Initializing PR
bbollen23 Oct 8, 2024
d0e2044
Empty Condition Selector.vue file
Luke-Schreiber Oct 8, 2024
2723c79
Empty condition selector as a registered component
Luke-Schreiber Oct 8, 2024
7391444
Condition Selector moved to folder, condition chart component added
Luke-Schreiber Oct 9, 2024
bd42a2e
main.ts changes whoops
Luke-Schreiber Oct 9, 2024
c6de1db
Created layout for condition selector
bbollen23 Oct 9, 2024
8bd762d
Data Loads
Luke-Schreiber Oct 9, 2024
5c962ff
Added dropdown buttons, condition selector store, and added styling f…
bbollen23 Oct 9, 2024
9274206
Creates vgplot (hard-coded size and attributes)
Luke-Schreiber Oct 9, 2024
ad93c35
Added resizing
bbollen23 Oct 9, 2024
c232a2d
Merge branch '17-condition-selector' of https://github.com/visdesignl…
Luke-Schreiber Oct 9, 2024
942b92c
Updated size slightly
bbollen23 Oct 9, 2024
e5e3e9e
Fixed experiment metadata table names, got condition chart working
bbollen23 Oct 10, 2024
7309d3c
vgplot styling (grey under line chart, smoothed lines)
Luke-Schreiber Oct 15, 2024
cb6ec06
Fixed typing on handleTagClick
bbollen23 Oct 15, 2024
ef1a3b4
ConditionChart gets passed 'props' to create charts. Linting issues c…
Luke-Schreiber Oct 15, 2024
36ac5de
refactoring changes
Luke-Schreiber Oct 16, 2024
d509aee
Merge branch '17-condition-selector' of https://github.com/visdesignl…
Luke-Schreiber Oct 16, 2024
8d666e0
Added small readme
bbollen23 Oct 16, 2024
f9aae63
Fixed condition chart not loading on hot reload while maintaining hot…
bbollen23 Oct 16, 2024
f7cc59d
Labels now come from experiment.json file. Fixed hover effects and re…
bbollen23 Oct 16, 2024
5286a17
Made vg plot dynamic based on tags
bbollen23 Oct 16, 2024
5fe2c04
Changed predicate to const
bbollen23 Oct 16, 2024
4ab1208
Fixed condition selector vue not re-rendering during label update.
bbollen23 Oct 16, 2024
05dc8da
Added avg to the Line chart views. Added "duckdb_findings.txt" file f…
bbollen23 Oct 21, 2024
5fddef4
Added mosaic selection store. All mosaic selections now pass through …
bbollen23 Oct 24, 2024
0be46d7
Removed unnecessary imports in PlotSelector.vue
bbollen23 Oct 24, 2024
f1b4129
Removed tags from createChart input.
bbollen23 Oct 24, 2024
e6f3980
Fixed condition chart not properly rendering dynamic tag names.
bbollen23 Oct 24, 2024
fe0b0b7
Added condition chart color scheme based on y-index. Remove unnecessa…
bbollen23 Oct 24, 2024
5be4a11
Adjusted styles and position for condition charts. Uncentered and mad…
bbollen23 Oct 24, 2024
fb28762
Added selection styles for condition chart. Added param to turn opaci…
bbollen23 Oct 24, 2024
89877ad
Moved mosaic selection interactions to watching variables
bbollen23 Oct 25, 2024
eb6e41b
Changed initialization of condition selector to computed variable
bbollen23 Oct 25, 2024
00c41b1
Revmoed unnecessary logs
bbollen23 Oct 28, 2024
7fb1fef
Shaded area of chart colors altered
Luke-Schreiber Oct 29, 2024
80ce2d3
Track Attributes UI (empty, non-functional yet)
Luke-Schreiber Oct 29, 2024
49fc4f9
Removed clearMosaicSource from plot selector vue since unnecessary. R…
bbollen23 Oct 29, 2024
489073c
Added aggregate table creation
bbollen23 Oct 29, 2024
89af358
Added typing for data selections -- defaults to cell. Updated mosaic …
bbollen23 Oct 30, 2024
1bfdecc
Track Attributes Displays 'avg_mass'
Luke-Schreiber Oct 31, 2024
8976fb2
Added error checking for creating aggregate table. Using header trans…
bbollen23 Oct 31, 2024
7c42e19
creates track level attributes
Luke-Schreiber Oct 31, 2024
624b7bc
Added track level selection
bbollen23 Oct 31, 2024
e2beced
Removed mosaic selection store from plotSelector
bbollen23 Oct 31, 2024
2ed2f48
Changed "mosaicSelection" to "cellLevelSelection". Still using "mosai…
bbollen23 Nov 1, 2024
96c8487
Changed "avg_mass" column to "AVG ${mass}". Made plot selector genera…
bbollen23 Nov 1, 2024
85e41cf
Added AVG, SUM, COUNT, MAX, MIN of all headers to aggregate table.
bbollen23 Nov 1, 2024
2e3e0c9
Added median
bbollen23 Nov 1, 2024
711c848
Track Level Attribute Plots are created based on user specified 'attr…
Luke-Schreiber Nov 8, 2024
3336f14
fixed condition chart and filters not rendering when switching experi…
bbollen23 Nov 8, 2024
bff2f0d
Fixed same label condition chart issue, added proper loading to univa…
bbollen23 Nov 9, 2024
8749a77
Selection/Filter Icons match type.
Luke-Schreiber Nov 11, 2024
1051772
Cell Attributes and Track Attributes are both dialog boxes.
Luke-Schreiber Nov 11, 2024
109c222
caps fixed for 'track' and 'cell' strings
Luke-Schreiber Nov 11, 2024
ea5d21e
Refactored & shortened
Luke-Schreiber Nov 11, 2024
63c536e
'delete' dialog for plots. Empty UI.
Luke-Schreiber Nov 11, 2024
33dd6b0
Rick-Click 'delete' implemented
Luke-Schreiber Nov 11, 2024
4ec16b6
Delete Dialog button spacings
Luke-Schreiber Nov 12, 2024
f06d7f3
Fixed opacity on image view geojson layer, testing for selection stor…
bbollen23 Nov 12, 2024
7c30585
Changed selection and filtering to use duckdb aggregate table.
bbollen23 Nov 12, 2024
fa3b99f
Finished selection and filtering linking. Moved attribute plots into …
bbollen23 Nov 24, 2024
bb556fe
Fixed selections not updating range
bbollen23 Nov 24, 2024
5b58ab5
toggleRelativeChart icon color changes
Luke-Schreiber Nov 26, 2024
c45e318
dark mode for dialogs + attribute select menu position fix
Luke-Schreiber Nov 26, 2024
12403e8
Commented out exemplar view
bbollen23 Nov 26, 2024
5d89547
Fixed range bug for track level attributes. Added dynamic column adding.
bbollen23 Nov 26, 2024
c03ed42
Adjusted track level attributes to use readable labels, fixed several…
bbollen23 Dec 9, 2024
a9bb36b
Merge pull request #135 from visdesignlab/dynamic-track-attributes
bbollen23 Dec 9, 2024
9b11cda
Apply suggestions from code review
bbollen23 Dec 10, 2024
2af5713
Removed unnecessary items.
bbollen23 Dec 10, 2024
3bbdc55
Empty Tabs + Axes Selector. I will improve the stylings soon.
Luke-Schreiber Dec 11, 2024
5f79b62
Bigger Text
Luke-Schreiber Dec 11, 2024
d3d5dd5
Added condition chart filtering
bbollen23 Dec 12, 2024
e0cfbc0
Fixed resizing issues and errors
bbollen23 Dec 12, 2024
60c6dcc
dark mode changes (manual dark stylings when q-components dont have "…
Luke-Schreiber Dec 13, 2024
c3894ee
Added compare view for condition chart.
bbollen23 Dec 13, 2024
00ffcdf
Fixed container ref in condition selector
bbollen23 Dec 13, 2024
18d5928
Unnecessary import
bbollen23 Dec 13, 2024
6859a1b
Added correct filtering labeling for condition chart. Added lazy load…
bbollen23 Dec 16, 2024
1de3d24
Added init mass and support for custom sql queries for track aggregat…
bbollen23 Dec 17, 2024
2ba486d
Fixed several bugs. Added basic cell attribute dropdown on cond chart
bbollen23 Dec 17, 2024
22113a3
Added growth rate and exponential growth rate constant
bbollen23 Dec 17, 2024
f158342
Added mass norm and time norm cell attributes. Added mass norm to con…
bbollen23 Dec 17, 2024
8f5a6de
Made the legend a little darker.
Luke-Schreiber Dec 18, 2024
e4acb97
custom-dark setting fixed.
Luke-Schreiber Dec 18, 2024
f20d84d
add script to prettier everything
Dev-Lan Dec 19, 2024
256478a
prettier everything
Dev-Lan Dec 19, 2024
0e3eac7
add vue to prettier script
Dev-Lan Dec 19, 2024
363e6a7
prettier vue files
Dev-Lan Dec 19, 2024
8629ef4
remove unused store
Dev-Lan Dec 19, 2024
0c8ec50
delete undefined var
Dev-Lan Dec 19, 2024
246598a
use array length instead of hard-coded number
Dev-Lan Dec 19, 2024
72e1193
switch to guard statement
Dev-Lan Dec 19, 2024
bed26b5
remove unused store
Dev-Lan Dec 19, 2024
93e43bd
add back unused var (for consistency)
Dev-Lan Dec 19, 2024
8613cb6
switch to guard statements
Dev-Lan Dec 19, 2024
5aa2b9f
switch to guard statement
Dev-Lan Dec 19, 2024
ce0b972
switch to linear lines (instead of smoothed ones)
Dev-Lan Dec 19, 2024
b59f58b
reduce line width
Dev-Lan Dec 19, 2024
d6c426e
switch to function syntax
Dev-Lan Dec 19, 2024
c0f8620
cleanup: minor template and style changes to facet view
Dev-Lan Dec 19, 2024
e1a4241
use useElementSize instead of writing our own
Dev-Lan Dec 19, 2024
a53b467
do not enforce square compare aspect ratio
Dev-Lan Dec 19, 2024
6813f49
use q-toolbar and fix wrapping issue
Dev-Lan Dec 19, 2024
d3712ca
better rendering when chart is very small
Dev-Lan Dec 19, 2024
8d47d00
change to function syntax
Dev-Lan Dec 19, 2024
982fc40
change constant from computed to variable
Dev-Lan Dec 19, 2024
151b45d
rename store varaiable for consistency
Dev-Lan Dec 19, 2024
1cf2165
refactor: use for loops, guard statement and object unpacking
Dev-Lan Dec 19, 2024
11dbb36
refactor: move into variable name
Dev-Lan Dec 19, 2024
1139047
refactor: pull into variable name
Dev-Lan Dec 19, 2024
35e45cd
add some function return types
Dev-Lan Dec 19, 2024
6c74df2
refactor: only pilcrow ( ¶ ) once
Dev-Lan Dec 19, 2024
1036358
tweak behavior when selecting an individual plot while everything is …
Dev-Lan Dec 19, 2024
72e35d4
refactor: simplify code for check all function
Dev-Lan Dec 19, 2024
6a51afc
cleanup: wrap returns with braces, remove unneded attribute
Dev-Lan Dec 20, 2024
cac5494
cleanup: remove clog, use existing variable
Dev-Lan Dec 20, 2024
77758df
avoid context menu for filter options
Dev-Lan Dec 20, 2024
e4b75b3
remove responsive removal of icons in sidebar
Dev-Lan Dec 20, 2024
99b1920
do not enforce persistent
Dev-Lan Dec 20, 2024
983cc8b
change color to primary theme color
Dev-Lan Dec 20, 2024
3b20fda
cleaup: delete vestigial css classes
Dev-Lan Dec 20, 2024
ff379a0
add dynamic tooltip
Dev-Lan Dec 20, 2024
e1e1c60
cleanup: make aggregate function typing more specific
Dev-Lan Dec 20, 2024
5580d92
cleanup: let → const
Dev-Lan Dec 20, 2024
1f959ac
only add the column we show by default
Dev-Lan Dec 20, 2024
8813cbb
cleanup: switch to guard statements
Dev-Lan Dec 20, 2024
5be51e0
cleanup: let → const
Dev-Lan Dec 20, 2024
61cec39
import specific function from lodash
Dev-Lan Dec 20, 2024
e02fe5d
cleanup: fix typo in comments
Dev-Lan Dec 20, 2024
80ada78
cleanup: if statement → guard statement
Dev-Lan Dec 20, 2024
3d221e9
add back the default min/max that Devin shouldn't have deleted
Dev-Lan Dec 20, 2024
89cd479
switch to primary color for consistency
Dev-Lan Dec 20, 2024
2304b9e
change project name/title (aardvark → loon)
Dev-Lan Dec 20, 2024
d6da835
tweak selected dataset style
Dev-Lan Dec 20, 2024
99045b0
remove veutify (caused clash with theming, keep import for css reset)
Dev-Lan Dec 20, 2024
3c6b741
make problem/warning notifications persistent, hide info/success noti…
Dev-Lan Dec 20, 2024
ecbdac5
Several bug fixes
bbollen23 Dec 23, 2024
4a1869b
Image view filtering to fade out, while keeping red circle
bbollen23 Jan 6, 2025
a8816d2
All cells selected when no selections made
bbollen23 Jan 6, 2025
1d188eb
Added legend to compare view
bbollen23 Jan 6, 2025
7155b3f
Location changes if curr location gets filtered out by condition chart.
bbollen23 Jan 6, 2025
50825f9
Initial location selected when experiment loads. Selected location li…
bbollen23 Jan 6, 2025
8932f76
Reverts to correct location if new location does not work. Notifies a…
bbollen23 Jan 6, 2025
fec8a2c
Fixed filter bug on refresh
bbollen23 Jan 6, 2025
e4c4715
Fixed refresh button styling on experiment selector. Fixed all mdi icons
bbollen23 Jan 6, 2025
ccd471c
Removed success notifications
bbollen23 Jan 6, 2025
fc32969
Fixed "reverting" message styling.
bbollen23 Jan 6, 2025
43a2cf4
Fixes with condition selector alongside @Dev-Lan
bbollen23 Jan 7, 2025
72ef28f
Fixed dark mode legend on compare view. Legend removed when loading. …
bbollen23 Jan 7, 2025
ab87de3
cleanup: prettier everything
Dev-Lan Jan 8, 2025
b1ee640
cleanup: remove unnecessary try catch
Dev-Lan Jan 8, 2025
ea89151
cleanup: change to function
Dev-Lan Jan 8, 2025
f3821fa
cleanup: deleted commented code
Dev-Lan Jan 8, 2025
c4a5dec
tweak styles in image
Dev-Lan Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json,vue}\""
},
"dependencies": {
"@deck.gl/core": "8.9.30",
Expand Down
37 changes: 36 additions & 1 deletion apps/client/src/components/AggregateLineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ const areaGen = computed(() => {
);
});

const areaGenHighlighted = computed(() => {
return area<AggDataPoint>()
.x((aggPoint) => scaleX.value(aggPoint.time))
.y0((aggPoint) =>
scaleY.value(aggPoint.value + temp.value * aggPoint.count)
)
.y1((aggPoint) =>
scaleY.value(aggPoint.value - temp.value * aggPoint.count)
)
.defined((aggPoint) => aggPoint.highlighted ?? false);
});

const lineGen = computed(() => {
return line<AggDataPoint>()
.x((aggPoint) => scaleX.value(aggPoint.time))
Expand Down Expand Up @@ -522,7 +534,9 @@ const otherUnmuted = computed(() => {
</g>
<g :transform="`translate(${margin.left},${margin.top})`">
<path
:class="`muted agg-line ${globalSettings.normalizedDark}`"
:class="`muted agg-line ${
globalSettings.normalizedDark
} ${aggLine.filtered ? 'filtered' : ''}`"
v-for="(
aggLine, index
) in aggregateLineChartStore.aggLineDataList.filter(
Expand All @@ -531,6 +545,18 @@ const otherUnmuted = computed(() => {
:key="index"
:d="areaGen(aggLine.data) ?? ''"
></path>
<!-- Path below is for individual cell tracks with highlighted cells. -->
<path
style="stroke-width: 2px"
:class="`highlighted-line ${globalSettings.normalizedDark}`"
v-for="(
aggLine, index
) in aggregateLineChartStore.aggLineDataList.filter(
(d) => d.muted
)"
:key="'highlighted-' + index"
:d="areaGenHighlighted(aggLine.data) ?? ''"
></path>
</g>
<g :transform="`translate(${margin.left},${margin.top})`">
<path
Expand Down Expand Up @@ -646,6 +672,15 @@ const otherUnmuted = computed(() => {
stroke-width: 1px;
opacity: 0.6;
}

.highlighted.agg-line {
stroke-width: 3px;
opacity: 1;
}

.filtered.agg-line {
opacity: 0 !important;
}
.selected.agg-line {
stroke-width: 4px;
}
Expand Down
68 changes: 58 additions & 10 deletions apps/client/src/components/ImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Pool from '../util/Pool';
import { useLooneageViewStore } from '@/stores/componentStores/looneageViewStore';
import { useGlobalSettings } from '@/stores/componentStores/globalSettingsStore';


import {
loadOmeTiff,
getChannelStats,
Expand All @@ -42,6 +41,7 @@ import { TripsLayer } from '@deck.gl/geo-layers';
import { format } from 'd3-format';
import colors from '@/util/colors';
import { useConfigStore } from '@/stores/misc/configStore';
import { useMosaicSelectionStore } from '@/stores/dataStores/mosaicSelectionStore';

const cellMetaData = useCellMetaData();
const globalSettings = useGlobalSettings();
Expand All @@ -57,6 +57,10 @@ const { currentLocationMetadata } = storeToRefs(datasetSelectionStore);
const { contrastLimitSlider } = storeToRefs(imageViewerStoreUntrracked);
const eventBusStore = useEventBusStore();
const looneageViewStore = useLooneageViewStore();
const mosaicSelectionStore = useMosaicSelectionStore();
const { highlightedCellIds, unfilteredTrackIds } =
storeToRefs(mosaicSelectionStore);

const deckGlContainer = ref(null);
const { width: containerWidth, height: containerHeight } =
useElementSize(deckGlContainer);
Expand All @@ -66,6 +70,24 @@ const contrastLimit = computed<[number, number][]>(() => {
return [[contrastLimitSlider.value.min, contrastLimitSlider.value.max]];
});

const _determineSelectedOrFiltered = (trackId: string) => {
const frame = imageViewerStore.frameNumber;
const location = currentLocationMetadata.value?.id;
let selected = false;
if (frame && location && highlightedCellIds.value) {
// Generate Unique String to compare against list
const unique_string = `${trackId}_${frame}_${location}`;
selected = highlightedCellIds.value.includes(unique_string);
}

return {
selected,
filtered: unfilteredTrackIds.value
? !unfilteredTrackIds.value.includes(trackId)
: false,
};
};

let deckgl: any | null = null;
onMounted(() => {
deckgl = new Deck({
Expand Down Expand Up @@ -121,7 +143,6 @@ onMounted(() => {
// onLoad: () => console.log('onLoad'),

getTooltip: ({ object }) => {
console.log(object);
if (!object) return null;
let { id, frame } = object.properties;
if (id == null) return null;
Expand Down Expand Up @@ -218,7 +239,7 @@ function createSegmentationsLayer(): typeof GeoJsonLayer {
),
lineWidthUnits: 'pixels',
id: 'segmentations',
opacity: 0.4,
opacity: 1,
stroked: true,
filled: true,
getFillColor: (info) => {
Expand All @@ -228,6 +249,13 @@ function createSegmentationsLayer(): typeof GeoJsonLayer {
) {
return hoverColorWithAlpha;
}

const { filtered } = _determineSelectedOrFiltered(
info.properties?.id?.toString()
);
if (filtered) {
return [0, 0, 0, 255];
}
return [0, 0, 0, 0];
},
getLineColor: (info) => {
Expand All @@ -242,6 +270,17 @@ function createSegmentationsLayer(): typeof GeoJsonLayer {
) {
return colors.hovered.rgb;
}

const { selected, filtered } = _determineSelectedOrFiltered(
info.properties?.id?.toString()
);
if (filtered) {
return [0, 0, 0];
} else {
if (!selected) {
return [0, 0, 0];
}
}
return colors.unselectedBoundary.rgb;
},
getLineWidth: (info) => {
Expand All @@ -257,9 +296,9 @@ function createSegmentationsLayer(): typeof GeoJsonLayer {
onHover: onHover,
onClick: onClick,
updateTriggers: {
getFillColor: dataPointSelectionUntrracked.hoveredTrackId,
getLineColor: dataPointSelection.selectedTrackId,
getLineWidth: dataPointSelection.selectedTrackId,
getFillColor: [dataPointSelectionUntrracked.hoveredTrackId],
getLineColor: [dataPointSelection.selectedTrackId],
getLineWidth: [dataPointSelection.selectedTrackId],
},
});
}
Expand Down Expand Up @@ -453,17 +492,24 @@ function createCenterPointLayer(): ScatterplotLayer {
if (d.trackId === dataPointSelection.selectedTrackId) {
return globalSettings.normalizedSelectedRgb;
}

const { filtered } = _determineSelectedOrFiltered(d.trackId);

if (filtered) {
return [0, 0, 0, 0];
}

return [228, 26, 28];
},
getStrokeWidth: 1,
updateTriggers: {
getFillColor: {
selected: dataPointSelection.selectedTrackId,
hovered: dataPointSelectionUntrracked.hoveredTrackId,
selected: [dataPointSelection.selectedTrackId],
hovered: [dataPointSelectionUntrracked.hoveredTrackId],
},
getLineColor: {
selected: dataPointSelection.selectedTrackId,
hovered: dataPointSelectionUntrracked.hoveredTrackId,
selected: [dataPointSelection.selectedTrackId],
hovered: [dataPointSelectionUntrracked.hoveredTrackId],
},
},
});
Expand Down Expand Up @@ -652,6 +698,8 @@ watch(currentTrackArray, renderDeckGL);
watch(dataPointSelection.$state, renderDeckGL);
watch(imageViewerStore.$state, renderDeckGL);
watch(contrastLimitSlider, renderDeckGL);
watch(highlightedCellIds, renderDeckGL);
watch(unfilteredTrackIds, renderDeckGL);

function clearSelection() {
dataPointSelection.selectedTrackId = null;
Expand Down
151 changes: 151 additions & 0 deletions apps/client/src/components/conditionSelector/ConditionChart.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<script setup lang="ts">
import { ref, nextTick, computed } from 'vue';
import { useDatasetSelectionStore } from '@/stores/dataStores/datasetSelectionUntrrackedStore';
import { useMosaicSelectionStore } from '@/stores/dataStores/mosaicSelectionStore';
import { useConditionSelectorStore } from '@/stores/componentStores/conditionSelectorStore';

import * as vg from '@uwdata/vgplot';
import { watch } from 'vue';
import { storeToRefs } from 'pinia';

// Props from parent component
// Accept props from the parent component
const props = defineProps<{
tags: [string, string][];
xAxisName: string;
yIndex: number;
selected: boolean;
chartLineWidth: number;
height: number;
}>();

const $height = vg.Param.value(props.height);

watch(
() => props.height,
(newHeight) => {
$height.update(newHeight);
}
);

const datasetSelectionStore = useDatasetSelectionStore();
const { experimentDataInitialized, compTableName } = storeToRefs(
datasetSelectionStore
);
const { conditionChartSelections, $conditionChartYAxisDomain } =
useMosaicSelectionStore();
const conditionSelectorStore = useConditionSelectorStore();
const { selectedIndividualYAxis } = storeToRefs(conditionSelectorStore);

// Container for chart.
const chartContainer = ref<HTMLElement | null>(null);

watch(
[
experimentDataInitialized,
chartContainer,
selectedIndividualYAxis,
conditionChartSelections,
bbollen23 marked this conversation as resolved.
Show resolved Hide resolved
],
async ([
isInitialized,
newChartContainer,
newYAxis,
newConditionChartSelections,
]) => {
if (!isInitialized || !newChartContainer || !newYAxis) {
return;
}
while (newChartContainer.firstChild) {
newChartContainer.removeChild(newChartContainer.firstChild);
}

await nextTick(); // Helps with hot reloading. On save, html ref will be temporarily none. This will wait until html has a ref.
const chart = createChart(props.xAxisName, newYAxis);

if (chart) {
newChartContainer.appendChild(chart);
}
},
{ deep: true }
);

// Styles
const lineColor =
conditionSelectorStore.chartColorScheme[
props.yIndex % conditionSelectorStore.chartColorScheme.length
];
const strokeWidth = props.chartLineWidth / 2;
const strokeWidthSelected = props.chartLineWidth;

// Filter statements in below code are left here to illustrate possibility of additional filter statements.
function createChart(xAxisName: string, yAxisName: string) {
if (!chartContainer.value) {
return null;
}
const source = `${props.tags[0][0]}-${props.tags[0][1]}_${props.tags[1][0]}-${props.tags[1][1]}`;
// Creates chart, filtered by the selection that uses the query.
const chart = vg.plot(
// Fills in area under line chart grey (optional)
vg.areaY(
vg.from(compTableName.value, {
filterBy: conditionChartSelections[source].baseSelection,
}),
{
x: xAxisName,
y1: 0,
y: vg.avg(yAxisName),
fill: 'grey',
fillOpacity: 0.3,
curve: 'linear',
stroke: null,
// filter: vg.sql`("${props.tags[0][0]}" = '${props.tags[0][1]}' AND "${props.tags[1][0]}" = '${props.tags[1][1]}')`
}
),
vg.lineY(
vg.from(compTableName.value, {
filterBy: conditionChartSelections[source].baseSelection,
}),
{
x: xAxisName,
y: vg.avg(yAxisName),
stroke: lineColor,
strokeWidth: strokeWidth,
curve: 'linear',
opacity: 0.6,
// filter: vg.sql`("${props.tags[0][0]}" = '${props.tags[0][1]}' AND "${props.tags[1][0]}" = '${props.tags[1][1]}')`
}
),
vg.lineY(
vg.from(compTableName.value, {
filterBy: conditionChartSelections[source].filteredSelection,
// cellLevelSelection
}),
{
x: xAxisName,
y: vg.avg(yAxisName),
stroke: lineColor,
strokeWidth: strokeWidthSelected,
curve: 'linear',
opacity: 1,
// filter: vg.sql`("${props.tags[0][0]}" = '${props.tags[0][1]}' AND "${props.tags[1][0]}" = '${props.tags[1][1]}')`
}
),

// Gets rid of axes and margins
vg.axis(false),
// Below would allow us to adjust the yAxis based on all the charts
vg.yDomain($conditionChartYAxisDomain),
vg.margin(0),
vg.height($height),
vg.width($height)
);
return chart;
}
</script>

<template>
<div ref="chartContainer"></div>
</template>

<style></style>
Loading