Show terminal value on the right, and show cross hairs, of a line chart

I am able to plot fine like this:

df = GetDF['change']

Is there a way to tell the line chart to display the terminal value at the right y-axis?

Also, is there a way to turn on cross-hairs on a linechart?

Share a clear and concise description of the issue. Aim for 2-3 sentences.

Steps to reproduce

Code snippet:

add code here

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Explain what you expect to happen when you run the code above.

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

Shared this on your StackOverflow post but I’ll paste below as well

st.line_chart() is essentially a wrapper around st.altair_chart() with less customizability. To customize your chart more, you’ll want to use st.altair_chart . This post explains how to add a label to an Altair chart for the point with the max x value. You can then pass your Altair chart with labels to st.altair_chart .

Hi Caroline,

I see this example program but I don’t see the line?

import altair as alt
import pandas as pd

df = pd.DataFrame({
    'x': np.random.randn(100),
    'y': np.random.randn(100)

chart = alt.Chart(df).mark_point().encode(x='x', y='y')
line = alt.Chart(pd.DataFrame({'y': [1]})).mark_rule().encode(y='y')

chart + line

Based on this post, it looks you need to use the aggregate parameter for this. This is the snippet that was shared on the StackOverflow thread:

labels = alt.Chart(data_core_sub).mark_text(align='left', dx=3).encode(
    alt.X('days:Q', aggregate='max'),
    alt.Y('value:Q', aggregate={'argmax': 'days'}, scale=alt.Scale(type='log')),
    alt.Color('country:N', legend=None, scale=alt.Scale(domain=countries_list,type='ordinal')), 
).properties(title='COVID-19 total deaths', width=600)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.