Automatically redraw a highStock chart under Angularjs

I want to make a highStock chart under AngularJS, and I want to change some chart option by some buttons. However, it seems that changing the option does not redraw the chart automatically. I tried to follow a thread which works with highChart, but I cannot make the directive work with highStock. Here is a plunker, the watch is well triggered, whereas I don’t know how redraw the chart well.

  .directive('highchart', function($parse, $timeout) {
    return {
      restrict: 'E',
      template: '<div></div>',
      replace: true,
      link: function(scope, element, attrs) {
        var config = $parse(attrs.config)(scope);
        Highcharts.stockChart(element[0], config);

        scope.$watch(, function(newVal) {
          if (newVal) {
            console.log("here" + JSON.stringify(newVal))
            $timeout(function() {
              Highcharts.stockChart(element[0], config);
            }, 0);

Could anyone help?

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.