角4与Plotly [英] Angular 4 with Plotly

查看:51
本文介绍了角4与Plotly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建需要图形的angular 4应用程序.

I am trying to build an angular 4 application that needs graph.

我计划使用 plotly ,但是我没有得到一个清晰的网站来显示在angular 4应用程序中包含 plotly.js 文件的步骤或方式.

I am planning to use plotly, but I am not getting any clear site showing the steps or the way to include plotly.js file in angular 4 application.

有人可以对此提供一些见解吗?

Can somebody please give me some insight on this?

推荐答案

这就是我要做的,首先是使用NPM(或您使用的任何软件包管理器)安装plotly.js:

This is what I do, first is to install plotly.js using NPM(or any package manager that you use):

npm install plotly.js --save
npm install @types/plotly.js --save

注意:您可以考虑在开发部分(--save-dev)

然后我在compilerOptions下编辑了src/tsconfig.app.json以包括此内容:

Then I edited src/tsconfig.app.json to include this, under compilerOptions:

    "types": [
      "plotly.js"
    ],"paths": {
      "plotly.js": [
        "../node_modules/plotly.js/dist/plotly-basic.js"
      ]
    }

然后,您可以通过如下所示的导入在任何组件中使用Plotly.js:

Then you can use Plotly.js in any of your component by importing like this:

import * as Plotly from 'plotly.js';
import {Config, Data, Layout} from 'plotly.js';

这篇关于角4与Plotly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆