gpt4 book ai didi

javascript - 我的图表线条未按顺序排列

转载 作者:行者123 更新时间:2023-12-01 03:03:41 24 4
gpt4 key购买 nike

我有一个图表,连接所有线条的结果应该如图所示。但目前情况并非如此。我做错了什么?

enter image description here

https://jsfiddle.net/r2uaq27a/

var chart = c3.generate({
data: {
xs: {
data1: "data2"
},
columns: [
['data1', 2,3,4,7,8,9,8,7,3],
['data2', 1,2,3,4,5,4,3,2,1]
]

}
});

最佳答案

设置some whatdata 的未记录的 xSort 属性设置为 false:

var chart = c3.generate({
data: {
xSort: false,
x: 'x',
order: function (i) { console.log(i); },
columns: [
['x', 1,2,3,4,5,4,3,2,1],
['data1', 2,3,4,7,8,9,8,7,3]
]
}
});

运行:

var chart = c3.generate({
data: {
xs: {
data1: "data2",
data3: "data4"
},
xSort: false,
columns: [
['data1', 2,3,4,7,8,9,8,7,3],
['data2', 1,2,3,4,5,4,3,2,1],
['data3', Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10],
['data4', Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10,Math.random() * 10]
]

}
});
#catImage {
width: 40px;
height: 40px;
position: absolute;
left: 40px;
top: 0px;
}
<link data-require="c3.js@0.4.11" data-semver="0.4.11" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.css" />
<script data-require="c3.js@0.4.11" data-semver="0.4.11" src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.js"></script>
<script data-require="d3@3.5.17" data-semver="3.5.17" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script>
<div id="chart"></div>

关于javascript - 我的图表线条未按顺序排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46325699/

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