带有 Angular6 的 Stacked Column Highchart 不起作用 [英] Stacked Column Highchart with Angular6 is not working
问题描述
我正在尝试按照链接中的 Angular 标准示例第一次使用 angular6 实现堆积柱形图
https://www.tutorialspoint.com/angular_highcharts/angular_highcharts_column_stacked.htm
但这给了我网页上的空白容器.有什么需要补充的吗.
下面附上我的 html 和 ts 文件以供参考.
app.module.ts进口:[...Highcharts图表模块],
.HTML 文件<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"><highcharts-图表[HighCharts]="highcharts"[选项]="图表选项"></highcharts-chart>
.ts 文件highcharts = Highcharts;图表选项 = {图表: {类型:'列'},标题: {文本:'月平均温度'},副标题:{text: '来源:WorldClimate.com'},传奇: {布局:'垂直',对齐:'左',垂直对齐:'顶部',x: 250,y: 100,浮动:真实,边框宽度:1,},x轴:{类别:['非洲'、'美洲'、'亚洲'、'欧洲'、'大洋洲'],标题:{文字:空}},y轴:{分钟:0,标题: {text: '人口(百万)',对齐:'高'},标签: {溢出:'证明'}},工具提示:{值后缀:'百万'},绘图选项:{柱子: {数据标签:{启用:真}},系列: {堆叠:'正常'}},学分:{启用:假},系列: [{name: 'Year 1800',数据:[107, 31, 635, 203, 2]},{name: 'Year 1900',数据:[133、156、947、408、6]},{name: '2008 年',数据:[973、914、4054、732、34]}]};构造函数(){}ngOnInit() {}
请分享您的建议/建议.
提前致谢!!
网页出现空白的原因如下:我在根级别的 app.module.ts 下添加 HighChartsChartModule 导入.但是在我的项目中有不同的模块,每个模块都有自己的 .module.ts 文件.因此,如果我在特定模块的导入下添加 HighChartsChartModule,那么它会按预期工作.如果我只是在 app.module.ts 下添加它永远不会工作
import { HighchartsChartModule } from 'highcharts-angular';@NgModule({进口:[Highcharts图表模块],
I am trying to implement the stacked column chart for the first time with angular6 by following the Angular standard example from the link
https://www.tutorialspoint.com/angular_highcharts/angular_highcharts_column_stacked.htm
But this give me blank container on the web page. Is there anything needs to be added.
Below I am attaching my html and ts files for reference.
app.module.ts
imports: [
...
HighchartsChartModule
],
.HTML file
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto">
<highcharts-chart
[HighCharts]="highcharts"
[options]="chartOptions"
></highcharts-chart>
</div>
.ts file
highcharts = Highcharts;
chartOptions = {
chart: {
type: 'column'
},
title: {
text: 'Monthly Average Temperature'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 250,
y: 100,
floating: true,
borderWidth: 1,
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'], title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip : {
valueSuffix: ' millions'
},
plotOptions: {
column: {
dataLabels: {
enabled: true
}
},
series: {
stacking: 'normal'
}
},
credits:{
enabled: false
},
series: [
{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
},
{
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
},
{
name: 'Year 2008',
data: [973, 914, 4054, 732, 34]
}
]
};
constructor() {
}
ngOnInit() {
}
Please share your suggestions/advice.
Thanks in advance !!
The reason to get blank at web page is below : I was adding the HighChartsChartModule import under app.module.ts which is root level. But in my project there are different modules, and each module have its own .module.ts file. So if I add HighChartsChartModule under imports for specific module then it works as expected. It never work if I just add under the app.module.ts
import { HighchartsChartModule } from 'highcharts-angular';
@NgModule({
imports: [
HighchartsChartModule
],
这篇关于带有 Angular6 的 Stacked Column Highchart 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!