[英]jqplot pointLabels how to format number up to 2 decimal
I am using jqplot for showing graph. 我正在使用jqplot显示图形。
following is the code : 以下是代码:
tempArr1 = [9189.539999999999, 10170.039999999999, 980.5]
plot2 = $.jqplot('bar_chart_id1', [tempArr1], {
title:{
text: chatTitle2,
textColor: '#B66B09'
},
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {
// Set the varyBarColor option to true to use different colors for each bar.
varyBarColor: true,
barPadding: 2,
barMargin: 3,
barWidth: 30,
},
pointLabels: {show: true},
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: lblArray,
label:'Manufacturer',
},
yaxis:{
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
min: 0,
tickInterval:1000,
label:'Amount',
tickOptions: {formatString: '$%#.2f'}
}
},
highlighter: { show: true },
});
As you can see the point label is showing many decimal points (9189.539999999999). 如您所见,点标签显示许多小数点(9189.539999999999)。 I need to show the label as '$91890.54'. 我需要将标签显示为“ $ 91890.54”。 I have tried the formatString option in pointLabels as '$%#.2' buts its not working. 我已经尝试在pointLabels中将formatString选项设置为'$%#。2',但是它不起作用。
Any help is greatly appreciated. 任何帮助是极大的赞赏。 Thank you. 谢谢。
tempArr1 = [9189.539999999999, 10170.039999999999, 980.5];
tempArr1 = tempArr1.map(i => { return parseFloat(i.toFixed(2)); });
pointLabels: { show: true, location: 'n', lables: tempArr1 , formatString: "$%#.2f" },
应该满足您的确切需求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.