2

Pretty simple stuff here:

   var dataHits = [['2011-10-16',1],['2011-11-05',7],['2011-11-06',1],['2011-11-09',2],['2011-11-12',5]];
   var plot1 = $.jqplot('chartHits', [dataHits], {
      title:'Zobrazenia profilu spolu',
      seriesDefaults:{
                renderer:$.jqplot.BarRenderer,
                rendererOptions: {            
            barPadding: 0,      // number of pixels between adjacent bars in the same
                                // group (same category or bin).
            barMargin: 0,      // number of pixels between adjacent groups of bars.
            barDirection: 'vertical', // vertical or horizontal.
            barWidth: 10

        }                
            },
      axes:{
        xaxis:{                    
          renderer:$.jqplot.DateAxisRenderer,
          min: '2011-10-15',
          max: '2011-11-13',
          tickInterval: "2 day",
          tickOptions:{
            formatString:'%d.%m'
          }          
        },
        yaxis:
        {
          min: 0,
          tickInterval: 1
        }        
      },
      highlighter: {
        show: true,
        sizeAdjust: 7.5
      },
      cursor: {
        show: false
      }
   });

But generated graph is wrong - first value is drawn OK - on 16.10.2011, but all other values (bars) are positioned incorrectly - one day sooner than they should be (even their "tooltip" when highlighted is OK, they are just in wrong place on x-axis). Any idea how to fix this?

See picture : enter image description here

Boro
  • 7,913
  • 4
  • 43
  • 85
rouen
  • 5,003
  • 2
  • 25
  • 48
  • What browser reproduces the problem? I tried it here: http://jsfiddle.net/larsenmtl/wN2SA/ (in firefox) and it works correctly. – Mark Nov 19 '11 at 17:13
  • really? screenshot is also from firefox, version 7 – rouen Nov 19 '11 at 22:01
  • Mine was firefox 3.6, wow, might be time for an upgrade... – Mark Nov 19 '11 at 23:22
  • Just tried in firefox 8, same result as 3.6. Pain in the arse that you can not link jqplot from jqplot.com, I had to cache each js file in my browser to get it to work with jsfiddle. – Mark Nov 19 '11 at 23:41

1 Answers1

1

I think that in general, when dealing with barcharts you should always use ticks to have a nicer plot. Also for your problem you obtain interesting results when using this approach, please see here. Here you would need to remember that if you care on showing nothing for the days that are not specified in the dataHits you would need to provide them as well just giving them value of 0.

Interesting results you obtain (hope this is what you want) when you use both ticks and dateAxisRenderer capabilities. This I show in the following sample. Here the gaps, showing time distance between the readings, are preserved and all values are correctly painted. Also important to notice the min, max and tickInterval have no effect since we use ticks.

BTW: If you still want to have some gaps around the chart you could apply the approach presented in EDIT of this answer.

Community
  • 1
  • 1
Boro
  • 7,913
  • 4
  • 43
  • 85
  • "A mere 4Y later" the links in the JS fiddle are broken – Owen Beresford Nov 09 '16 at 14:41
  • This happens when you build on top of assumptions that an URI will be available and as it happens the https://bitbucket.org/cleonello/ is not available anymore and the scripts were coming from there. I updated those. Please have fun. – Boro Nov 10 '16 at 13:01
  • @OwenBeresford if you come across anything else not updated please do let me know. – Boro Nov 10 '16 at 13:32