plotly / plotly/plotly.js

text annotations with with hrefs containing encoded characters such as '#' break links

Open
#4,084 13 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

The solution that was adopted in #2471 to enable support for encoded hrefs seems to break for characters like # and :. This seems to be because JavaScript's encodeURI and decodeURI do not encode/decode these characters. Perhaps more nuanced used of encodeURIComponent and decodeURIComponent needs to be used?

Here's a minimal working example in Python, which is trying to link to a Twitter query for #food lang:en, in which the # and : characters need to be encoded:

import plotly.io as pio
fig = {"data": [{"type": "bar", "x": ['<a href="http://twitter.com/search? q=%23food%20lang%3Aen">query</a>'], "y": [1]}]}
pio.show(fig)

The generated link ends up being scrambled because the hash and colon escape sequences are not decoded, but are then encoded again, resulting in the following Twitter search: %23food lang%3Aen

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the approach adopted in issue #2471 and reproduce the minimal Python example in a Plotly chart. Trace the JavaScript encodeURI/decodeURI handling for the href and verify that encoded # and : characters remain intact so the Twitter query opens correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.