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/

我怎样才能解决这个问题?

4

2 回答 2

10

试试这个,它有效

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

                   }
        },
于 2012-12-28T05:52:21.453 回答
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
                }
            }
于 2014-07-04T02:31:57.353 回答