Skip to content

Commit

Permalink
Native Plot respects the height parameters (#10546)
Browse files Browse the repository at this point in the history
* make height responsive

* add changeset

---------

Co-authored-by: Freddy Boulton <freddyboulton@hf-freddy.local>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 8, 2025
1 parent 196b600 commit 27155cf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/great-llamas-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/nativeplot": patch
"gradio": patch
---

fix:Native Plot respects the height parameters
2 changes: 2 additions & 0 deletions js/nativeplot/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@
: [])
],
width: chart_element.offsetWidth,
height: height ? "container" : undefined,
title: title || undefined
};
/* eslint-enable complexity */
Expand Down Expand Up @@ -561,6 +562,7 @@
<style>
div {
width: 100%;
height: 100%;
}
:global(#vg-tooltip-element) {
font-family: var(--font) !important;
Expand Down
30 changes: 30 additions & 0 deletions js/nativeplot/NativePlot.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@
}}
/>

<Story
name="Line Plot with height"
args={{
value: {
columns: ["time", "value"],
data: [
[1, 10],
[2, 15],
[3, 13],
[4, 17],
[5, 14],
[6, 20]
],
datatypes: {
time: "quantitative",
value: "quantitative"
},
mark: "line"
},
x: "time",
y: "value",
title: "Sample Line Plot",
x_title: "Time",
y_title: "Value",
height: 250,
label: "Line Plot",
show_label: true
}}
/>

<Story
name="Empty Plot"
args={{
Expand Down

0 comments on commit 27155cf

Please sign in to comment.