Commits

cleonello  committed 101da1c

Added option to encode html special characters in table legends.
Added axis label test to test/example navigation.
Fixed empty script tag in example includes.

  • Participants
  • Parent commits 74839e1

Comments (0)

Files changed (6)

File src/jqplot.core.js

         // prop: predraw
         // Wether to draw the legend before the series or not.
         this.preDraw = false;
+        this.escapeHtml = false;
         this._series = [];
     }
     

File src/jqplot.tableLegendRenderer.js

                 '<div style="border:1px solid #cccccc;padding:0.2em;">'+
                 '<div style="width:1.2em;height:0.7em;background-color:'+color+';"></div>'+
                 '</div></td>').appendTo(tr);
-            $('<td class="jqplot-legend" style="vertical-align:middle;padding-top:'+rs+';">'+label+'</td>').appendTo(tr);
+            var elem = $('<td class="jqplot-legend" style="vertical-align:middle;padding-top:'+rs+';"></td>');
+            elem.appendTo(tr);
+            if (this.escapeHtml) {
+                elem.text(label);
+            }
+            else {
+                elem.html(label);
+            }
         }
         return this._elem;
     };

File src/plugins/jqplot.pieRenderer.js

                 '<div style="border:1px solid #cccccc;padding:0.2em;">'+
                 '<div style="width:1.2em;height:0.7em;background-color:'+color+';"></div>'+
                 '</div></td>').appendTo(tr);
-            $('<td class="jqplot-legend" style="vertical-align:middle;padding-top:'+rs+';">'+label+'</td>').appendTo(tr);
+            var elem = $('<td class="jqplot-legend" style="vertical-align:middle;padding-top:'+rs+';"></td>');
+            elem.appendTo(tr);
+            if (this.escapeHtml) {
+                elem.text(label);
+            }
+            else {
+                elem.html(label);
+            }
         }
         return this._elem;
     };
   $(document).ready(function(){
 
 
-line1 = [['frogs', 3], ['buzzards', 7], ['deer', 2.5], ['turkeys', 6], ['moles', 5], ['ground hogs', 4]];
+line1 = [['<frogs> & lizards', 3], ['buzzards & gizzards', 7], ['deer & beef', 2.5], ['turkeys & vulures', 6], ['moles & voles', 5], ['ground hogs & beets', 4]];
 line2 = [3, 7, 2.5, 6, 5, 4];
 
 plot1 = $.jqplot('chart1', [line1], {
 plot2 = $.jqplot('chart2', [line1], {
   title: 'Pie Chart with Legend and sliceMargin',
   seriesDefaults:{renderer:$.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}}, 
-  legend:{show:true}
+  legend:{show:true, escapeHtml:true}
 });
 
 plot3 = $.jqplot('chart3', [line1], {

File tests/index.html

             <table class="suites">
               <tr class="description"><td><a href="coretests.php">Core plotting functionality.</a></td></tr>
               <tr class="description"><td><a href="axisAutoscaleTests.php">Axis Auto Scaling Options.</a></td></tr>
+              <tr class="description"><td><a href="axisLabelTests.php">Axis Labels.</a></td></tr>
               <tr class="description"><td><a href="pieTests.php">Pie Charts</a></td></tr>
               <tr class="description"><td><a href="multipleYAxesTests.php">Multiple Y Axes</a></td></tr>
               <tr class="description"><td><a href="logAxisTests.php">Log Axes</a></td></tr>

File tests/opener.php

   </script>
   
 <?php
-  $pages = array('coretests.php', 'axisAutoscaleTests.php', 'pieTests.php', 'multipleYAxesTests.php', 'logAxisTests.php', 'dateAxisTests.php', 'highlighterTests.php', 'OHLCTests.php', 'zoomTests.php', 'categoryAxisTests.php', 'barRendererTests.php', 'dragableTests.php', 'stackedTests.php', 'pointLabelTests.php', 'canvasAxisTests.php');
+  $pages = array('coretests.php', 'axisAutoscaleTests.php', 'axisLabelTests.php', 'pieTests.php', 'multipleYAxesTests.php', 'logAxisTests.php', 'dateAxisTests.php', 'highlighterTests.php', 'OHLCTests.php', 'zoomTests.php', 'categoryAxisTests.php', 'barRendererTests.php', 'dragableTests.php', 'stackedTests.php', 'pointLabelTests.php', 'canvasAxisTests.php');
         
   $len = count($pages);
   $parts = explode("/", $_SERVER["REQUEST_URI"]);
   <?php
     if (count($jqplot_js_includes)==1) {
       echo '<p class="description">The plot(s) on this page use the following plugin:</p>';
-      echo '<pre class="prettyprint">&lt;script type="text/javascript" src="'.$jqplot_js_includes[0].'" /&gt;</pre>';
+      echo '<pre class="prettyprint">&lt;script type="text/javascript" src="'.$jqplot_js_includes[0].'"&gt;&lt;/script&gt;</pre>';
     }
     else if (count($jqplot_js_includes)>1) {
       echo '<p class="description">The plot(s) on this page use the following plugins:</p><pre class="prettyprint">';
       foreach ($jqplot_js_includes as $ji) {
-        echo '&lt;script type="text/javascript" src="'.$ji.'" /&gt;';
+        echo '&lt;script type="text/javascript" src="'.$ji.'"&gt;&lt;/script&gt;';
         echo '<br />';
       }
       echo '</pre>';