jqplot Bar Charts忽略了我的浮动数字。如何修复它们?

时间:2012-12-26 16:43:04

标签: jqplot

我正在尝试使用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/

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:10)

试试这个,它有效

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

                   }
        },

答案 1 :(得分: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
                }
            }