Chart JS工具提示,标签宽度为零

问题描述 投票:0回答:1

工具提示和标签的宽度在localhost上似乎为0,其代码与示例相同:https://i.imgur.com/FJ5nHra.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

控制台上没有错误

javascript python flask html5-canvas chart.js
1个回答
0
投票

在“勇敢的浏览器”上似乎有一个故障,无法在url 0.0.0.0上运行,而在localhost上运行,在localhost上运行也不错

© www.soinside.com 2019 - 2024. All rights reserved.