无法在Ionic v4应用中添加高图指示器

时间:2019-03-12 12:30:03

标签: ionic-framework highcharts

我努力在Ionic v4应用程序中的股票图表上显示高图指标。

我已经npm安装了highcharts节点模块...

html:

<ion-content>
    <ion-item >
      <div id="container" style="width:100%; "></div>
    </ion-item>
 </ion-content>

ts:

import { Component, OnInit } from '@angular/core';
import * as Highcharts from 'highcharts/highstock';
import * as Indicators from 'highcharts/indicators/indicators';


@Component({
  selector: 'app-instrument',
  templateUrl: './instrument.page.html',
  styleUrls: ['./instrument.page.scss'],
})
export class InstrumentPage implements OnInit {

  constructor() {}

  ngOnInit() {}

  ngDoCheck(){
    Highcharts.stockChart('container', {
          chart: {
          height: '95%' 
          },
          navigator: {
            enabled: false
        },
        scrollbar: {
          enabled: false
      },
          rangeSelector: {
            enabled: false
        },
          series: [{
            id: 'mymain',
            type: 'candlestick',
            name: 'AAPL Stock Price',
            data: [
              [
                1489411800000,
                138.85,
                139.43,
                138.82,
                139.2
            ],
            [
                1489498200000,
                139.3,
                139.65,
                138.84,
                138.99
            ],
            [
                1489584600000,
                139.41,
                140.75,
                139.03,
                140.46
            ],
            [
                1489671000000,
                140.72,
                141.02,
                140.26,
                140.69
            ],
            [
                1489757400000,
                141,
                141,
                139.89,
                139.99
            ],
            [
                1490016600000,
                140.4,
                141.5,
                140.23,
                141.46
            ],
            [
                1490103000000,
                142.11,
                142.8,
                139.73,
                139.84
            ],
            [
                1490189400000,
                139.85,
                141.6,
                139.76,
                141.42
            ],
            [
                1490275800000,
                141.26,
                141.58,
                140.61,
                140.92
            ],
            [
                1490362200000,
                141.5,
                141.74,
                140.35,
                140.64
            ],
            [
                1490621400000,
                139.39,
                141.22,
                138.62,
                140.88
            ],
            [
                1490707800000,
                140.91,
                144.04,
                140.62,
                143.8
            ],
            [
                1490794200000,
                143.68,
                144.49,
                143.19,
                144.12
            ],
            [
                1490880600000,
                144.19,
                144.5,
                143.5,
                143.93
            ],
            [
                1490967000000,
                143.72,
                144.27,
                143.01,
                143.66
            ],
            [
                1491226200000,
                143.71,
                144.12,
                143.05,
                143.7
            ],
            [
                1491312600000,
                143.25,
                144.89,
                143.17,
                144.77
            ],
            [
                1491399000000,
                144.22,
                145.46,
                143.81,
                144.02
            ],
            [
                1491485400000,
                144.29,
                144.52,
                143.45,
                143.66
            ],
            [
                1491571800000,
                143.73,
                144.18,
                143.27,
                143.34
            ],
            [
                1491831000000,
                143.6,
                143.88,
                142.9,
                143.17
            ],
            [
                1491917400000,
                142.94,
                143.35,
                140.06,
                141.63
            ],
            [
                1492003800000,
                141.6,
                142.15,
                141.01,
                141.8
            ],
            [
                1492090200000,
                141.91,
                142.38,
                141.05,
                141.05
            ],
            [
                1492435800000,
                141.48,
                141.88,
                140.87,
                141.83
            ]
            ]
        },{
      type: 'sma',
      linkedTo: 'mymain'
      }
      ]
    });

  }

}

如果我最后删除了与sma指标有关的部分,则主图表将按预期工作。有了它,它变成空白。

我不太了解如何将高位图表/指标/指标导入链接到图表。

我也尝试添加

<script src="https://code.highcharts.com/stock/indicators/indicators.js"></script>

转到主要index.html,但无济于事。

感谢您的任何帮助!

0 个答案:

没有答案