I want to change ngx chart by changing it from Dom and insert the new one within property binding, however changing Dom is done by [innerHTML]=stringVar; but if inside of my stringVar was ngx-chart element it's not rendering it.
import { Component, OnInit } from '@angular/core';
import { NgxChartsModule } from '@swimlane/ngx-charts';
import { single, multi } from '../../shared/data';
import { CHARTS } from '../../shared/mock-charts';
@Component({
selector: 'app-chart-graph',
template: '<div [innerHTML]="ChartGraph"></div>',
styleUrls: ['./chart-graph.component.css']
})
export class ChartGraphComponent implements OnInit {
ChartGraph = `<ngx-charts-bar-vertical
[view]="view"
[scheme]="colorScheme"
[results]="single"
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[legend]="showLegend"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[xAxisLabel]="xAxisLabel"
[yAxisLabel]="yAxisLabel"
(select)="onSelect($event)">
</ngx-charts-bar-vertical>`;
single: any[];
multi: any[];
CHARTS: any[];
// options
showXAxis = true;
showYAxis = true;
gradient = false;
showLegend = true;
showXAxisLabel = true;
xAxisLabel = 'Country';
showYAxisLabel = true;
yAxisLabel = 'Population';
colorScheme = {
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA']
};
constructor() {
Object.assign(this, { single, multi });
}
onSelect(event) {
console.log(event);
}
ngOnInit() {
}
}