要解决Angular应用中的Plotly.js无法正常工作的问题,可以尝试以下解决方法:
npm install plotly.js
import * as Plotly from 'plotly.js-dist';
import { Component, OnInit } from '@angular/core';
import * as Plotly from 'plotly.js-dist';
@Component({
selector: 'app-my-chart',
template: '',
})
export class MyChartComponent implements OnInit {
ngOnInit() {
const data = [
{
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
mode: 'markers',
type: 'scatter'
}
];
const layout = {
title: 'My Chart'
};
Plotly.newPlot('chart', data, layout);
}
}
"styles": [
"src/styles.css",
"node_modules/plotly.js-dist/plotly.css"
]
如果以上方法无法解决问题,请提供更多的错误信息和代码示例,以便更准确地诊断和解决问题。