Skip to content

plotly wrongly automatically converts strings to integers if possible #7147

Open
@toolslive

Description

@toolslive
<head>
    <script src='https://cdn.plot.ly/plotly-2.35.0.min.js'></script>
</head>
<body>
    <div id='myDiv'>
    </div>
    <script>
     //var x = [1,2,3,4] // interpreted as number
     //var x = ['a','b','c', 'd']; // used as labels
     var x = ['-1','1e1', '0x64']; // now they're numbers :(
     var trace1 = {
         x: x,
         y: [10, 15, 13, 17],
         type: 'scatter'
     };

     var trace2 = {
         x: x,
         y: [16, 5, 11, 9],
         type: 'scatter'
     };

     var data = [trace1, trace2];

     Plotly.newPlot('myDiv', data);

    </script>
</body>

plotly_ducktyping

It should just use strings as labels (just like what happens when x= ['a','b','c','d'] ).
A simple work around is to prefix the strings with &nbsp; to sabotage the convertion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions