gpt4 book ai didi

javascript - 当只有几个值时,Dimple Js 会重复刻度

转载 作者:行者123 更新时间:2023-11-28 07:39:19 25 4
gpt4 key购买 nike

当我只有一两个数据点时,dimple js 会重复相同的刻度。我怎样才能让它不这样做?

示例

Image of the below code. 1/1/1990 repeats multiple times

<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>

最佳答案

通常您会设置 axis.ticks但是当使用时间轴时,您需要设置 timePeriodtimeInterval 。这将在数​​据集中每天设置一个刻度线。

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();

enter image description here

关于javascript - 当只有几个值时,Dimple Js 会重复刻度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28246202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com