【问题标题】:Chart JS tooltip and label width is zeroed图表 JS 工具提示和标签宽度归零
【发布时间】:2020-06-10 21:08:45
【问题描述】:

工具提示和标签宽度在 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】:

    似乎在 Brave Browser 上在 url 0.0.0.0 上运行但在 localhost 上运行时出现故障,在 localhost 上运行它可以正常工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 2013-11-29
      • 1970-01-01
      相关资源
      最近更新 更多