单击选项无法在javascript中正常工作

我试图获得要在单击时打开新页面的要点,但是当我对x标签使用字符串刻度时,它不起作用。

我怀疑我不正确地使用window.open(d.x)参数! JS新手,请帮忙。

 var chart = c3.generate({
      bindto: '#chart',data: {
			x:'x',columns: [
          ['x','30','200','100','400','150','250'],['data2',50,20,10,40,15,25]
        ],type: 'scatter',onclick: function (d) { 
          console.log(d)
          window.open(arrayOfLinks[d.x]);
        },},axis: {
        rotated: true
      },});
    
var arrayOfLinks = [
  "http://google.com","http://bing.com","http://duckduckgo.com","http://yahoo.com","http://msn.com","http://stackoverflow.com",];
<!DOCTYPE html>
<html lang="en">
<head>
    <title>tst</title>
     <meta charset="utf-8">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.11/c3.min.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.11/c3.min.js"></script>
</head>
<body>
<div class="container">

			
<div id="container" style="width: 2000px; height: 60px; margin: 0 auto"></div>
<div class="container">
		</div>
		<center><b>Clickable data points</b></center>
		<div id="chart"></div>
 
    <script> 
    </script>
</body>
</html>

当我摆脱x:'x'而只是使用:

data: {
        columns: [
          [x,30,200,100,400,150,250],25]

效果很好!但是我需要前面的例子。

谢谢。

inlove2100 回答:单击选项无法在javascript中正常工作

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3157789.html

大家都在问