Anonymous avatar Anonymous committed edd2f59

Wroking more on theming. Fixing bugs, making it work.

Comments (0)

Files changed (4)

examples/legendLabels.html

     div.plot {
         margin-bottom: 70px;
     }
-    div.jqplot-table-legend-swatch {
+/*    div.jqplot-table-legend-swatch {
     width: 0px;
     height: 0px;
     border-width: 3px 4px;
     td.jqplot-table-legend > div {
         padding: 1px;
         border: 1px solid #dedede;
-    }
+    }*/
 </style>
 <script language="javascript" type="text/javascript">
 $(document).ready(function(){
            yoffset: 35
 		},
 		axes: {
-		    xaxis:{min:1, max:4, label: 'Weather Pattern'},
+		    xaxis:{min:1, max:4},
 		    yaxis:{min:0, max:35}
 		}
    });

examples/theming.html

         axesStyles: {
            borderWidth: 4,
            ticks: {
-               fontSize: '14pt',
+               fontSize: '12pt',
                fontFamily: '"Times New Roman"'
            } 
-        }
+        },
+        // seriesColors = ['red', 'green', 'blue', 'yellow', 'purple'],
+        series: [
+            {color: 'red'},
+            {color: 'green'},
+            {color: 'blue'},
+            {color: 'yellow'}
+        ]
     };
     
     old = plot2.themeEngine.newTheme('old', temp);

src/jqplot.linearAxisRenderer.js

             // position it and the labels correctly on the plot.
             var dim=0;
             var temp;
-            
+            // Added for theming.
             if (this._elem) {
                 this._elem.empty();
             }

src/jqplot.themeEngine.js

             a.borderColor = ax.borderColor;
             a.borderWidth = ax.borderWidth;
             if (ax._ticks && ax._ticks[0]) {
-                if (ax._ticks[0].constructor == $.jqplot.AxisTickRenderer) {
+                if (ax._ticks[0].constructor == $.jqplot.AxisTickRenderer || true) {
                     for (nn in a.ticks) {
                         if (ax._ticks[0].hasOwnProperty(nn)) {
                             a.ticks[nn] = ax._ticks[0][nn];
                                 val = thax.ticks[nn]
                             }
                             if (val != null) {
-                                if (axis.tickRenderer == $.jqplot.CanvasAxisTickRenderer) {
+                                if (axis.tickRenderer == $.jqplot.CanvasAxisTickRenderer || true) {
                                     axis.tickOptions[nn] = val;
                                     axis._ticks = [];
                                     redrawPlot = true;
                     }
                 }
             }
+            
+            // if (redrawPlot) {
+            //     plot.target.empty();
+            //     plot.draw();
+            // }
+            
             var i;
             for (i=0; i<th.series.length; i++) {
+                var opts = {};
+                var redrawSeries = false;
                 for (n in th.series[i]) {
                     val = (th.seriesStyles[n] != null) ? th.seriesStyles[n] : th.series[i][n];
                     if (val != null) {
-                        plot.series[i][n] = val;
+                        opts[n] = val;
+                        if (n == 'color') {
+                            plot.series[i].renderer.shapeRenderer.fillStyle = val;
+                            plot.series[i].renderer.shapeRenderer.strokeStyle = val;
+                            plot.series[i][n] = val;
+                        }
+                        else if (n == 'lineWidth') {
+                            plot.series[i].renderer.shapeRenderer.lineWidth = val;
+                            plot.series[i][n] = val;
+                        }
+                        else if (n == 'markerOptions') {
+                            merge (plot.series[i].markerOptions, val);
+                            merge (plot.series[i].markerRenderer, val);
+                        }
+                        else {
+                            plot.series[i][n] = val;
+                        }
+                        redrawPlot = true;
+                        // redrawSeries = true;
                     }
                 }
-                if (!redrawPlot) {
-                    plot.drawSeries(th.series[i], i);
-                }
+                // if (redrawSeries) {
+                //     console.log('redrawing series ', i)
+                //     plot.drawSeries(opts, i);
+                // }
             }
             
             if (redrawPlot) {
         return th;
     };
     
-    // function clone(obj){
-    //     if(obj == null || typeof(obj) != 'object'){
-    //         return obj;
-    //     }
-    // 
-    //     var temp = new obj.constructor(); // changed (twice)
-    //     for(var key in obj){
-    //         temp[key] = clone(obj[key]);
-    //     }   
-    //     return temp;
-    // }
-    
     function clone(obj) {
         return eval(obj.toSource());
     }
         }
     }
     
-    $.jqplot.merge = merge;
-    
     $.jqplot.ThemeEngine.prototype.rename = function (oldName, newName) {
         if (this.themes.hasOwnProperty(newName)) {
             throw new Error ("jqplot.ThemeEngine Error: New name already in use.");
             this._name = obj;
         }
         else if(typeof(obj) == 'object') {
-            $.jqplot.merge(this, obj);
+            merge(this, obj);
         }
     };
     
         this.whiteSpace = null;
         this.fontSize = null;
         this.fontFamily = null;
-        this.fontWeight = null;
     }
     
     var AxisLabel = function() {
     
     var BarSeriesProperties = function() {
         this.color=null;
+        this.seriesColors=null;
         this.lineWidth=null;
         this.shadow=null;
         this.barPadding=null;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.