Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

API doesn't handle UTF-8 characters correctly. #43

Open
bramp opened this issue Jun 13, 2016 · 4 comments · May be fixed by #49
Open

API doesn't handle UTF-8 characters correctly. #43

bramp opened this issue Jun 13, 2016 · 4 comments · May be fixed by #49

Comments

@bramp
Copy link

bramp commented Jun 13, 2016

I tried setting some math characters (e.g 'μ') in a title of a figure, like so:

    var figure = {
      layout: {
        title: 'Normal (μ = 0, σ = 1.0)',
      }
    };

However, when I call plotly.getImage(figure, ...) a error is returned and it looks like the server returned a "500 Internal Server Error".

When I use the graph builder on the plot.ly site, I see that Chrome POSTs JSON in the form title: 'Normal (\u03bc = 0, \u03c3 = 1.0)', however Node.js seems to send it literally title: 'Normal (μ = 0, σ = 1.0)'. Reading the JSON spec, how Node.js is sending it is valid, however, hacking the plotly/index.js, and changing the output of JSON.stringify to use \u0XXX notation seems to work.

So please either change your Node.js API to encode in a way that is suitable, or please change your server to accept all valid JSON.

bramp added a commit to bramp/plotly-nodejs that referenced this issue Apr 10, 2017
@bramp bramp linked a pull request Apr 10, 2017 that will close this issue
@bramp
Copy link
Author

bramp commented May 21, 2018

@bartekadams did you try the patch in my pull request https://github.com/plotly/plotly-nodejs/pull/49/files ? And what exactly did you try, and what exactly didn't work?

@bartekadams
Copy link

bartekadams commented May 21, 2018

@bramp thanks it is working now, at last I got what you meant with this changes :)
Sorry for deleting comment. I didn't expect you to answer so quickly.

@a1019328562
Copy link

@bramp I encounter similar problem when use plotly.getImage API. I want to show Chinese character like follow:
var figure = { 'data': [trace1], 'layout': { 'title': '标题' } };
but it can not show right character, just show some box. it seems due to lack of font in server, please help me. your help is greatly appreciated!

@shaedmorgan
Copy link

I'm having this same issue plotting the triangle figure as text (I don't like the plotly triangle markers, so I've been using this instead.
"\u25B3"
I substitute that, but it's giving me the same error 500 - bad request. Help?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants