用“字符串"进行浮点运算X轴 [英] Flot With "String" x-axis

查看:75
本文介绍了用“字符串"进行浮点运算X轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用flot时,我希望有一个基于字符串的x轴.例如,我有一个客户列表"Bob","Chris","Joe",并希望将其收入绘制在Y轴上. (这是一个条形图)

When using flot I would like to have a string based x-axis. For example I have a list of customers "Bob", "Chris", "Joe" and would like to plot their revenue on the Y-Axis. (this is a bar graph)

乍一看,flot仅支持x轴上的数字类型.这是真的吗?

It seems at first glance flot only supports numeric types on the x-axis. Is this true?

推荐答案

@Matt 很近,但它会使使用ticks选项直接指定哪些价格变动应带有哪些标签更有意义:

@Matt is close, but it would make more sense to just use the ticks option to directly specify what ticks should have what labels:

var options = {

...
  xaxis: {
    ticks: [[0,'Bob'],[1,'Chris'],[2,'Joe']]
  }
...

};

编辑:类似于(我添加了更多数据而不是标签,但是您可以理解.)

EDIT: it looks like this (I added more data than labels, but you get the idea).

这篇关于用“字符串"进行浮点运算X轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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