Commits

Anonymous committed 51783eb

add data-colors attr to chart widget

Comments (0)

Files changed (1)

htraf/jquery.htraf.js

             xVertical: isTrue(this.element.attr('data-x-vertical')),
             yInt: isTrue(this.element.attr('data-yint'))
         };
+        // if colors attr was specified include it other wise don't
+        if ( this.element.attr('data-colors') != undefined )
+        {
+            attrs.seriesColors = eval(this.element.attr('data-colors'));
+            this.assert((attrs.seriesColors instanceof Array),
+                    "Unsupported chart color specification. \n\ndata-colors must be of form: \n"
+                    + "['red','green','blue']");
+        }
         this.assert($.inArray(attrs.type, this.supportedType) != -1,
                     "Unsupported chart type. \n\nPossible values: \n"
-                    + this.supportedLegend.join(','));
+                    + this.supportedType.join(','));
         this.assert($.inArray(attrs.legend, this.supportedLegend) != -1,
                     "Unsupported legend option. \n\nPossible values: \n"
                     + this.supportedLegend.join(','));             
                 $.each(data.data, function(i, row) {
                     ticks.push(row[0]); 
                 });
+                if ( attrs.seriesColors != undefined )
+                    $.extend(config, { seriesColors: attrs.seriesColors } );
                 return $.extend(config, {
                     seriesDefaults: {
                         renderer: $.jqplot.BarRenderer,