Moment.js and Chart.js not working in Firefox Addon when Type time is specified

旧城冷巷雨未停 提交于 2020-01-05 06:53:12

问题


I've created a firefox addon with:

My manifest includes:

"content_scripts": [
    {
      "matches": [
        "..."          ],
      "js": [
        "moment.js",
        "jquery.js",
        "chartjs.js",
        "main.js"
      ],
      "run_at": "document_end"
    }
  ]

main.js includes:

var myChart = new Chart(ctx, {
      type: 'line',
      data: {
        datasets: [{
          label: label,
          lineTension: 0,
          backgroundColor: color,
          data: data
        }]
      },
      options: {
        scales: {
          xAxes: [{
            type: "time",
            distribution: 'linear',
            time: {
              unit: "day"
            }
          }]
        }
      }
    });

This works in my Chrome extension, but when I port it to Firefox addon, it shows a blank chart. Even the jsfiddle works in both: https://jsfiddle.net/a9yzuxjf/1/

I've removed the 'type: "time"' and it renders, but the chart isn't a time series like I want. Could this be something to do with moment.js not loading properly?

来源:https://stackoverflow.com/questions/51011867/moment-js-and-chart-js-not-working-in-firefox-addon-when-type-time-is-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!