UNPKG

ng2-charts-schematics

Version:

ng2-charts schematics collection for generating chart components

47 lines (44 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const ng2_process_tree_1 = require("./ng2-process-tree"); const newCode = `public barChartOptions: ChartOptions = { responsive: true, }; public barChartLabels: Label[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012']; public barChartType: ChartType = 'bar'; public barChartLegend = true; public barChartPlugins = []; public barChartData: ChartDataSets[] = [ { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' }, { data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' } ]; constructor() { } ngOnInit() { }`; const newMarkup = `<div style="display: block;"> <canvas baseChart [datasets]="barChartData" [labels]="barChartLabels" [options]="barChartOptions" [plugins]="barChartPlugins" [legend]="barChartLegend" [chartType]="barChartType"> </canvas> </div> `; const newImports = [ ['ChartDataSets, ChartOptions, ChartType', 'chart.js'], ['Label', 'ng2-charts'], ]; // You don't have to export the function as default. You can also have more than one rule factory // per file. function ng2ChartsBar(_options) { // console.log('options', _options); return schematics_1.chain([ schematics_1.externalSchematic('@schematics/angular', 'component', _options), (tree, _context) => ng2_process_tree_1.ng2ProcessTree(tree, _context, _options, newCode, newMarkup, newImports) ]); } exports.ng2ChartsBar = ng2ChartsBar; //# sourceMappingURL=ng2-charts-bar.js.map