Code Monkey home page Code Monkey logo

chart-amexio's Introduction

Datagrid

This project was generated with Angular CLI version 6.0.8.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

npm install -g @angular/cli
ng new charts
ng serve
npm install amexio-ng-extensions --save

At first create a angular project and install the library amexio-ng-extensions. Import AmexioChartsModule, AmexioWidgetModule from this library in app.module.ts.

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { EmployeeService } from './employee.service';

// Import your library
import { AmexioChartsModule, AmexioWidgetModule } from 'amexio-ng-extensions';
import { BarchartComponent } from './barchart/barchart.component';
import { PiechartComponent } from './piechart/piechart.component';
import { CandlestickchartComponent } from './candlestickchart/candlestickchart.component';
import { DonutchartComponent } from './donutchart/donutchart.component';
import { AreachartComponent } from './areachart/areachart.component';
import { ScatterchartComponent } from './scatterchart/scatterchart.component';
import { CombochartComponent } from './combochart/combochart.component';
import { BubblechartComponent } from './bubblechart/bubblechart.component';


@NgModule({
  declarations: [
    AppComponent,
    BarchartComponent,
    PiechartComponent,
    CandlestickchartComponent,
    DonutchartComponent,
    AreachartComponent,
    ScatterchartComponent,
    CombochartComponent,
    BubblechartComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    AmexioChartsModule,
    AmexioWidgetModule
    ],
  providers: [EmployeeService],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html

<div class="container-fluid">

  <h1 align="center">Chart using Amexio Plugin</h1>
  <app-barchart></app-barchart>
  <app-piechart></app-piechart>
  <app-candlestickchart></app-candlestickchart>
  <app-donutchart></app-donutchart>
  <app-areachart></app-areachart>
  <app-scatterchart></app-scatterchart>
  <app-bubblechart></app-bubblechart>
  <app-combochart></app-combochart>

</div>

Create a employee service and fetch the json data. Import the service in chart component.

employee.service.ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable} from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class EmployeeService {

  constructor(private http:HttpClient) { }

  url :string = "https://raw.githubusercontent.com/piyalidas10/Chart-Amexio/master/src/app/employee.json";

  allEmployees(): Observable<any>{
    return this.http.get(this.url);
  }


}

employee.json

{  
    "employees":[
      {  
          "preferredFullName":"Tom Hanks",
          "salary":14000000
       },
       {  
          "preferredFullName":"Ketan Gote",
          "salary":22000000
       },
       {  
          "preferredFullName":"Santosh Gawade",
          "salary":22000000
       },
       {  
          "preferredFullName":"Dattaram Gawas",
          "salary":1000000
       },
       {  
          "preferredFullName":"Pratik Kelwalkar",
          "salary":1500000
       }
    ]    
 }

Convert JSON to JSON Array using the following function. You have to convert JSON to JSOn array to implement the chart.

jsonToArray(val){
    var arr = [];
    var arrColumnLength = 0;
    if (val.length > 0){ 
        //get field/column name from JSON
        var arrColumn = [];
        for(var key in val[0]){
          arrColumn.push(key);
        } 
        arrColumnLength = Object.keys(val[0]).length;
       Object.keys(val).forEach(function(key) { 
        var arrVal = [];         
         for(var i=0;i<arrColumnLength;i++){
          arrVal.push(val[key][arrColumn[i]]);
         }              
         arr.push(arrVal);                
       }); 
       arr.unshift(arrColumn); 
    }
    return arr;
  }

chart-amexio's People

Contributors

piyalidas10 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.