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

String Values don't allow for spaces #4

Open
shmolf opened this issue Apr 17, 2021 · 1 comment
Open

String Values don't allow for spaces #4

shmolf opened this issue Apr 17, 2021 · 1 comment

Comments

@shmolf
Copy link

shmolf commented Apr 17, 2021

Example JSON:

{
  "chart": {
    "type": "radar"
  },
  "series": [{
    "name": "Series 1",
    "data": [80,50,30,40,100,20]
  }],
  "title": {
    "text": "Basic Radar Chart"
  },
  "xaxis": {
    "categories": ["January","February","March","April","May","June"]
  }
}

Because each of these strings has a space between the quotes, it disrupts how the data is stored in the data attribute:

  • Series 1
  • Basic Radar Chart

HTML when there's no spaces:

<div type="apexChart" data-options="{&quot;chart&quot;:{&quot;type&quot;:&quot;radar&quot;},&quot;series&quot;:[{&quot;name&quot;:&quot;Series1&quot;,&quot;data&quot;:[80,50,30,40,100,20]}],&quot;title&quot;:{&quot;text&quot;:&quot;BasicRadarChart&quot;},&quot;xaxis&quot;:{&quot;categories&quot;:[&quot;January&quot;,&quot;February&quot;,&quot;March&quot;,&quot;April&quot;,&quot;May&quot;,&quot;June&quot;]}}" id="Apex801" style="min-height: 715px;">

versus HTML when there's spaces:

<div type="apexChart" data-options="{&quot;chart&quot;:{&quot;type&quot;:&quot;radar&quot;},&quot;series&quot;:[{&quot;name&quot;:&quot;Series" 1","data":[80,50,30,40,100,20]}],"title":{"text":"basic="" radar="" chart"},"xaxis":{"categories":["january","february","march","april","may","june"]}}="" id="Apex621">

It may help use use encodeURIComponent() on the JSON before storing it in the data attribute. Then using decodeURIComponent() when extracting the data attribute.

Though, based on the &quot;, those functions may already be in use.

@znfgnu
Copy link

znfgnu commented Nov 29, 2022

What about replacing spaces to &nbsp;?

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

No branches or pull requests

2 participants