当我只有一个或两个数据点时,凹坑js将重复相同的刻度。我怎么能不这样做呢?
实施例
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script>
</head>
<body>
<script type="text/javascript">
var svg = dimple.newSvg("body", 800, 600);
var data = [
{ "Word":"1/2/1990", "Awesomeness":2000 },
{ "Word":"1/1/1990", "Awesomeness":3000 }
];
var chart = new dimple.chart(svg, data);
chart.addTimeAxis("x", "Word");
chart.addMeasureAxis("y", "Awesomeness");
chart.addSeries(null, dimple.plot.line);
chart.draw();
</script>
</body>
答案 0 :(得分:0)
通常您会设置axis.ticks,但在使用时间轴时,您需要设置timePeriod和timeInterval。这将在数据集中每天设置一个刻度标记。
var xAxis = chart.addTimeAxis("x", "Word");
xAxis.timePeriod = d3.time.days;
xAxis.timeInterval = 1;
xAxis.tickFormat = "%A";
chart.addMeasureAxis("y", "Awesomeness");
chart.addSeries(null, dimple.plot.line);
chart.draw();