[英]jqplot pointLabels how to format number up to 2 decimal
我正在使用jqplot显示图形。
以下是代码:
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 },
});
如您所见,点标签显示许多小数点(9189.539999999999)。 我需要将标签显示为“ $ 91890.54”。 我已经尝试在pointLabels中将formatString选项设置为'$%#。2',但是它不起作用。
任何帮助是极大的赞赏。 谢谢。
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.