我使用d3plus创建了一个条形图。在代码中,我使用以下行创建了时间轴:
.time({
"value": "__TIME__"
)
.timeline({
"align":"center",
"value":true})
在我的数据中, __ TIME __ 变量仅包含数字(1,2,3,4 ..)。但时间表将其转换为数月。我只想要简单的数字(1,2,3,4 ......),而不是自动格式化时间。
是否可以禁用时间线的自动格式?
以下是jsfiddle示例:
var data = [{
"day": 0,
"name": "alpha",
"value": 15
}, {
"day": 1,
"name": "alpha",
"value": 34
}, {
"day": 0,
"name": "alpha2",
"value": 17
}, {
"day": 1,
"name": "alpha2",
"value": 65
}, {
"day": 1,
"name": "beta",
"value": 10
}, {
"day": 1,
"name": "beta",
"value": 10
}, {
"day": 0,
"name": "beta2",
"value": 40
}, {
"day": 1,
"name": "beta2",
"value": 38
}, {
"day": 0,
"name": "gamma",
"value": 5
}, {
"day": 1,
"name": "gamma",
"value": 10
}, {
"day": 0,
"name": "gamma2",
"value": 20
}, {
"day": 1,
"name": "gamma2",
"value": 34
}, {
"day": 0,
"name": "delta",
"value": 50
}, {
"day": 2,
"name": "delta",
"value": 43
}, {
"day": 2,
"name": "delta2",
"value": 17
}, {
"day": 2,
"name": "delta2",
"value": 35
}]
var visualization = d3plus.viz()
.container("#chartContainer")
.data(data)
.type({
"value": "box",
"mode": "extent" // changes box/whisker from tukey to extent mode
})
.id("name")
.x("day")
.y("value")
.time("day")
.timeline({
"align":"center",
"value":true})
//.format() // I couldn't find any format for plain data without converting it into time
.draw()
<script src="//d3plus.org/js/d3.js"></script>
<script src="//d3plus.org/js/d3plus.js"></script>
<div id="chartContainer">
</div>