-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and adapt circular plot from bakrep
- Loading branch information
1 parent
1adcbf0
commit 88a6ef0
Showing
24 changed files
with
3,219 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import FeaturePlotViewer from './FeaturePlotViewer.vue' | ||
import { fn } from '@storybook/test' | ||
import { ref } from 'vue' | ||
import { fixtures, fixturesFn } from '@/test-data/bakta-results' | ||
const meta: Meta<typeof FeaturePlotViewer> = { | ||
component: FeaturePlotViewer, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof FeaturePlotViewer> | ||
export const Default: Story = { | ||
args: { | ||
bakta: fixturesFn('1.10'), | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<div class="w-100 h-100"> | ||
<div v-if="bakta.sequences.length > 1" class="form-floating"> | ||
<select id="selectSequence" class="form-select" v-model="currentId"> | ||
<option v-for="s of bakta.sequences" :key="s.id" :value="s.id"> | ||
{{ s.id }} | ||
</option> | ||
</select> | ||
<label for="selectSequence">Select sequence</label> | ||
</div> | ||
<select v-if="false" v-model="type"> | ||
<option value="circular">circular</option> | ||
<option value="linear">linear</option> | ||
</select> | ||
<div class="my-2 w-100 h-100" ref="comp"> | ||
<BaktaCircularPlot | ||
v-if="data.seq && type == 'circular'" | ||
:sequence="data.seq" | ||
:features="data.feat" | ||
:size="size" | ||
/> | ||
<BaktaLinearPlot | ||
v-if="data.seq && type == 'linear'" | ||
:sequence="data.seq" | ||
:features="data.feat" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { type Result } from '@/model/result-data' | ||
import { computed, onMounted, ref, useTemplateRef } from 'vue' | ||
import BaktaCircularPlot from './feature-plot/BaktaCircularPlot.vue' | ||
import BaktaLinearPlot from './feature-plot/BaktaLinearPlot.vue' | ||
const props = defineProps<{ | ||
bakta: Result | ||
}>() | ||
const currentId = ref<string>('') | ||
const type = ref<'circular' | 'linear'>('circular') | ||
const size = ref({ width: 1000, height: 1000 }) | ||
const data = computed(() => ({ | ||
seq: props.bakta.sequences.find((x) => x.id == currentId.value), | ||
feat: props.bakta.features.filter((x) => x.sequence === currentId.value), | ||
})) | ||
const component = useTemplateRef('comp') | ||
onMounted(() => { | ||
if (props.bakta.sequences.length > 0) { | ||
currentId.value = props.bakta.sequences[0].id | ||
} | ||
if (component.value) { | ||
const obs = new ResizeObserver(() => { | ||
if (component.value) { | ||
const bbox = component.value.getBoundingClientRect() | ||
const max = Math.max(bbox.width, bbox.height) | ||
size.value = { width: max, height: max } | ||
} | ||
}) | ||
obs.observe(component.value) | ||
} | ||
}) | ||
</script> |
35 changes: 35 additions & 0 deletions
35
src/components/bakta-result/feature-plot/BaktaCircularPlot.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import BaktaCircularPlot from './BaktaCircularPlot.vue' | ||
|
||
import { ref } from 'vue' | ||
import type { Result } from '@/model/result-data' | ||
import { fixtures } from '@/test-data/bakta-results' | ||
const meta: Meta<typeof BaktaCircularPlot> = { | ||
component: BaktaCircularPlot, | ||
} | ||
|
||
const result: Result = fixtures.result['1.10'] | ||
|
||
export default meta | ||
type Story = StoryObj<typeof BaktaCircularPlot> | ||
|
||
export const Default: Story = { | ||
args: { sequence: result.sequences[0], features: result.features }, | ||
render: (args) => ({ | ||
components: { BaktaCircularPlot }, | ||
setup() { | ||
let cur = 0 | ||
const seq = ref(result.sequences[0]) | ||
const feat = ref(result.features.filter((x) => x.sequence === seq.value.id)) | ||
function nextSequence() { | ||
cur = (cur + 1) % result.sequences.length | ||
seq.value = result.sequences[cur] | ||
feat.value = result.features.filter((x) => x.sequence === seq.value.id) | ||
} | ||
return { seq, feat, nextSequence, args } | ||
}, | ||
template: | ||
'<button @click="nextSequence">Toggle</button><BaktaCircularPlot v-bind="args" :sequence="seq" :features="feat" />', | ||
}), | ||
} |
Oops, something went wrong.