Rickshaw - js图表库:需要字符串,而不是轴上的数字 [英] Rickshaw - js chart library: Need strings instead of numbers on axes

查看:385
本文介绍了Rickshaw - js图表库:需要字符串,而不是轴上的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用人力车( http://code.shutterstock.com/rickshaw/ )和想要在图形的一个轴上有字符串而不是数字。是可能做到的吗?

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?

推荐答案

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

Your own formatter can be defined and be used

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()

这篇关于Rickshaw - js图表库:需要字符串,而不是轴上的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆