dude
dude

Reputation: 4982

jqplot not able to display the chart properly

jQuery(document).ready(function() {
     var firstv=10;
            var secondv=20;
            var thirdv=70;
            var name1=ram;
            var name2=kumar;
            var name3=manju;
      var data = [ [name1, firstv],[name2, secondv], [name3, thirdv]];

var plot1 = jQuery.jqplot('chart', [data],
        {
            grid: {
                shadow: false,
                background: '#FFFFFF',                                                                                          
            },
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    showDataLabels: true,
                    padding: 20,
                    startAngle: 270
                }
            },
            legend: {
                show: true,
                location: 'e',
                fontSize: 11,
                marginTop: 10,                                
            }
        });
});

working code link

if i assign values to var , it is not fetching it?

Upvotes: 0

Views: 294

Answers (2)

wirey00
wirey00

Reputation: 33661

Do you mean to store a string instead?

var secondv=20;
var thirdv=70;
var name1=ram; //  var name1='ram';
var name2=kumar; // var name2='kumar';
var name3=manju; // var name3='manju';

If not where are you getting those variables from?

and if you are just using those values once. You can directly assign them in data

var data = [
    ["ram", 10], 
    ["kumar", 20],
    ["manju", 70]
];​

Upvotes: 2

j0nes
j0nes

Reputation: 8109

Check the error console:

Uncaught ReferenceError: ram is not defined 

Change your assignment of names to quoted names:

var name1="ram";
var name2="kumar";
var name3="manju";

Here is the updated example.

Upvotes: 1

Related Questions