Anonymous avatar Anonymous committed d566783

fixed bug with test for bar renderer in point labels.

Comments (0)

Files changed (3)

examples/pointLabels.html

         axes:{yaxis:{pad: 1.3}}
       }
     );
+    
     pop1980 = [7071, 2968, 3005, 1595, 789];
     pop1990 = [7322, 3485, 2783, 1630, 983];
     pop2000 = [8008, 3694, 2896, 1974, 1322];
            show: true
        },
        seriesDefaults: {
-           renderer: $.jqplot.BarRenderer
+           renderer: $.jqplot.BarRenderer,
+           pointLabels: {
+               location: 's'
+           }
        },
        series: [
           {label: '1980'},

examples/pointLabels2.html

+<!DOCTYPE html>
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Simple Test</title>
+  <!--[if IE]><script language="javascript" type="text/javascript" src="../src/excanvas.js"></script><![endif]-->
+  
+  <link rel="stylesheet" type="text/css" href="../src/jquery.jqplot.css" />
+  <link rel="stylesheet" type="text/css" href="examples.css" />
+  
+  <!-- BEGIN: load jquery -->
+  <script language="javascript" type="text/javascript" src="../src/jquery-1.4.2.min.js"></script>
+  <!-- END: load jquery -->
+  
+  <!-- BEGIN: load jqplot -->
+  <script language="javascript" type="text/javascript" src="../src/jquery.jqplot.js"></script>
+  <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.pointLabels.js"></script>
+  <!-- END: load jqplot -->
+
+
+<script language="javascript" type="text/javascript">
+$(document).ready(function(){
+      $.jqplot.config.enablePlugins = true;
+
+   s1 = [[0, 300, '<img height="30px" width="30px" src="../images/new.png"/>'], [1, 150, '<img height="30px" width="30px" src="../images/new.png"/>'], [2, 35, '<img height="30px" width="30px" src="../images/new.png"/>']];
+
+   plot1 = $.jqplot('chart1',[s1],{
+       title: 'Simple Test',
+       legend: {show: true},
+       seriesDefaults: {
+           pointLabels: {
+              show: true,
+              escapeHTML: false,
+              ypadding: -15 
+           }
+       }
+   });
+   
+ });
+</script>
+  </head>
+  <body>
+<?php include "nav.inc"; ?>
+<div id="chart1" class="plot" style="width:500px;height:300px;"></div>
+  </body>
+</html>

src/plugins/jqplot.pointLabels.js

     $.jqplot.PointLabels.prototype.setLabels = function() {   
         var p = this.plugins.pointLabels; 
         var labelIdx;
-        if (p.seriesLabelIndex) {
+        if (p.seriesLabelIndex != null) {
             labelIdx = p.seriesLabelIndex;
         }
-        else if (this.renderer.constuctor = $.jqplot.BarRenderer) {
-            if (this.barDirection == "vertical") {
-                labelIdx = this._plotData[0].length - 1;
-            }
-            else {
-                labelIdx = 0;
-            }
+        else if (this.renderer.constuctor == $.jqplot.BarRenderer && this.barDirection == 'horizontal') {
+            labelIdx = 0;
+        }
+        else {
+            labelIdx = this._plotData[0].length -1;
         }
         p._labels = [];
         if (p.labels.length == 0 || p.labelsFromSeries) {    
                     label = '';
                 }
                 
-                label = p.formatter(p.formatString, label);
-                
+                if (label != null) label = p.formatter(p.formatString, label);
                 var elem = $('<div class="jqplot-point-label jqplot-series-'+this.index+' jqplot-point-'+i+'" style="position:absolute"></div>');
                 elem.insertAfter(sctx.canvas);
                 p._elems.push(elem);
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.