Commits

Chris Leonello committed d1736ef

Fix to properly place legend when outside grid to south. Update example.

Comments (0)

Files changed (2)

examples/kcp_area2.php

 <?php 
-    $title = "Area Chart";
+    $title = "Area Chart 2";
     // $plotTargets = array (array('id'=>'chart1', 'width'=>600, 'height'=>400));
 ?>
-<?php include "openerNoHeader.php"; ?>
+<?php include "opener.php"; ?>
 
 <!-- Example scripts go here -->
 
     }
 
     table.jqplot-table-legend {
-        font-size: 0.65em;
-        line-height: 1em;
-        margin: 0px 0px 10px 15px;
+        border: 0px;
     }
 
     td.jqplot-table-legend-label {
-      width: 20em;
+      padding: 0.25em;
+    }
+
+    td.jqplot-table-legend-label + td.jqplot-table-legend-swatch {
+        padding-left: 1.5em;
     }
 
     div.jqplot-table-legend-swatch {
-        border-width: 2px 6px;
+        border-width: 4px 6px;
     }
 
     div.jqplot-table-legend-swatch-outline {
         plot1 = $.jqplot('chart1', [data.rural, data.urban], {
             title: 'Contribution of Urban and Rural Population to National Percentiles (edited data)',
             stackSeries: true,
+            seriesColors: ['#77933C', '#B9CDE5'],
             seriesDefaults: {
                 showMarker: false,
                 fill: true,
                     pad: 0,
                     min: 1,
                     max: 100,
+                    label: 'Population Percentile',
+                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                     tickInterval: 3,
                     tickOptions: {
                         showGridline: false
                 yaxis: {
                     min: 0,
                     max: 1,
+                    label: 'Percentage of Population',
+                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                     tickOptions: {
                       formatter: $.jqplot.PercentTickFormatter,
                       showGridline: false,
 <!-- Additional plugins go here -->
 
   <script class="include" type="text/javascript" src="../src/plugins/jqplot.enhancedLegendRenderer.js"></script>
+  <script class="include" type="text/javascript" src="../src/plugins/jqplot.canvasTextRenderer.js"></script>
+  <script class="include" type="text/javascript" src="../src/plugins/jqplot.canvasAxisLabelRenderer.js"></script>
   <script class="include" type="text/javascript" src="jquery-ui/js/jquery-ui.min.js"></script>
 
 <!-- End additional plugins -->

src/jqplot.core.js

                     }
                 }
                 
-                var legendPadding = (this.legend.placement == 'outsideGrid') ? {top:this.title.getHeight(), left: 0, right: 0, bottom: 0} : this._gridPadding;
-            
+                var legendPadding = this._gridPadding;
+                
+                if (this.legend.placement === 'outsideGrid') {
+                    legendPadding = {top:this.title.getHeight(), left: 0, right: 0, bottom: 0};
+                    if (this.legend.location === 's') {
+                        legendPadding.left = this._gridPadding.left;
+                        legendPadding.right = this._gridPadding.right;
+                    }
+                }
+                
                 ax.xaxis.pack({position:'absolute', bottom:this._gridPadding.bottom - ax.xaxis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right});
                 ax.yaxis.pack({position:'absolute', top:0, left:this._gridPadding.left - ax.yaxis.getWidth(), height:this._height}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top});
                 ax.x2axis.pack({position:'absolute', top:this._gridPadding.top - ax.x2axis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right});