Skip to content
Snippets Groups Projects
Commit 44a78cbc authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Set a max width for distribution with little bar

parent 4b8479e6
No related branches found
No related tags found
No related merge requests found
Pipeline #129863 waiting for manual action with stages
in 6 minutes and 16 seconds
...@@ -15,7 +15,7 @@ export interface PlotMargin { ...@@ -15,7 +15,7 @@ export interface PlotMargin {
const margin = ref<PlotMargin>({ const margin = ref<PlotMargin>({
marginTop: 50, marginTop: 50,
marginRight: 20, marginRight: 30,
marginBottom: 100, marginBottom: 100,
marginLeft: 40 marginLeft: 40
...@@ -46,9 +46,6 @@ const genomeCountValue = ref<number>(10) ...@@ -46,9 +46,6 @@ const genomeCountValue = ref<number>(10)
const genomePercentDomain = ref<[number, number]>([0, 100]) const genomePercentDomain = ref<[number, number]>([0, 100])
const genomePercentValue = ref<[number, number]>([0, 0]) const genomePercentValue = ref<[number, number]>([0, 0])
const resetPercent = ref<Fn | null>(null) const resetPercent = ref<Fn | null>(null)
const axisOptions = ref<string[]>([{ title: "Percentage genomes", value: "percent" }, { title: "Number genomes", value: "size" }])
const plotY = ref<string>("percent") const plotY = ref<string>("percent")
const plotFill = ref<string>("size") const plotFill = ref<string>("size")
...@@ -63,11 +60,14 @@ onMounted(() => { ...@@ -63,11 +60,14 @@ onMounted(() => {
const plotContainer = ref(null) const plotContainer = ref(null)
const maxBarWidth = ref<number>(100)
const computedWidth = computed(() => { const computedWidth = computed(() => {
const { marginLeft, marginRight } = toValue(margin)
const filteredDistributionVal = toValue(filteredDistribution)
const screenWidth = useElementSize(plotContainer, { width: 500, height: 0 }, { box: 'border-box' }).width.value const screenWidth = useElementSize(plotContainer, { width: 500, height: 0 }, { box: 'border-box' }).width.value
// const screenWidth = toValue(width) > 1280 ? 1280 : toValue(width) // compare screen width and how many bar I have
return Math.max(screenWidth, 550); const totalWidthMax = marginLeft + marginRight + filteredDistributionVal.length * toValue(maxBarWidth)
return Math.min(Math.max(screenWidth, 550), totalWidthMax);
}); });
const computedDistribution = computed(() => { const computedDistribution = computed(() => {
...@@ -138,7 +138,7 @@ const distributionOptions = computed(() => { ...@@ -138,7 +138,7 @@ const distributionOptions = computed(() => {
marginLeft: 10, marginLeft: 10,
label: toValue(plotFill) === 'percent' ? toValue(plotLabelPercent) : toValue(plotLabelCount), label: toValue(plotFill) === 'percent' ? toValue(plotLabelPercent) : toValue(plotLabelCount),
}, },
width: computedWidth.value - marginRight - marginLeft, width: computedWidth.value,
marks: [ marks: [
Plot.barY( Plot.barY(
toValue(filteredDistribution), toValue(filteredDistribution),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment