在Chartjs-Plugin-Labels.js中找不到图表对象

发布于 2025-02-07 08:48:59 字数 1895 浏览 0 评论 0 原文

美好的一天,

在我的Angular项目中,我想使用图表插件,因此我运行两个命令如下:

npm install angular2-chartjs
npm install chartjs-plugin-labels

然后我在TS文件中将其导入到以下

import { ChartModule } from 'angular2-chartjs';
import 'chartjs-plugin-labels';

我的软件包中。

"angular2-chartjs": "^0.5.1",
"chartjs-plugin-labels": "^1.1.0",

内容:在 我的本地,我通过 ng serve 命令启动我的角度项目,一切正常。

但是,当我生成Web软件包并部署以坐下Apache Web服务器时,加载页面时,我会点击“找不到图表对象”错误。

我从Chrome Console中看到的错误如下:

我相信它的投掷量来自chatchjs-plugin-lables.js:

“在此处输入图像说明”

我使用 npm npm run sit 命令生成SIT软件包:

以下是我的 package.json 的一部分,在 ng服务 npm运行sit

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "demo": "ng build -c=demo --base-href=/demo/",
    "dev": "ng build -c=dev --base-href=/sib/",
    "sit": "ng build -c=sit --base-href=/sib/ && ts-node git.version.ts -c sit && ts-node app.version.ts -c sit",
    "uat": "ng build -c=uat --base-href=/sib/ && ts-node git.version.ts -c uat && ts-node app.version.ts -c uat",
    "prod": "ng build -c=prod --base-href=/sib/ && ts-node git.version.ts -c prod && ts-node app.version.ts -c prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "version": "ts-node git.version.ts -c prod"
  },

我怀疑的是,当我运行 NPM运行SIT ,生成Web软件包的方法是不同的,而Char对象未在Web软件包中生成的方式。

但是到目前为止,其他插件没有问题。

请建议。

Good day,

In my angular project, I would like to use the chart plugin, thus I run the both command as follow:

npm install angular2-chartjs
npm install chartjs-plugin-labels

and then I import it in my ts file as follow:

import { ChartModule } from 'angular2-chartjs';
import 'chartjs-plugin-labels';

and in my package.json, I have this:

"angular2-chartjs": "^0.5.1",
"chartjs-plugin-labels": "^1.1.0",

In my local, I start my angular project by ng serve command, everything working fine.

But when I generate the web package and deploy to SIT apache web server, I will hit "Can not find Chart object" error when I load the page.

The error I saw from chrome console is something as follow:
enter image description here

And I believe its throw from chartjs-plugin-lables.js:

enter image description here

I generate SIT package using npm run sit command:

The following is part of my package.json, on what it doing for ng serve and npm run sit:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "demo": "ng build -c=demo --base-href=/demo/",
    "dev": "ng build -c=dev --base-href=/sib/",
    "sit": "ng build -c=sit --base-href=/sib/ && ts-node git.version.ts -c sit && ts-node app.version.ts -c sit",
    "uat": "ng build -c=uat --base-href=/sib/ && ts-node git.version.ts -c uat && ts-node app.version.ts -c uat",
    "prod": "ng build -c=prod --base-href=/sib/ && ts-node git.version.ts -c prod && ts-node app.version.ts -c prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "version": "ts-node git.version.ts -c prod"
  },

What I suspect is, when I run npm run sit, the way to generate the web package is different, and some how the char object did not generate into web package.

But so far no issue for other plugin.

Kindly advise.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨小墨 2025-02-14 08:48:59

我也有同样的问题。仔细检查项目中的单个导入“ Chartjs-Plugin-labels.js”并将其删除。

I had the same issue. Check through the project for a single import of 'chartjs-plugin-labels.js' and remove it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文