3

我正在使用这个 jquery 插件来显示一个迷你图,http: //www.omnipotent.net/jquery.sparkline 。

工作完美,除非行值上有负值,它只显示“-,299”而不是“-299”,我试图追踪所有逗号仍然附加的内容,即使该值仅以数百为单位。

这是小提琴http://jsfiddle.net/alfdc/u8pyg/

HTML:

<div class="sparkslim" linevalues="69,1198,1076,545,447,-182,195,0,276,199,-312,187,713,508,2088,28947,33595,34587,19261,58,202,277,194,974"></div>

JS:

$(".sparkslim").sparkline('html', {type: 'line', tagValuesAttribute: 'linevalues', 
width: "135",
    height: "25",
    lineColor: "#adadad",
    fillColor: "rgba(244, 252, 225, 0.0)",
    lineWidth: 2,
    spotColor: "#909090",
    minSpotColor: "#909090",
    maxSpotColor: "#909090",
    highlightSpotColor: "#666",
    highlightLineColor: "#666",
    spotRadius: 0,
    chartRangeMin: 0,
    tooltipFormat: '{{offset:offset}} : {{y:val}}',
});  
4

1 回答 1

3

内部函数编号 formatNumber 有错误。我通过设置自定义 numberFormatter 来解决它。它应该如下所示:

$(".sparkslim").sparkline('html', {
     ...
     numberFormatter: function(x) { return x; },
     ...
});

这是示例:http: //jsfiddle.net/u8pyg/1/

于 2015-04-15T07:41:03.917 回答