gpt4 book ai didi

rickshaw - Uncaught Rickshaw.Graph 需要对元素的引用

转载 作者:行者123 更新时间:2023-12-05 06:44:59 27 4
gpt4 key购买 nike

需要一些帮助来解决这个错误:

Uncaught Rickshaw.Graph needs a reference to an element
rickshaw.min.js:1 initialize
rickshaw.min.js:1 Rickshaw.Graph
rickshaw.min.js:1 loadChart
chart.js:23 (anonymous function)
stockDisplay.html:21 window.DoorLock.DoorLock._tryToFreeWaitList
onsenui.js:4123 window.DoorLock.DoorLock._unlock
onsenui.js:4118 unlock
onsenui.js:4100 (anonymous function)

这是 JS 函数:

函数加载图表(){

 var stockDataSeries = (function () {
var stockDataSeries = null;
$.ajax({
'async': false,
'global': false,
'url': 'http://[host_name]/json/aa_historicalData.json',
'dataType': "json",
'success': function (data) {
stockDataSeries = JSON.stringify(data);
},
'error': function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
return stockDataSeries;
})();

var stockChart = new Rickshaw.Graph({
element: document.querySelector('chart'),
renderer: 'line',
width: '345',

series: [ {
color: 'steelblue',
name: 'Price',
data: stockDataSeries
} ]
});

var x_axis = new Rickshaw.Graph.Axis.X( {
graph: stockChart
} );

var y_axis = new Rickshaw.Graph.Axis.Y( {
graph: stockChart,
orientation: 'left',
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
element: document.getElementById('y_axis')
} );

var detail = new Rickshaw.Graph.HoverDetail({
graph: stockChart
});

graph.render();

最佳答案

尝试使用 document.getElementById('chart') 而不是使用 document.querySelector('chart')。我相信您的错误是由于返回的 querySelector 没有元素造成的。

关于rickshaw - Uncaught Rickshaw.Graph 需要对元素的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27082952/

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