带有Angular6的堆积列Highchart无法正常工作 [英] Stacked Column Highchart with Angular6 is not working

查看:59
本文介绍了带有Angular6的堆积列Highchart无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过遵循链接Angular标准示例

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.

下面我附上我的html和ts文件以供参考.

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.

预先感谢!

推荐答案

网页空白的原因如下: 我在根目录app.module.ts下添加了HighChartsChartModule导入. 但是在我的项目中有不同的模块,每个模块都有自己的.module.ts文件. 因此,如果我在针对特定模块的导入下添加HighChartsChartModule,则它将按预期工作. 如果我仅在app.module.ts

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的堆积列Highchart无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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