Search code examples
javascriptjqplot

JQPLOT bar graph range


I have created a dynamic bar graph using jqplot, the problem is that some values are quite big i.e. 10000000 and others are pretty small i.e. 2000 or 10000. Because of this range issue, i am only able to see the bigger valued graphs while the rest dont even appear up or appear as just a line on the axis.

Could someone please let me know how this range issue could be solved?


Solution

  • Following my comment, and your need to achieve a solution which includes jqplot bar chart, i'll suggest illustrating the massive difference of values by adding a second line graph to the plot.

    $(document).ready(function(){ 
    var data = [10000000, 5000000,10000,2000];
    var options= {    
       title: 'Bar and Line Chart',      
       series:[{
          renderer: $.jqplot.BarRenderer,                 
          rendererOptions: {          
             barMargin: 5,           
             fillToZero: true               
          },
          pointLabels: {
             show: true,
             seriesLabelIndex:1,
             hideZeros:false
          }
       }],
       axes: {      
          xaxis: {          
             tickRenderer: $.jqplot.CanvasAxisTickRenderer,
             renderer: $.jqplot.CategoryAxisRenderer,
          },      
          yaxis: {   
             labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
             padMin: 0,
             pad: 1.1,
             label: ' logarithmic scale',
             rendererOptions: { forceTickAt0: true}
          } 
       },               
    };  
    $.jqplot('graph', [data,data], options );
    });
    

    Here is a working solution in jsfiddle