Angular 在ionic 2中实现实时highcharts

Angular 在ionic 2中实现实时highcharts,angular,highcharts,ionic2,livecharts,Angular,Highcharts,Ionic2,Livecharts,我想实现一个活动图表:在离子2,所以angular2 我试了很多次,但总是出错 我在js中看到了以下代码: $(document).ready(function () { Highcharts.setOptions({ global: { useUTC: false } }); Highcharts.chart('container', { chart: { type: 's

我想实现一个活动图表:在离子2,所以angular2

我试了很多次,但总是出错

我在js中看到了以下代码:

$(document).ready(function () {
    Highcharts.setOptions({
        global: {
            useUTC: false
        }
    });

    Highcharts.chart('container', {
        chart: {
            type: 'spline',
            animation: Highcharts.svg, // don't animate in old IE
            marginRight: 10,
            events: {
                load: function () {

                    // set up the updating of the chart each second
                    var series = this.series[0];
                    setInterval(function () {
                        var x = (new Date()).getTime(), // current time
                            y = Math.random();
                        series.addPoint([x, y], true, true);
                    }, 1000);
                }
            }
        },
        title: {
            text: 'Live random data'
        },
        xAxis: {
            type: 'datetime',
            tickPixelInterval: 150
        },
        yAxis: {
            title: {
                text: 'Value'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '</b><br/>' +
                    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
                    Highcharts.numberFormat(this.y, 2);
            }
        },
        legend: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
        series: [{
            name: 'Random data',
            data: (function () {
                // generate an array of random data
                var data = [],
                    time = (new Date()).getTime(),
                    i;

                for (i = -19; i <= 0; i += 1) {
                    data.push({
                        x: time + i * 1000,
                        y: Math.random()
                    });
                }
                return data;
            }())
        }]
    });
});
$(文档).ready(函数(){
Highcharts.setOptions({
全球:{
useUTC:false
}
});
Highcharts.chart('容器'{
图表:{
类型:“样条线”,
动画:Highcharts.svg,//不要在旧IE中设置动画
marginRight:10,
活动:{
加载:函数(){
//设置图表的每秒更新
var系列=本系列[0];
setInterval(函数(){
var x=(新日期()).getTime(),//当前时间
y=数学随机();
系列。添加点([x,y],真,真);
}, 1000);
}
}
},
标题:{
文本:“实时随机数据”
},
xAxis:{
键入:“日期时间”,
像素间隔:150
},
亚克斯:{
标题:{
文本:“值”
},
绘图线:[{
值:0,
宽度:1,
颜色:'#808080'
}]
},
工具提示:{
格式化程序:函数(){
返回“+this.series.name+”
+ Highcharts.dateFormat(“%Y-%m-%d%H:%m:%S',this.x)+'
'+ 数字格式(this.y,2); } }, 图例:{ 已启用:false }, 出口:{ 已启用:false }, 系列:[{ 名称:'随机数据', 数据:(函数(){ //生成一个随机数据数组 var数据=[], 时间=(新日期()).getTime(), 我
对于(i=-19;i如果你想在Angular2中使用Highcharts,你可以通过 它提供了正确的绑定

这些说明对我很有效:

从CL:
npm安装angular2 highcharts——保存

在您的
App.module.ts
中:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ChartModule } from 'angular2-highcharts';
import { App } from './App';

@NgModule({
    imports: [
      BrowserModule, 
      ChartModule.forRoot(require('highcharts')
    ],
    declarations: [App],
    bootstrap: [App]
})
export class AppModule {}

如果你想在Angular2中使用Highcharts,你可以通过 它提供了正确的绑定

这些说明对我很有效:

从CL:
npm安装angular2 highcharts——保存

在您的
App.module.ts
中:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ChartModule } from 'angular2-highcharts';
import { App } from './App';

@NgModule({
    imports: [
      BrowserModule, 
      ChartModule.forRoot(require('highcharts')
    ],
    declarations: [App],
    bootstrap: [App]
})
export class AppModule {}

您尚未将代码粘贴到此处或创建问题示例-粘贴的代码没有问题。请阅读并尝试重新创建问题的实例。您尚未将代码粘贴到此处或创建问题示例-粘贴的代码没有问题。请阅读并尝试重新创建问题的实例。