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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Add Show Image Marks With Selection/Show Local Images Examples #3219

Merged
merged 8 commits into from
Oct 16, 2023

Conversation

ChiaLingWeng
Copy link
Contributor

@ChiaLingWeng ChiaLingWeng commented Oct 6, 2023

This will close #2739

  1. Show Image Marks With Selection
    image
  2. Use Local Images As Image Marks
    I only provide source code here, not sure if there is any better illustration.
    image

@joelostblom
Copy link
Contributor

Thanks for all your documentation PRs @ChiaLingWeng, they are great! I'm going to take closer look this weekend, but one comment I have now already is that it would be good to include a link to the new tutorial for how to show numpy images somewhere on this page https://altair-viz.github.io/case_studies/numpy-tooltip-images.html, could you add that where you see fit?

@ChiaLingWeng
Copy link
Contributor Author

Hi @joelostblom , no problem!
Added links to Numpy Tooltip Images and Image Tooltip under Show Image Marks With Selection section, not create a section for image tooltip since it might be not straightforward to have section only points to other pages, but feel free to discuss!
image

@joelostblom joelostblom self-assigned this Oct 7, 2023
Copy link
Contributor

@joelostblom joelostblom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @ChiaLingWeng ! This is a big improvement and I have a few comments that I think can improve this page further.

one with point marks and the other with image marks, applying the selection filter only to the latter.
By combining these two charts, we can achieve the desired result.

.. altair-plot::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two examples in this code will be easier to understand if we show them one at a time like in #2278 (comment) and don't hide the code by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update as below
image
image

source = pd.DataFrame.from_records(
[{'a': 1, 'b': 1, 'image': 'https://altair-viz.github.io/_static/altair-logo-light.png'},
{'a': 2, 'b': 2, 'image': 'https://avatars.githubusercontent.com/u/11796929?s=200&v=4'},
{'a': 3, 'b': 3, 'image': ''}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this empty image included?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to remove this... just for testing if point withot image can be shown correctly

In the layered chart, images may overlap one other, using the faceted chart instead can
avoid this issue.

If you're looking to learn how to create an image tooltip that displays an image when hovering over a point,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include the Image Tooltip example directly on this page under its own heading and remove the gallery example? I think this is a natural place for it and we have so many different gallery examples that it is sometimes hard to find what we are looking for there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Image Tooltip section
image

doc/user_guide/marks/image.rst Outdated Show resolved Hide resolved

# replace your image path here
# recommend use raw string for absolute path; i.e. r'C:\Users\...\img00.jpg'
images = ["./img00.jpg", "./img01.jpg", "./img02.jpg"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this image https://altair-viz.github.io/_static/altair-logo-light.png' might be available locally to the doc build, either as _static/altair-logo-light.png' or just altair-logo-light.png'. Could you try with those two paths and see if you can actually use it as a local image? Then we could run this example in the docs instead of only showing the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update! The relative path is "doc/_static/gray-square.png"
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done 🙌

@ChiaLingWeng ChiaLingWeng marked this pull request as draft October 10, 2023 09:40
@ChiaLingWeng ChiaLingWeng marked this pull request as ready for review October 11, 2023 02:27
Copy link
Contributor

@joelostblom joelostblom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big improvement to the image docs, thanks again @ChiaLingWeng ! I added an example of automatically resizing charts when images start out hidden. Merging when tests are passing

@joelostblom joelostblom merged commit 9602812 into vega:main Oct 16, 2023
10 checks passed
@ChiaLingWeng ChiaLingWeng deleted the doc-dev3 branch October 23, 2023 01:40
@ChiaLingWeng ChiaLingWeng restored the doc-dev3 branch November 8, 2023 02:46
@ChiaLingWeng ChiaLingWeng deleted the doc-dev3 branch November 8, 2023 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the image mark documentation
2 participants