jqplot柱状图无法显示我的浮点数。如何修复?

3
我正在尝试使用jqplot生成条形图。我的所有值都是浮点数,如下所示:
var s1 = [17.1, 18.2];
var s2 = [50.2, 53];
var s3 = [93.9, 93];
var s4 = [34.1, 34];

但是它将它们舍入为整数。

这里是一个可工作的示例:http://jsfiddle.net/JkBKs/

我该如何修复这个问题?


1
y轴: { 刻度选项: { 格式字符串:'%.2f' } }像上面这样添加一个y轴格式化就解决了它。 - ispirto
2个回答

10

试试这个,它有效。

        axes:
        {
            xaxis:{
                renderer: $.jqplot.CategoryAxisRenderer,
                ticks: ticks
            },
            yaxis: {
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
                    min: 0 ,
                    tickOptions: {
                                  formatString: '%.1f'
                                } 

                   }
        },

1
请查看“formatString”内容。
seriesDefaults: {
                renderer:$.jqplot.BarRenderer,
                // Show point labels to the right ('e'ast) of each bar.
                // edgeTolerance of -15 allows labels flow outside the grid
                // up to 15 pixels.  If they flow out more than that, they
                // will be hidden.
                pointLabels: { show: true, location: 'e', edgeTolerance: -15, formatString: '%.1f' },
                // Rotate the bar shadow as if bar is lit from top right.
                shadowAngle: 135,
                // Here's where we tell the chart it is oriented horizontally.
                rendererOptions: {
                    barDirection: 'horizontal'
                }
            },
            axes: {
                yaxis: {
                    renderer: $.jqplot.CategoryAxisRenderer
                }
            }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接