Skip to content

Commit 521d00a

Browse files
committed
Fix gradio-app#10764: Prevent automatic sorting of labels in gr.NativePlot components
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 null, which, after compilation, is treated as void 0. This implicitly triggers default sorting. To solve this, I changed undefined to null, ensuring that the compiled code handles it as null, resulting in unsorted data being displayed in the browser.
1 parent b19e8ad commit 521d00a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)