Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在JQPlot条形图中绘制十进制值?_Javascript_Jqplot - Fatal编程技术网

Javascript 如何在JQPlot条形图中绘制十进制值?

Javascript 如何在JQPlot条形图中绘制十进制值?,javascript,jqplot,Javascript,Jqplot,我正在使用jqplot生成条形图。我能够生成整数的精确图形。但我无法为具有小数点的值生成图形。以下是我使用的代码: <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 moul

我正在使用jqplot生成条形图。我能够生成整数的精确图形。但我无法为具有小数点的值生成图形。以下是我使用的代码:

<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], {    
// Only 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>

$(文档).ready(函数(){
$.jqplot.config.enablePlugins=true;
变量s1=['1.5'、'3.0'、'0.0'、'0.0'、'0.0'、'3.0'、'0.0'];
var ticks=[‘新模具’、‘原材料’、‘颜色/尺寸’、‘进口/目录’、‘印刷’、‘电镀’、‘其他’];
plot1=$.jqplot('chart1',[s1],{
//只有在我们不使用excanvas(不在IE7或IE8中)时才进行动画制作。。
动画:!$.jqplot.use_excanvas,
序列默认值:{
渲染器:$.jqplot.blunderer,
点标签:{show:true}
},     
轴:{
xaxis:{
渲染器:$.jqplot.CategoryAxisRenderer,
滴答声:滴答声
},
yaxis:{tickOptions:{formatString:'%.2f'}}
},高亮显示:{show:false}
});           
$(“#图表1”).bind('jqplotDataClick',函数(ev、SerieIndex、pointIndex、data)
{               
$('info1').html('series:'+seriesIndex+',point:'+pointIndex+',data:'+data');
}       
);   
}); 
我得到的错误如下:

此[r]。\u记号[0]未定义 第57行


请帮我解决这个问题。

我可以通过查看您的代码来发现错误。 但我不确定这是否是错误的真正原因

您使用的数据数组为
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0']
jqPlot正在尝试从数据数组读取值,它需要一个
整数
十进制

在本例中,您正在数组中传递
String
值。因此,您需要做的就是从值中删除单引号(“”)

数组应该是这样的,
vars1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]//删除引号

为了确认这一点,我通过JSFiddle运行了您的代码。这是链接

尝试小提琴中的两个数组,带引号的值(
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0'];
)和不带引号的值(
var s1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]
)。带单引号的不会绘制条形图


希望有帮助。

我可以通过查看您的代码来发现错误。 但我不确定这是否是错误的真正原因

您使用的数据数组为
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0']
jqPlot正在尝试从数据数组读取值,它需要一个
整数
十进制

在本例中,您正在数组中传递
String
值。因此,您需要做的就是从值中删除单引号(“”)

数组应该是这样的,
vars1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]//删除引号

为了确认这一点,我通过JSFiddle运行了您的代码。这是链接

尝试小提琴中的两个数组,带引号的值(
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0'];
)和不带引号的值(
var s1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]
)。带单引号的不会绘制条形图


希望有帮助。

我可以通过查看您的代码来发现错误。 但我不确定这是否是错误的真正原因

您使用的数据数组为
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0']
jqPlot正在尝试从数据数组读取值,它需要一个
整数
十进制

在本例中,您正在数组中传递
String
值。因此,您需要做的就是从值中删除单引号(“”)

数组应该是这样的,
vars1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]//删除引号

为了确认这一点,我通过JSFiddle运行了您的代码。这是链接

尝试小提琴中的两个数组,带引号的值(
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0'];
)和不带引号的值(
var s1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]
)。带单引号的不会绘制条形图


希望有帮助。

我可以通过查看您的代码来发现错误。 但我不确定这是否是错误的真正原因

您使用的数据数组为
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0']
jqPlot正在尝试从数据数组读取值,它需要一个
整数
十进制

在本例中,您正在数组中传递
String
值。因此,您需要做的就是从值中删除单引号(“”)

数组应该是这样的,
vars1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]//删除引号

为了确认这一点,我通过JSFiddle运行了您的代码。这是链接

尝试小提琴中的两个数组,带引号的值(
var s1=['1.5','3.0','0.0','0.0','0.0','3.0','0.0'];
)和不带引号的值(
var s1=[1.5,3.0,0.0,0.0,0.0,3.0,0.0]
)。带单引号的不会绘制条形图

希望能有帮助