我正在使用d3.js生成一个sankey图表,并且我使用intro.js来引导页面浏览。除了d3图表外,Intro.js适用于我的所有页面。例如,我还使用intro.js来浏览由js库DataTables动态生成的其他元素,它完美地运行。
我的DataTables之旅代码:
document.getElementById('help').onclick = function (){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "These are the results of your search."
},
{
element: "[name=DataTables_Table_0_length]",
intro: "Select how many results to view.",
position: "right"
},
{
element: "[type=search][aria-controls=DataTables_Table_0]",
intro: 'Here you can search the table.',
position: 'left'
},
{
element: "[class=ColVis]",
intro: "To show or hide columns, use this.",
position: "left"
},
{
element: "[class=DTTT_container]",
intro: "Use these buttons to download, print or copy the data in the table.",
position: "left"
},
{
intro: "Select an NPI to view its homepage and we'll continue from there."
}
],
'showBullets': true,
'skipLabel': 'Let me drive',
'doneLabel': "Try it out"
});
intro.start();
};
所有这些元素都是动态生成的,但在调用时会被intro.js识别。
但是,当我尝试使用d3元素时,intro.js无法找到它们。
document.getElementById('help').onclick = function (){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "These are the results of your search."
},
{
element: "[class=legend-items]",
intro: "This is the legend.",
position: "right"
}
],
'showBullets': true,
'skipLabel': 'Let me drive',
'doneLabel': "Try it out"
});
intro.start();
};
有没有人遇到过这个问题,可以为我解释一下?
非常感谢。