-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow plot tooltip to show extra columns #9800
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/dc1545193da353c9599980bb0648a2b058eb4e44/gradio-5.4.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@dc1545193da353c9599980bb0648a2b058eb4e44#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/dc1545193da353c9599980bb0648a2b058eb4e44/gradio-client-1.7.1.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/dc1545193da353c9599980bb0648a2b058eb4e44/dist/lite.js""></script> |
js/nativeplot/Index.svelte
Outdated
} | ||
return obj; | ||
}); | ||
if (tooltip == "all") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't filter out "irrelevant" columns if tooltip == "all"
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
gradio/components/native_plot.py
Outdated
@@ -94,6 +95,7 @@ def __init__( | |||
x_axis_labels_visible: Whether the x-axis labels should be visible. Can be hidden when many x-axis labels are present. | |||
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. | |||
tooltip: The tooltip to display when hovering on a point. "axis" shows the values for the axis columns, "all" shows all column values, and "none" shows no tooltips. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better api would be to just let it take a list of column names. Often, dataframes will have a large number of irrelevant columns and I'm sure we'll get the request to be able to select specific columns to show in the tooltip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok added support for passing list of column names
gradio/components/native_plot.py
Outdated
@@ -94,6 +95,7 @@ def __init__( | |||
x_axis_labels_visible: Whether the x-axis labels should be visible. Can be hidden when many x-axis labels are present. | |||
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. | |||
tooltip: The tooltip to display when hovering on a point. "axis" shows the values for the axis columns, "all" shows all column values, and "none" shows no tooltips. Can also provide a list of strings representing columns to show in the tooltip. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended behavior that the axes are always shown in the tooltip? If so let's mention it here in the docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm @aliabid94. Just noting that the axes are always shown in the tooltip, even if not explicitly listed in the list of columns e.g. see this example:
import pandas as pd
import numpy as np
import gradio as gr
# Generate random data
np.random.seed(42)
dates = pd.date_range(start='2024-01-01', periods=30, freq='D')
data = {
'Date': dates,
'Value1': np.random.normal(100, 15, 30).cumsum(),
'Value2': np.random.normal(50, 10, 30).cumsum()
}
df = pd.DataFrame(data)
with gr.Blocks() as demo:
plot = gr.LinePlot(
df,
x="Date",
y="Value1",
title="Random Time Series Data",
tooltip=["Value2"],
)
demo.launch()
If this is intended behavior, let's make a note of it in the docstring
Yep its intended, added to docstring |
Merging in for the release! |
If
tooltip="all"
, will show all columns for a datapoint, not just the axis column names