Topic: Angular LineChart
FuzzeWuzze free asked 6 years ago
zerolds free answered 5 years ago
you can also do this:
npm install chart.js --save
and then in the angular.json file after architect node in build, there is a place where you can add scripts and add :
"scripts": [ "node_modules/chart.js/dist/Chart.bundle.min.js" ]
CaRniFeXeR free answered 5 years ago
any update on this specific issue?
Damian Gemza staff commented 5 years ago
Dear @CaRniFeXeR
Could you please provide me with reproduction steps of this problem? Also, if you could describe your problem, it would be great.
Best Regards,
Damian
nate pro answered 6 years ago
Damian Gemza staff commented 6 years ago
Dear machiinate, thanks for your informations. We will take a look at this. Best Regards, DamianDamian Gemza staff answered 6 years ago
- To shared.component.html i've pasted html code of line chart,
- To shared.component.ts i've pasted ts code of line chart,
- In app.module.ts i've imported SharedComponent, RouterModule and Routes.,
- Then in app.module.ts i've created const approuter: Routes = [{path: 'shared', component: SharedComponent}],
- Again in app.module.ts in imports array i've imported RouterModule.forRoot(approuter),
- In app.component.html i've created a button with code: <a routerLink="/shared"><button class="btn btn-primary waves-light" mdbRippleRadius>Chart</button></a>, and below this button <router-outlet></router-outlet>
<div class="row"> <divclass="col-md-6 mx-auto my-5"> <divstyle="display: block"> <canvasmdbChart [chartType]="chartType" [datasets]="chartDatasets" [labels]="chartLabels" [colors]="chartColors" [options]="chartOptions" [legend]="true" (chartHover)="chartHovered($event)" (chartClick)="chartClicked($event)"> </canvas> </div> </div> </div>
import { Component } from '@angular/core'; @Component({ selector:'app-shared', templateUrl:'./shared.component.html', styleUrls: ['./shared.component.scss'] }) export class SharedComponent { publicchartType:string='line'; publicchartDatasets:Array<any> = [ { data: [65, 59, 80, 81, 56, 55, 40], label: 'My First dataset' }, { data: [28, 48, 40, 19, 86, 27, 90], label: 'My Second dataset' } ]; publicchartLabels:Array<any> = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul']; publicchartColors:Array<any> = [ { backgroundColor:'rgba(220,220,220,0.2)', borderColor:'rgba(220,220,220,1)', borderWidth:2, pointBackgroundColor:'rgba(220,220,220,1)', pointBorderColor:'#fff', pointHoverBackgroundColor:'#fff', pointHoverBorderColor:'rgba(220,220,220,1)' }, { backgroundColor:'rgba(151,187,205,0.2)', borderColor:'rgba(151,187,205,1)', borderWidth:2, pointBackgroundColor:'rgba(151,187,205,1)', pointBorderColor:'#fff', pointHoverBackgroundColor:'#fff', pointHoverBorderColor:'rgba(151,187,205,1)' } ]; publicchartOptions:any= { responsive:true }; publicchartClicked(e:any):void { } publicchartHovered(e:any):void { } }
import { BrowserModule } from '@angular/platform-browser'; import { MDBBootstrapModules } from 'ng-mdb-pro'; import { ToastModule } from './../../node_modules/ng-mdb-pro/pro/alerts/toast/toast.module'; import { MDBSpinningPreloader } from 'ng-mdb-pro'; import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import { SharedComponent } from './shared/shared.component'; import { RouterModule, Routes } from '@angular/router'; const approute: Routes = [{ path:'shared', component:SharedComponent }]; @NgModule({ declarations: [ AppComponent, SharedComponent ], imports: [ BrowserModule, BrowserAnimationsModule, MDBBootstrapModules.forRoot(), ToastModule.forRoot(), FormsModule, RouterModule.forRoot(approute) ], providers: [MDBSpinningPreloader], bootstrap: [AppComponent], schemas: [ NO_ERRORS_SCHEMA ] }) export class AppModule { }
<a routerLink="/shared"><button class="btn btn-primary waves-light" mdbRippleRadius>Wykres</button></a> <router-outlet></router-outlet>
nate pro commented 6 years ago
could you guys please add a fix to this in the next release?FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- ForumUser: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No