Issue #767 new

bar plots deviate from the right position

mingke_he
created an issue

the version of the jqplot is V1.0.7. There are two lines i need to plot and one of them is a bar . The question is when I set the first line as the bar line, jqplot works normally, but if I set the second line as the bar line, these bars deviate from the right position(figure).

$(document).ready(function(){

              var line1=[["2012-10-31 00:00:00",6],["2012-11-30 00:00:00",13.7],["2012-12-31 00:00:00",7.7]];
              var line2=[["2012-10-31 00:00:00",5909.6],["2012-11-30 00:00:00",5747.1],["2012-12-31 00:00:00",5765.6]];
              var data=[line1,line2];

              var barWidth=50;
              var plot1 = $.jqplot('chart4', data, {
                series:[

                    {yaxis:'yaxis',
                        label:'line1',
                        renderer:$.jqplot.LineRenderer,
                        // rendererOptions: {
                            // fillToZero: true,
                            // barWidth:0,
                        // },
                    },
                    {yaxis:'y2axis',label:'line2',
                        renderer:$.jqplot.BarRenderer,
                        rendererOptions: {
                            fillToZero: true,
                            barWidth:barWidth,
                        },                   

                    },
                ], 
                axesDefaults: {
                    tickRenderer: $.jqplot.CanvasAxisTickRenderer ,                   
                },
                highlighter: {
                    show: true,
                    sizeAdjust: 7.5
                },
                axes: {
                  xaxis: {
                    renderer:$.jqplot.DateAxisRenderer,                   
                  },

                },
                legend:{
                    show:true,
                }
              });
            });

Comments (1)

  1. Kevan Benson

    I had the same problem, and the quick fix I just figured out seems to work. The problem seems to be that the function that computes the number of bar series and the position of the current series does not limit the position of the current series to the number of bar series. This causes weird offsets when mixing line and bar series together. The following diff fixes it for me (single line change, should be easy):

    --- dist/plugins/jqplot.barRenderer.OLD.js      2013-03-26 19:28:18.000000000 -0700
    +++ dist/plugins/jqplot.barRenderer.js   2013-04-15 10:32:14.976265221 -0700
    @@ -229,7 +229,7 @@
             for (var i=0; i < paxis._series.length; i++) {
                 series = paxis._series[i];
                 if (series === this) {
    -                pos = i;
    +                pos = nseries; // Current series number, 0-based
                 }
                 // is the series rendered as a bar?
                 if (series.renderer.constructor == $.jqplot.BarRenderer) {
    
  2. Log in to comment