无法使用Ionic3 / 2显示图表

时间:2018-02-11 04:59:58

标签: angular ionic-framework charts highcharts ionic2

您好我试图使用高级图表显示静态数据,我收到错误13,我放置了这个

<div id="container" style="display: block;" ></div>

在html文件中,下面是我用来显示图表的数据

import * as HighCharts from 'highcharts';

ionViewDidLoad(){
    var myChart = HighCharts.chart('container', {
      chart: {
        type: 'bar'
      },
      title: {
        text: 'Fruit Consumption'
      },
      xAxis: {
        categories: ['Apples', 'Bananas', 'Oranges']
      },
      yAxis: {
        title: {
          text: 'Fruit eaten'
        }
      },
      series: [{
        name: 'Jane',
        data: [1, 0, 4]
      }, {
        name: 'John',
        data: [5, 7, 3]
      }]
    });
  }

是否有更好的离子图表库用于显示chart.js以外的图表

2 个答案:

答案 0 :(得分:1)

有一个名为 angular2-highcharts

的angular2包
import { ChartModule } from 'angular2-highcharts';

和选项为,

class AppComponent {
    constructor() {

        this.options = {
            chart: {
                type: 'bar'
            },
            title: {
                text: 'Fruit Consumption'
            },
            xAxis: {
                categories: ['Apples', 'Bananas', 'Oranges']
            },
            yAxis: {
                title: {
                    text: 'Fruit eaten'
                }
            },
            series: [{
                name: 'Jane',
                data: [1, 0, 4]
            }, {
                name: 'John',
                data: [5, 7, 3]
            }]
        };
    }
    options: Object;
}

DEMO

答案 1 :(得分:1)

检查官方highcharts#typescript

stackblitz演示

SftpMessageHandler.setLogging(false)