<commit_before>module = angular.module('maestrano.impac.widgets.common.chart',['maestrano.assets'])

#============================================
# Component
#============================================

module.directive('widgetCommonChart', ['TemplatePath','$compile','$timeout', (TemplatePath,$compile,$timeout) ->
  return {
      restrict: 'A',
      scope: {
        data: '='
      },
      template: '<canvas id="myChart"></canvas>',
      link: (scope,elem,attr) ->
        options = {
          bezierCurve: true,
          pointDotRadius : 3,
          responsive: true,
          scaleShowLabels : true,
          scaleShowLabelBackdrop : true,
          scaleBeginAtZero: true,
          scaleShowGridLines: true,
        }

        myChart = null
        scope.draw = ->
          if !_.isEmpty(scope.data.options)
            angular.extend(options,scope.data.options)

          if myChart != null then myChart.destroy()
          canvas = elem.children().get(0)
          ctx = canvas.getContext("2d")
          switch scope.data.chartType
            when 'Doughnut' then myChart = new Chart(ctx).Doughnut(scope.data.data,options)
            when 'Bar' then myChart = new Chart(ctx).Bar(scope.data.data,options)
            when 'Line' then myChart = new Chart(ctx).Line(scope.data.data,options)
            when 'Pie' then myChart = new Chart(ctx).Pie(scope.data.data,options)
          newWidth = angular.element(canvas).parent().width()

        # Redraw the chart when data changes
        scope.$watch((-> scope.data)
          ,(value) ->
            if value?
              scope.draw()
              $timeout((-> scope.draw()),100)
        ,true)
    }
])
<commit_msg>fixed chartjs redraw<commit_after>module = angular.module('maestrano.impac.widgets.common.chart',['maestrano.assets'])

#============================================
# Component
#============================================

module.directive('widgetCommonChart', ['TemplatePath','$compile','$timeout', (TemplatePath,$compile,$timeout) ->
  return {
      restrict: 'A',
      scope: {
        data: '='
      },
      template: '<canvas id="myChart"></canvas>',
      link: (scope,elem,attr) ->
        options = {
          bezierCurve: true,
          pointDotRadius : 3,
          responsive: true,
          scaleShowLabels : true,
          scaleShowLabelBackdrop : true,
          scaleBeginAtZero: true,
          scaleShowGridLines: true,
        }

        myChart = null
        scope.draw = ->
          if !_.isEmpty(scope.data.options)
            angular.extend(options,scope.data.options)

          if myChart != null then myChart.destroy()
          canvas = elem.children().get(0)
          ctx = canvas.getContext("2d")
          switch scope.data.chartType
            when 'Doughnut' then myChart = new Chart(ctx).Doughnut(scope.data.data,options)
            when 'Bar' then myChart = new Chart(ctx).Bar(scope.data.data,options)
            when 'Line' then myChart = new Chart(ctx).Line(scope.data.data,options)
            when 'Pie' then myChart = new Chart(ctx).Pie(scope.data.data,options)
          newWidth = angular.element(canvas).parent().width()

        # Redraw the chart when data changes
        scope.$watch((-> scope.data)
          ,(value) ->
            if value?
              $timeout((-> scope.draw()),100)
        ,true)
    }
])

{'fraction_non_alphanumeric': 0.18238434163701067, 'fraction_numerical': 0.0035587188612099642, 'mean_word_length': 2.342913776015857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '381427', 'n_tokens_mistral': 939, 'n_tokens_neox': 924, 'n_words': 179}