Skip to content

restyle textposition produces javascript error #2688

@kochelmonster

Description

@kochelmonster

Try out the following example and click on "No Text" link.

<head>
  <!-- Plotly.js -->
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>

<body>

  <div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
  <script>
var xValue = ['Product A', 'Product B', 'Product C'];

var yValue = [20, 14, 23];

var trace1 = {
x: xValue,
y: yValue,
type: 'bar',
text: yValue,
textposition: 'auto',
hoverinfo: 'none',
marker: {
  color: 'rgb(158,202,225)',
  opacity: 0.6,
  line: {
    color: 'rbg(8,48,107)',
    width: 1.5
  }
}
};

var data = [trace1];

var layout = {
title: 'January 2013 Sales Report'
};

Plotly.newPlot('myDiv', data, layout);

function no_text() {
  Plotly.restyle('myDiv', {textposition: ['none']}, [0]);
}

  </script>

  <a href="javascript:no_text()">No Text</a>

</body>

Activity

alexcjohnson

alexcjohnson commented on Jun 1, 2018

@alexcjohnson
Collaborator

Thanks @kochelmonster - there's another bug if you delete the text array:

Plotly.restyle(gd, {text: null})

The text doesn't disappear, and gets stuck in place if you pan/zoom on the plot:
screen shot 2018-06-01 at 5 02 05 pm

alexcjohnson

alexcjohnson commented on Jun 1, 2018

@alexcjohnson
Collaborator

@etpinard seems like these came in with some of the 🐎 optimizations between 1.36 and 1.37 https://codepen.io/alexcjohnson/pen/jKbmmV

etpinard

etpinard commented on Jun 1, 2018

@etpinard
Contributor

optimizations between 1.36 and 1.37

Ok. On it!

etpinard

etpinard commented on Jun 1, 2018

@etpinard
Contributor

It's from #2574, where we 🔪 that ugly selectAll('.trace') on each Cartesian.plot call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething brokenregressionthis used to work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @alexcjohnson@kochelmonster@etpinard

      Issue actions

        restyle textposition produces javascript error · Issue #2688 · plotly/plotly.js