Question

I'm trying to do chart with jqplot. Problem is that it don't create bars with results(only empty area with title and numbers on left axis). I don't know what seems to be the problem, i included needed scripts, code works when i'm trying it on jsfiddle. I don't have any errors. My included scripts and sheets:

<link href="default.css" rel="stylesheet" type="text/css" />
  <script type='text/javascript' src='scripts/script.js'></script>
 <script type='text/javascript' src='scripts/jquery-1.10.2.min.js'></script>
  <script type='text/javascript' src='scripts/jquery-1.9.2.ui.min.js'></script>
   <link rel='stylesheet' type='text/css' href='jquery-ui-1.10.3.custom.min.css'>
 <script type='text/javascript' src='scripts/script-jquery.js'></script>


  <script type='text/javascript' src='scripts/jquery.jqplot.min.js'></script>
<link rel='stylesheet' type='text/css' href='jquery.jqplot.min.css' >

Code:

var line1 = [['Nissan', 4],['Porche', 6],['Acura', 2],['Aston Martin', 5],['Rolls Royce', 6]];

    $('#chart1').jqplot([line1], {
        title:'Default Bar Chartasd',
        seriesDefaults:{
            renderer:$.jqplot.BarRenderer
        },
        axes:{
            xaxis:{
                renderer: $.jqplot.CategoryAxisRenderer
            }
        }
    });
Was it helpful?

Solution

The BarRenderer and CategoryAxisRenderer come in their own script files and are not included in the main jqplot file. You will need to either bundle those in your script file or include separate script tag references to them, e.g.:

<script type="text/javascript" language="javascript" src="plugins/jqplot.categoryAxisRenderer.js"></script>
<script type="text/javascript" language="javascript" src="plugins/jqplot.barRenderer.js"></script>

Probably it worked on jsfiddle because the sample you used had those files referenced as external resources.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top