我正在尝试使用NG2-Charts的基本示例(http://valor-software.com/ng2-charts/)
我复制粘贴HTML部分
<div style="display: block">
<canvas baseChart
[datasets]="barChartData"
[labels]="barChartLabels"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="barChartType"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
和TypeScript部分
private barChartOptions: any = {
scaleShowVerticalLines: false,
responsive: true
};
private barChartLabels: string[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
private barChartType: string = 'bar';
private barChartLegend: boolean = true;
private barChartData: any[] = [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' } …Run Code Online (Sandbox Code Playgroud) 版本:Cordova:6.3.1,Gulp CLI:1.2.2,离子框架:2.0.0-rc.0,Ionic CLI版本:2.1.0
我在ionic2应用程序中使用ng2-charts.
进口不受import {ChartsModule} from "ng2-charts";
而是import {ChartsModule} from "ng2-charts/components/charts/charts;"因为这个(问题#440)
我的整个app.module.ts
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { ChartsModule } from 'ng2-charts/components/charts/charts';
import { MyApp } from './app.component';
import { EventsPage } from '../pages/events/events.component';
import { ChartComponent } from '../pages/chart/chart.component';
import { APICaller } from '../services/APICaller.service';
import { EventDetailComponent } from '../pages/event-detail/event-detail.component';
import { ParticipantDetail } from '../pages/participant-detail/participant-detail.component';
import { ParticipantFeedComponent } from …Run Code Online (Sandbox Code Playgroud)