You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EDIT: I managed to fix this by setting the parenthesis around the filter correctly
I am using altair to create a reporting page for a collaboration I am part of. I managed to implement a time series plot that can set limits of the x-axis. Nevertheless vega is not able to do change both x-axis limits at the same time. If I add one of the selections only, they work perfectly.
Here's to code I am trying to work with:
import altair as alt
import pandas as pd
import numpy as np
# Create a sample dataframe with datetime data
data = pd.DataFrame({
'date': pd.date_range('2023-01-01', periods=100, freq='D'),
'value': np.random.randn(100).cumsum()
})
# Define the text input bindings for start and end dates
start_date_input = alt.binding(input='text', name='Start Date: ')
end_date_input = alt.binding(input='text', name='End Date: ')
interval = alt.selection_interval(encodings=['x'])
# Create selections for the start and end dates
start_date_selection = alt.selection_point(fields=['start_date'], bind=start_date_input, value='2023-01-01')
end_date_selection = alt.selection_point(fields=['end_date'], bind=end_date_input, value='2023-02-01')
# Filter data based on the selected date range
date_filter = (alt.datum.date >= alt.expr.toDate(start_date_selection.start_date)) & (alt.datum.date <= alt.expr.toDate(end_date_selection.end_date))
# Create the chart and use the date range selection to filter the data
chart = alt.Chart(data).mark_line().encode(
x='date:T',
y='value:Q'
).transform_filter(
interval
).add_params(
interval
).properties(
width=600,
height=400
)
chart = chart.transform_filter(
date_filter
).add_params(
end_date_selection,
start_date_selection
)
chart
Do you have any idea on what I could do to make limit setting work for both limits at the same time? Any help is appreciated. ChatGPT is stuck in loops of suggesting variations on the selection that get me no where or cause errors.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey everyone,
EDIT: I managed to fix this by setting the parenthesis around the filter correctly
I am using altair to create a reporting page for a collaboration I am part of. I managed to implement a time series plot that can set limits of the x-axis. Nevertheless vega is not able to do change both x-axis limits at the same time. If I add one of the selections only, they work perfectly.
Here's to code I am trying to work with:
Do you have any idea on what I could do to make limit setting work for both limits at the same time? Any help is appreciated. ChatGPT is stuck in loops of suggesting variations on the selection that get me no where or cause errors.
Beta Was this translation helpful? Give feedback.
All reactions