ng2-charts-schematics
Version:
ng2-charts schematics collection for generating chart components
51 lines (49 loc) • 1.76 kB
JavaScript
"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 lineChartData: ChartDataSets[] = [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
];
public lineChartLabels: Label[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
public lineChartOptions: ChartOptions = {
responsive: true,
};
public lineChartColors: Color[] = [
{
borderColor: 'black',
backgroundColor: 'rgba(255,0,0,0.3)',
},
];
public lineChartLegend = true;
public lineChartType: ChartType = 'line';
public lineChartPlugins = [];
constructor() { }
ngOnInit() {
}`;
const newMarkup = `<div style="display: block;">
<canvas baseChart width="400" height="400"
[]="lineChartData"
[]="lineChartLabels"
[]="lineChartOptions"
[]="lineChartColors"
[]="lineChartLegend"
[]="lineChartType"
[]="lineChartPlugins">
</canvas>
</div>
`;
const newImports = [
['ChartDataSets, ChartOptions, ChartType', 'chart.js'],
['Color, 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 ng2ChartsLine(_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.ng2ChartsLine = ng2ChartsLine;
//# sourceMappingURL=ng2-charts-line.js.map