0
        // BAR CHART
        if (sparklineType == 'bar') {

                barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0',
                sparklineHeight = $this.data('sparkline-height') || '26px',
                sparklineBarWidth = $this.data('sparkline-barwidth') || 5,
                sparklineBarSpacing = $this.data('sparkline-barspacing') || 2,
                sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329',
                sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];

            $this.sparkline('html', {
                barColor : barColor,
                type : sparklineType,
                height : sparklineHeight,
                barWidth : sparklineBarWidth,
                barSpacing : sparklineBarSpacing,
                stackedBarColor : sparklineStackedColor,
                negBarColor : sparklineNegBarColor,
                zeroAxis : 'false'
            });

        }

For this code above in JSHINT, I am getting this following error message:

"Expected an assignment or function call and instead saw an expression"

Can someone please tell me how I can fix this?

Thank you!

  • http://jsfiddle.net/GaurangTandon/u3R8t/ Says your JS is perfectly valid. – Gaurang Tandon Apr 20 '14 at 17:26
  • That error probably exists because of something about this expression _in relation to_ some other code that comes just before it. Can you give us a little more? – rescuecreative Apr 20 '14 at 17:29
  • @rescuecreative absolutely, please see above:) – user3375777 Apr 20 '14 at 17:41
  • My first thought is that it may have to do with the fact that you are separating multiple assignments with commas but there is no `var` keyword at the beginning. Try changing those to semicolons and see if that does it. – rescuecreative Apr 20 '14 at 17:44

2 Answers2

0

The Boolean expression relies on the "falsiness" of null, or undefined, to decide whether to assign $this.data or the array literal. My guess is that jshint wants you to be explicit about assigning a value so you could explicitly check $this.data for null or undefined then assign accordingly.

rom99
  • 709
  • 4
  • 14
0

This wrong (comma)

barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0',
sparklineHeight = $this.data('sparkline-height') || '26px',
sparklineBarWidth = $this.data('sparkline-barwidth') || 5,
sparklineBarSpacing = $this.data('sparkline-barspacing') || 2,
sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329',
sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];

Try this (semicolon - ;)

barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0';
sparklineHeight = $this.data('sparkline-height') || '26px';
sparklineBarWidth = $this.data('sparkline-barwidth') || 5;
sparklineBarSpacing = $this.data('sparkline-barspacing') || 2;
sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329';
sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];
Protomen
  • 9,471
  • 9
  • 57
  • 124