【问题标题】:Rickshaw - js chart library: Need strings instead of numbers on axesRickshaw - js 图表库:需要字符串而不是轴上的数字
【发布时间】:2012-10-25 03:41:35
【问题描述】:

我正在使用 rickshaw(http://code.shutterstock.com/rickshaw/) 并希望在图形的一个轴上使用字符串而不是数字。有可能这样做吗?如果有,怎么做?

【问题讨论】:

    标签: charts d3.js javascript


    【解决方案1】:

    可以定义和使用您自己的格式化程序

    Rickshaw.Fixtures.Number.myFormat =  (y) ->
      if (y == val)
        return 'somestring';
      else
        return ''some other string';
    

    将其用作:

    yAxis = new Rickshaw.Graph.Axis.Y
      graph: graph
      tickFormat: Rickshaw.Fixtures.Number.myFormat
    
    
    graph.render()
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多