javascript - How to plot decimal values in JQPlot Bar graphs? -


i using jqplots generate bar graphs . able generate exact graphs whole numbers. not able generate graph values having decimal points. below code have used :

<script type="text/javascript"> $(document).ready(function(){  $.jqplot.config.enableplugins = true;   var s1 = ['1.5','3.0', '0.0', '0.0', '0.0', '3.0', '0.0'];   var ticks = ['new mould', 'raw material', 'color/size', 'imported/catalogue' , 'printing' , 'plating' , 'other'];    plot1 = $.jqplot('chart1', [s1], {     // animate if we're not using excanvas (not in ie 7 or ie 8)..            animate: !$.jqplot.use_excanvas,      seriesdefaults:{         renderer:$.jqplot.barrenderer,          pointlabels: { show: true }           },      axes: {         xaxis: {      renderer: $.jqplot.categoryaxisrenderer,      ticks: ticks               }, yaxis: { tickoptions: { formatstring: '%.2f' } } },  highlighter: { show: false }  });            $('#chart1').bind('jqplotdataclick',function (ev, seriesindex, pointindex, data) {                $('#info1').html('series: '+seriesindex+', point: '+pointindex+', data: '+data);           }        );     });   </script> 

i getting erroe follows:

this[r]._ticks[0] undefined http://blrsrigwd11074.itcinfotech.com:81/windchill/netmarkets/javascript/report/plugins/jqplot.pointlabels.min.js line 57

please me out on issue.

i spot error looking @ code on first go. wasn't sure, if actual cause error.

you using data array var s1 = ['1.5', '3.0', '0.0', '0.0', '0.0', '3.0', '0.0']; jqplot trying read values data-array, , expects integer or decimal value(s).

in case, passing string values in array. need remove single quotes('') values.

the array should this, var s1 = [1.5, 3.0, 0.0, 0.0, 0.0, 3.0, 0.0]; //remove quotes

to confirm this, ran code thru jsfiddle. here's link jsfiddle code

try both arrays in fiddle, values quotes(var s1 = ['1.5', '3.0', '0.0', '0.0', '0.0', '3.0', '0.0'];) , without quotes(var s1 = [1.5, 3.0, 0.0, 0.0, 0.0, 3.0, 0.0]). 1 single quotes won't plot bar-chart.

hope helps.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -