UNPKG

ng2-charts-schematics

Version:

ng2-charts schematics collection for generating chart components

43 lines (41 loc) 1.51 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 pieChartOptions: ChartOptions = { responsive: true, }; public pieChartLabels: Label[] = ['Download Sales', 'In-Store Sales', 'Mail Sales']; public pieChartData: SingleDataSet = [300, 500, 100]; public pieChartType: ChartType = 'pie'; public pieChartLegend = true; public pieChartPlugins = []; constructor() { } ngOnInit() { }`; const newMarkup = `<div style="display: block;"> <canvas baseChart [data]="pieChartData" [labels]="pieChartLabels" [chartType]="pieChartType" [options]="pieChartOptions" [plugins]="pieChartPlugins" [legend]="pieChartLegend"> </canvas> </div> `; const newImports = [ ['ChartOptions, ChartType', 'chart.js'], ['Label, SingleDataSet', 'ng2-charts'], ]; // You don't have to export the function as default. You can also have more than one rule factory // per file. function ng2ChartsPie(_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.ng2ChartsPie = ng2ChartsPie; //# sourceMappingURL=ng2-charts-pie.js.map