Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some BarPlot Fixes #4531

Merged
merged 4 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -38,6 +38,8 @@ demo.launch()
- Fixes issue with Clear button not working for `Label` component by [@abidlabs](https://github.com/abidlabs) in [PR 4456](https://github.com/gradio-app/gradio/pull/4456)
- Restores the ability to pass in a tuple (sample rate, audio array) to gr.Audio() by [@abidlabs](https://github.com/abidlabs) in [PR 4525](https://github.com/gradio-app/gradio/pull/4525)
- Ensure code is correctly formatted and copy button is always present in Chatbot by [@pngwn](https://github.com/pngwn) in [PR 4527](https://github.com/gradio-app/gradio/pull/4527)
- `show_label` will not automatically be set to `True` in `gr.BarPlot.update` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4531](https://github.com/gradio-app/gradio/pull/4531)
- `gr.BarPlot` group text now respects darkmode by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4531](https://github.com/gradio-app/gradio/pull/4531)

## Other Changes:

Expand Down
8 changes: 4 additions & 4 deletions gradio/components/bar_plot.py
Expand Up @@ -143,11 +143,11 @@ def update(
caption: str | None = None,
interactive: bool | None = None,
label: str | None = None,
show_label: bool = True,
container: bool = True,
show_label: bool | None = None,
container: bool | None = None,
scale: int | None = None,
min_width: int = 160,
visible: bool = True,
min_width: int | None = None,
visible: bool | None = None,
):
"""Update an existing BarPlot component.

Expand Down
3 changes: 2 additions & 1 deletion js/plot/src/Plot.svelte
Expand Up @@ -6,7 +6,7 @@
import { get_next_color } from "@gradio/utils";
import { Vega } from "svelte-vega";
import { afterUpdate, beforeUpdate, onDestroy } from "svelte";
import { create_config } from "./utils";
import { create_config, bar_plot_header_encoding} from "./utils";
import { Empty } from "@gradio/atoms";
import type { ThemeMode } from "js/app/src/components/types";

Expand Down Expand Up @@ -96,6 +96,7 @@
(e, i) => get_color(i)
);
}
spec.config.header = bar_plot_header_encoding(darkmode);
break;
default:
break;
Expand Down
8 changes: 6 additions & 2 deletions js/plot/src/utils.ts
@@ -1,7 +1,7 @@
import type { Config as VegaConfig } from "vega";

const dark = "#e2e8f0";
const light = "#111827";
export const dark = "#e2e8f0";
export const light = "#111827";

export function create_config(darkmode: boolean): VegaConfig {
return {
Expand Down Expand Up @@ -31,3 +31,7 @@ export function create_config(darkmode: boolean): VegaConfig {
}
};
}

export function bar_plot_header_encoding(darkmode: boolean): Object {
return { labelFont: "sans-serif", labelColor: darkmode ? dark : light };
}
6 changes: 6 additions & 0 deletions test/test_components.py
Expand Up @@ -2630,6 +2630,12 @@ def test_get_config(self):
"bokeh_version": "3.0.3",
}

def test_update_defaults_none(self):
output = gr.BarPlot.update(simple, x="a", y="b", height=100, width=200)
assert all(
v is None for k, v in output.items() if k not in ["value", "__type__"]
)

def test_no_color(self):
plot = gr.BarPlot(
x="a",
Expand Down