I am unable to get the Chart component of the Telerik UI Pro to work with webpack/AoT both on iOS/Android (I am also using the side drawer in the same app which is working just fine). I followed the instructions in the docs for angular and webpack is compiling fine, but the chart just doesn't display (without webpack it works fine).
This is my app.module.ts
import {NgModule, NO_ERRORS_SCHEMA} from
"@angular/core"
;
import {NativeScriptHttpModule} from
"nativescript-angular/http"
;
import {NativeScriptModule} from
'nativescript-angular'
;
import {NativeScriptFormsModule} from
'nativescript-angular/forms'
;
// needed for two-way binding in textfields
import {NativeScriptUISideDrawerModule} from
'nativescript-telerik-ui-pro/sidedrawer/angular'
;
import {NativeScriptUIChartModule} from
'nativescript-telerik-ui-pro/chart/angular'
;
import {ModalDialogService} from
"nativescript-angular/modal-dialog"
;
import {AppRoutingModule} from
"./app.routing"
;
/* Declarations */
import {AppComponent} from
"./app.component"
;
import {DashboardPage} from
'./pages/dashboard'
;
import {DefectsPage} from
'./pages/defects'
;
import {DashboardCycleComponent} from
'./components/dashboard-cycle'
;
import {DonutChartComponent} from
'./components/donut-chart'
;
import {LoginPage} from
'./pages/login'
;
import {ProjectContainerPage} from
"./pages/project-container"
;
import {ProjectsOverviewPage} from
"./pages/projects-overview"
;
import {SearchFilterPipe} from
'./pipes/search-filter'
;
import {TestStepsReadyPage} from
'./pages/test-steps-ready'
;
import {TestStepDetailsPage} from
'./pages/test-step-details'
;
/* Providers */
import {BackendProvider} from
"./providers/backend"
;
import {ConfigProvider} from
"./providers/config"
;
import {EventsProvider} from
'./providers/events'
;
import {SessionProvider} from
"./providers/session"
;
@NgModule({
declarations: [
AppComponent,
DashboardCycleComponent,
DashboardPage,
DefectsPage,
DonutChartComponent,
LoginPage,
ProjectContainerPage,
ProjectsOverviewPage,
SearchFilterPipe,
TestStepsReadyPage,
TestStepDetailsPage,
],
bootstrap: [AppComponent],
entryComponents: [
],
imports: [
AppRoutingModule,
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptUISideDrawerModule,
NativeScriptUIChartModule
],
providers: [
BackendProvider,
ConfigProvider,
EventsProvider,
SessionProvider
],
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule { }
This is the component that should display the donut chart:
import {Component,Input} from
'@angular/core'
;
//import {RadPieChartComponent,RadLegendViewDirective} from 'nativescript-telerik-ui-pro/chart/angular';
import {SessionProvider} from
'../providers/session'
;
@Component({
selector:
'DonutChart'
,
template: `
<RadPieChart height=
"150"
allowAnimation=
"true"
row=
"1"
>
<DonutSeries tkPieSeries selectionMode=
"DataPoint"
[items]=
"convertCycleDataForPieChart()"
valueProperty=
"value"
legendLabel=
"label"
outerRadiusFactor=
"0.9"
innerRadiusFactor=
"0.7"
expandRadius=
"0.1"
>
</DonutSeries>
<RadLegendView tkPieLegend position=
"Left"
offsetOrigin=
"TopRight"
width=
"150"
></RadLegendView>
</RadPieChart>
`
})
export class DonutChartComponent {
@Input() public cycle:any = undefined;
@Input() private type:string =
'tests'
;
// possible values: 'tests', 'steps', 'defects', 'issues'
constructor(private session: SessionProvider) {
}
/*
Convert data from the projectProgress API call to Pie Chart data
*/
public convertCycleDataForPieChart() {
console.log(
'reached convertCycleDataForPieChart'
);
let returnArr:Array<any> = [];
// enumate over all type object keys and create their labels
for
(let key
in
this
.cycle[
this
.type]) {
// ensure property name is member of object instead of inherited from prototype chain
if
(
this
.cycle[
this
.type].hasOwnProperty(key)) {
returnArr.push({
/* PieChart does not support label values on iOS so we add the numbers to the labels */
label: (
this
.session.platform===
'ios'
?
this
.cycle[
this
.type][key]+
' '
:
''
) +
key,
value:
this
.cycle[
this
.type][key]
});
}
}
console.dump(returnArr);
return
returnArr;
}
}
When running the bundle that webpack produces, I do see the 'reached convertCycleDataForPieChart' printed to the console, which seems to indicate that the DonutSeries directive is being processed right? Also the dump of the items data seems to be correct (and the same as with the non-webpack bundle that works properly):
[
{
"label"
:
"39 In Progress"
,
"value"
: 39
},
{
"label"
:
"4 Failed"
,
"value"
: 4
},
{
"label"
:
"234 Passed"
,
"value"
: 234
},
{
"label"
:
"890 Out Of Scope"
,
"value"
: 890
},
{
"label"
:
"789 Not Run"
,
"value"
: 789
}
]
Any idea what might be going on?
Thanks!