Skip to content

Commit ede7428

Browse files
Fix gr.NativePlot sorting of labels as default behaviour (#10953)
* Fix #10764: Automatic sorting of labels in plots Originally, the bug appeared to be isolated to gr.BarPlot, but it turns out that it affects all gr.NativePlot components, including BarPlot, LinePlot, and ScatterPlot. Although the data does not seem sorted in the program's flow, it gets sorted when the Svelte file is rendered. This issue occurs because the reformat_sort function in index.svelte of NativePlot returns undefined when sort is not specified, which, during compilation, is treated as void 0. This implicitly triggers default sorting. To resolve this, I changed undefined to null, ensuring that the compiled code handles it as null, resulting in unsorted data being displayed in the browser. * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent a8dc9f4 commit ede7428

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/funny-cows-draw.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/nativeplot": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Fix gr.NativePlot sorting of labels as default behaviour

js/nativeplot/Index.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
| "descending"
5757
| { field: string; order: "ascending" | "descending" }
5858
| string[]
59+
| null
5960
| undefined {
6061
if (_sort === "x") {
6162
return "ascending";
@@ -66,7 +67,7 @@
6667
} else if (_sort === "-y") {
6768
return { field: y, order: "descending" };
6869
} else if (_sort === null) {
69-
return undefined;
70+
return null;
7071
} else if (Array.isArray(_sort)) {
7172
return _sort;
7273
}

0 commit comments

Comments
 (0)