Rickshaw - js chart library: Need strings instead

2019-06-03 02:14发布

I am using rickshaw(http://code.shutterstock.com/rickshaw/) and want to have strings on one of the axes of the graph instead of numbers. Is it possible to do that? If so, how?

1条回答
男人必须洒脱
2楼-- · 2019-06-03 02:57

Your own formatter can be defined and be used

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

Use this as:

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


graph.render()
查看更多
登录 后发表回答