How to make the plot take full width of it's container? #2105
Unanswered
that-ambuj
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Setting the width to This is what the code looks like: import * as Plot from "@observablehq/plot";
// @ts-expect-error No Types provided
import * as htl from "htl";
import { nextTick, onMounted, onUnmounted, ref } from "vue";
import appl from "../../../extras/aapl.json";
import { useDisplay } from "vuetify";
const svgRef = ref<HTMLElement>();
const plot = ref<ReturnType<typeof Plot.plot>>();
const { width } = useDisplay();
onMounted(() => {
plot.value = Plot.plot({
width: width.value,
height: 200,
marks: [
Plot.lineY(appl, {
stroke: "#00AFFF",
x: "Date",
y: "Open",
interval: "friday",
}),
Plot.areaY(appl, {
fill: "#00AFFF",
fillOpacity: 0.1,
x: "Date",
y: "Open",
interval: "friday",
}),
],
});
svgRef.value?.appendChild(plot.value);
});
onUnmounted(() => {
svgRef.value?.removeChild(plot.value!);
}); |
Beta Was this translation helpful? Give feedback.
1 reply
-
Typically you would use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently working on a dashboard, I need to make the plot take full width but I can't seem to find the correct way to do this with responsiveness.
As shown, the plot by default does not take the full available space.
With
width
set to high number (i.e. 2000) it takes the full space but the text is too small, especially for mobile devices.Now with
style
css set towidth: 100%
, it takes the full width but the text is too large.Is there any way that I can make it responsive while the text is correctly sized?
Beta Was this translation helpful? Give feedback.
All reactions