【问题标题】:JQplot Format StringJQplot 格式字符串
【发布时间】:2012-12-31 09:55:05
【问题描述】:

能否请我帮忙格式化 Y 轴上带有 '%' 符号的字符串。

这是'$'的代码:

tickOptions: {formatString: '$%d'}

如何格式化字符串以使用“%”符号,因为“%”符号用作“关键字”?

【问题讨论】:

    标签: javascript jqplot axis format-string


    【解决方案1】:

    试试这样的:

    tickFormatter = function (format, val) { 
    return val+"%";
    }
    

    并将此选项添加到情节中:

    axes: {
     yaxis: {
     tickOptions: {
      formatter: tickFormatter
     }
    }
    

    http://jsfiddle.net/pabloker/9ZrKA/3/

    【讨论】:

      【解决方案2】:

      要写一个 '%' 符号,你必须把它加倍:

      axes:
         {yaxis: 
              {tickOptions: 
                     {formatString: '%%%d'}
              }
         }
      

      如果您的值为 10,%%%d 将写入 '%10'。 同样,如果您的值再次为 10,%d%% 将写入 '10%'。 因此,您只需将 '$' 符号替换为 '%%'。

      安东尼。

      【讨论】:

        猜你喜欢
        • 2019-04-18
        • 2019-03-04
        • 1970-01-01
        • 2010-11-25
        • 1970-01-01
        • 1970-01-01
        • 2018-11-22
        • 2021-08-06
        • 2010-10-22
        相关资源
        最近更新 更多