anon346
anon346

Reputation: 1

Grunt build js error

Since i included the for loop i get this error: Warning: Uglification failed. Unexpected token: punc (.).

This is the js code that im trying to build:

chart: {
      type: 'column',
      events: {
          load: function () {
            for (i = 0; i <= captionLabel.length; i++) {
            var label = this.renderer.label(captionLabel[i]);
          }
              .css({
                  width: '400px',
                  fontSize: '9px'
              })
              .attr({
                  'r': 2,
                  'padding': 5
              })
              .add();

              label.align(Highcharts.extend(label.getBBox(), {
                  align: 'center',
                  x: 20, // offset
                  verticalAlign: 'bottom',
                  y: 0 // offset
              }), null, 'spacingBox');

          }
      },
      marginBottom: 120
  },

Any idea why i get this error when i try to build this file?


Upvotes: 0

Views: 42

Answers (1)

Priyesh Kumar
Priyesh Kumar

Reputation: 2857

You have .(dot) right after closing }, which throws error. Try following code

chart: {
        type: 'column',
        events: {
            load: function () {
                for (i = 0; i <= captionLabel.length; i++) {
                    var label = this.renderer.label(captionLabel[i]);
                    label.css({
                        width: '400px',
                        fontSize: '9px'
                    })
                        .attr({
                            'r': 2,
                            'padding': 5
                        })
                        .add();

                    label.align(Highcharts.extend(label.getBBox(), {
                        align: 'center',
                        x: 20, // offset
                        verticalAlign: 'bottom',
                        y: 0 // offset
                    }), null, 'spacingBox');

                }

            }
        },
        marginBottom: 120
    }

Upvotes: 1

Related Questions