Javascript x轴上的字符串
我想创建一个图形,其中x轴上的值是字符串而不是整数。 目前我所拥有的是这样的:Javascript x轴上的字符串,javascript,nvd3.js,Javascript,Nvd3.js,我想创建一个图形,其中x轴上的值是字符串而不是整数。 目前我所拥有的是这样的: 10 | 8 | 4 | 0 |__________ 1 3 5 10 | 8 | 4 | 0 |____________________________ January February March 我想这样做: 10 | 8 | 4 | 0 |__________
10 |
8 |
4 |
0 |__________
1 3 5
10 |
8 |
4 |
0 |____________________________
January February March
我想这样做:
10 |
8 |
4 |
0 |__________
1 3 5
10 |
8 |
4 |
0 |____________________________
January February March
我使用的是NVD3图表。任何帮助都将不胜感激
我将传递数据,但目前我手动放置
function profiles() {
var profiles = [];
profiles.push({x:1,y:5});
profiles.push({x:2,y:3});
profiles.push({x:3,y:9});
profiles.push({x:4,y:6});
profiles.push({x:5,y:6});
profiles.push({x:6,y:8});
profiles.push({x:7,y:4});
profiles.push({x:8,y:7});
profiles.push({x:9,y:5});
profiles.push({x:10,y:8});
profiles.push({x:11,y:6});
profiles.push({x:12,y:12});
return [{
values: profiles,
key: "Profiles",
color: "#ff7f0e"
}];
}
例如,我想要的不是x:1,而是x:1。我会将我的答案引导到这个页面。这似乎允许您在传入的数组中创建标签和值。如果数字来自其他地方,您可以创建一个月名称数组,然后使用月份-1的值访问它们(一月是0,因为数组是以零为基础的),因此 然后
我认为这应该为您指出正确的方向,让图表显示字符串。您是否在数据中传递日期?你能在问题中发布一段代码吗?这个例子可能会有所帮助