图表JS工具提示和标签宽度为零



工具提示和标签宽度在localhost上似乎为0,代码与示例相同:https://i.stack.imgur.com/dKhyr.png

我不知道我做错了什么,这是代码:https://pastebin.com/mt9WCdhe

var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var config = {
type: 'line',
data: {
labels: MONTHS,
datasets: [{
label: 'My First dataset',
backgroundColor: window.chartColors.red,
borderColor: window.chartColors.red,
data: randomData(),
fill: false,
}, {
label: 'My Second dataset',
fill: false,
backgroundColor: window.chartColors.blue,
borderColor: window.chartColors.blue,
data: randomData(),
}]
},
options: {
responsive: false,
maintainAspectRatio: false,
title: {
display: true,
text: 'Test graph'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: false
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Value'
}
}]
}
}
};
window.onload = function() {
var ctx = document.getElementById('myChart').getContext('2d');
window.myLine = new Chart(ctx, config);
};

使用的示例:https://www.chartjs.org/samples/latest/charts/line/basic.html

控制台上没有错误

Brave Browser在url 0.0.0.0上运行时出现故障,但在localhost上运行时没有,运行正常

最新更新