mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-18 12:50:30 +08:00
Restore plot label angles (#8947)
* changes * add changeset * Update gradio/components/native_plot.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update gradio/components/native_plot.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update gradio/components/native_plot.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
3539787ebb
commit
96d36d70ad
6
.changeset/eleven-baths-know.md
Normal file
6
.changeset/eleven-baths-know.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/nativeplot": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Restore plot label angles
|
@ -57,6 +57,8 @@ class NativePlot(Component):
|
||||
color_map: dict[str, str] | None = None,
|
||||
x_lim: list[float] | None = None,
|
||||
y_lim: list[float] | None = None,
|
||||
x_label_angle: float = 0,
|
||||
y_label_angle: float = 0,
|
||||
caption: str | None = None,
|
||||
sort: Literal["x", "y", "-x", "-y"] | list[str] | None = None,
|
||||
height: int | None = None,
|
||||
@ -90,6 +92,8 @@ class NativePlot(Component):
|
||||
height: The height of the plot in pixels.
|
||||
x_lim: A tuple or list containing the limits for the x-axis, specified as [x_min, x_max]. If x column is datetime type, x_lim should be timestamps.
|
||||
y_lim: A tuple of list containing the limits for the y-axis, specified as [y_min, y_max].
|
||||
x_label_angle: The angle of the x-axis labels in degrees offset clockwise.
|
||||
y_label_angle: The angle of the y-axis labels in degrees offset clockwise.
|
||||
caption: The (optional) caption to display below the plot.
|
||||
sort: The sorting order of the x values, if x column is type string/category. Can be "x", "y", "-x", "-y", or list of strings that represent the order of the categories.
|
||||
height: The height of the plot in pixels.
|
||||
@ -118,6 +122,8 @@ class NativePlot(Component):
|
||||
self.color_map = color_map
|
||||
self.x_lim = x_lim
|
||||
self.y_lim = y_lim
|
||||
self.x_label_angle = x_label_angle
|
||||
self.y_label_angle = y_label_angle
|
||||
self.caption = caption
|
||||
self.sort = sort
|
||||
self.height = height
|
||||
|
@ -42,6 +42,8 @@
|
||||
export let color_map: Record<string, string> | null = null;
|
||||
export let x_lim: [number, number] | null = null;
|
||||
export let y_lim: [number, number] | null = null;
|
||||
export let x_label_angle: number | null = null;
|
||||
export let y_label_angle: number | null = null;
|
||||
export let caption: string | null = null;
|
||||
export let sort: "x" | "y" | "-x" | "-y" | string[] | null = null;
|
||||
function reformat_sort(
|
||||
@ -252,6 +254,7 @@
|
||||
computed_style.getPropertyValue("--text-sm")
|
||||
);
|
||||
|
||||
/* eslint-disable complexity */
|
||||
return {
|
||||
$schema: "https://vega.github.io/schema/vega-lite/v5.17.0.json",
|
||||
background: "transparent",
|
||||
@ -328,7 +331,7 @@
|
||||
value: 0
|
||||
},
|
||||
x: {
|
||||
axis: {},
|
||||
axis: x_label_angle ? { labelAngle: x_label_angle } : {},
|
||||
field: x,
|
||||
title: x_title || x,
|
||||
type: value.datatypes[x],
|
||||
@ -337,7 +340,7 @@
|
||||
sort: _sort
|
||||
},
|
||||
y: {
|
||||
axis: {},
|
||||
axis: y_label_angle ? { labelAngle: y_label_angle } : {},
|
||||
field: y,
|
||||
title: y_title || y,
|
||||
type: value.datatypes[y],
|
||||
@ -441,6 +444,7 @@
|
||||
width: chart_element.offsetWidth,
|
||||
title: title || undefined
|
||||
};
|
||||
/* eslint-enable complexity */
|
||||
}
|
||||
|
||||
export let label = "Textbox";
|
||||
|
Loading…
x
Reference in New Issue
Block a user