title: Plotly update data
body: <p>Okay so i have the following code:</p>
  
  <pre><code>    var element = document.getElementById(scope.changeid);
  
  function getData(division,redraw) {
      var employeeData = [];
      if (!division) {
          $http.get(api.getUrl('competenceUserAverageByMyDivisions', null)).success(function (response) {
              processData(response,redraw);
          });
      }
      else {
          $http.get(api.getUrl('competenceUserAverageByDivision', division)).success(function (response) {
              processData(response,redraw);
          })
      }
  
  }
  
  function processData(data,redraw) {
      var y = [],
          x1 = [],
          x2 = [];
  
      data.forEach(function (item) {
          y.push(item.user.profile.firstname);
          x1.push(item.current_level);
          x2.push(item.expected);
      });
  
      var charData = [{
              x: x1,
              y: y,
              type: 'bar',
              orientation: 'h',
  
              name: 'Nuværende'
          }, {
              x: x2,
              y: y,
              type: 'bar',
              orientation: 'h',
  
              name: 'Forventet'
          }],
          layout = {
              barmode: 'stack',
              legend: {
                  traceorder: 'reversed',
                  orientation: 'h'
  
              }
          };
  
      if(!redraw){
          Plotly.plot(element, charData, layout);
      }
      else
      {
          Plotly.redraw(element,charData,layout);
      }
  }
  
  scope.$watch('divisionId', function (newValue, oldValue) {
      if (newValue) {
          getData(newValue.id,true);
      }
  }, true);
  
  getData(null,false);
  </code></pre>
  
  <p>Which creates the following chart:</p>
  
  <p><a href="https://i.stack.imgur.com/hswRf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hswRf.png" alt="enter image description here"></a></p>
  
  <p>Now as you can see ive added a <code>watcher</code></p>
  
  <pre><code>            scope.$watch('divisionId', function (newValue, oldValue) {
              if (newValue) {
                  getData(newValue.id,true);
              }
          }, true);
  </code></pre>
  
  <p>Now when i trigger this it should update the chart and call <code>Plotly.redraw(element,charData,layout);</code></p>
  
  <p>However when it does this the chart does not change at all. There is no error in the console so i am not quite sure what to do?</p>