将jqPlot pointLabels格式化为货币

时间:2013-05-24 21:41:22

标签: jquery charts jqplot

我想在我的价值观中加入逗号。

到目前为止,我可以获得$,但没有别的:

                seriesDefaults: {
                    renderer: $.jqplot.BarRenderer,
                    pointLabels: { show: true, formatString: '$%s' },
                },

有没有办法让pointLabel看起来像 $ 45,666,444

2 个答案:

答案 0 :(得分:2)

试试这个:

tickOptions:{
   formatString: "%'.2f"
},

答案 1 :(得分:1)

默认情况下,使用数据系列中数据ponit数组中的最后一个值    为标签。对于大多数系列渲染器,可以将额外的数据添加到    数据点数组和最后一个值将用作标签。

例如,    这个系列:

   [[1,4], [3,5], [7,2]]

默认情况下,会使用标签中的y值。    额外的数据可以像这样添加到系列中:

   [[1,4,'mid'], [3 5,'hi'], [7,2,'low']]

现在点标签将是'mid','low'和'hi'。

点标签和自定义标签数组的选项可以传递给    系列选项上的“pointLabels”选项如下:

   series:[{pointLabels:{
      labels:['mid', 'hi', 'low'],
      location:'se',
      ypadding: 12
      }
   }]
相关问题