[英]C3.js, y-axis time
Using C3.js
, I am trying to generate a graph whose x-axis is a linear list of kilometres, and y-axis is the corresponding time - in format MM:SS
. 使用
C3.js
,我试图生成一个图,其x轴是公里的线性列表,y轴是对应的时间格式MM:SS
。
The best I have been able to generate is the result of the below, which is the reverse of what I'm looking for. 我能够生成的最好结果是以下结果,这与我正在寻找的结果相反。 This produces a graph with times on the x-axis and kilometres on the y-axis.
这将生成一个图形,其中x轴上有时间,y轴上有公里。 Could anyone advise how I could convert the below to a generate a graph with the x-axis KMs, and y-axis times.
任何人都可以建议我如何将以下内容转换为带有x轴KM和y轴时间的图形。 Thank you.
谢谢。
var km_chart = c3.generate({
"data": {
"x": "time",
"y": "kms",
"columns": [
["time", "04:00", "04:00", "04:15", "04:30", "04:15"],
["kms", 1, 2, 3, 4, 5]
]
},
"axis": {
"x": {
"type": "category"
}
},
"bindto": "#km_chart"
});
The simpliest solution would be to rotate your graph with: 最简单的解决方案是使用以下方法旋转图形:
"axis":{
<your stuff>
rotate: true
}
The y-axis is only accepting values, so you can switch your x/y-axis with rotate or you have to convert your time into some value. y轴仅接受值,因此您可以旋转旋转x / y轴,或者必须将时间转换为某个值。 You could use 1234 as 12:34 for example.
例如,您可以使用1234作为12:34。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.