Sunday, 21 March 2021

Export TABLE to PDF in Angular

We will be using jsPdf to export the Data.

Step 1:
  • npm install
  •  jspdf jspdf-autotable
  • npm install --save @types/jspdf
Step 2 : 

Add Scripts in Angular.json

"scripts": ["./node_modules/jspdf/dist/jspdf.min.js",
            "./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"]


Step 3 :

Check Package.json

dependencies:{
    
"jspdf""^2.3.1",
        "jspdf-autotable""^3.5.14",
}

devDependencies:{
    "@types/jspdf""^1.3.3",
}

Step 4: Actual Coding Starts:-

import the packages

import 'jspdf-autotable';
import { jsPDF } from 'jspdf';  

Write Method to export the table Data

In auto-table we need 2 things Column and row Data
dipslayColumn will be Array of element with all the column names

Eg :  displayedColumnsstring[] =
 [
    'patientId',
    'patientName',
    'dob',
    'gender',
    'screeningDate',
    'assignedClinician',
    'study',
    'studyVisit',
    'visitDate',
    'imagePath',
    'visitStatus',
    'review'];

Now Row Data(Array) should be array of Array

Eg: ["E1001","Sashi Yadav","30-07-1998","Male","12-03-2020","Dr. Rajesh",.....]

exportPdf() {
    var doc = new jsPDF("l""px");
    doc.setFontSize(18);
    doc.text('My PDF Table'118);
    doc.setFontSize(11);
    doc.setTextColor(100); (doc as any).autoTable(this.displayedColumnsthis.array)
    // Open PDF document in new tab
    doc.output('dataurlnewwindow')
    // Download PDF document  
    doc.save('table.pdf');

  } 

               

Friday, 29 January 2021

How to pass data between two components in angular

 Hello Guys, today in this blog we will learn how to pass data between components.

Suppose there is a component Customer Registration and Dashboard. We need to pass data from Customers to the Dashboard. We will have to create a service so that it will also the data sharing.

Ceate customer.service.ts


import { Injectable } from '@angular/core';
import { BehaviorSubjectObservable } from 'rxjs';
@Injectable()
export class CustomerRegistartionService {
    public RenewCount = new BehaviorSubject<number>(0);
    getRenewCount(): Observable<number> {
        return this.RenewCount.asObservable();

    }
    setRenewCount(valnumber) {
        this.RenewCount.next(val);
    }
    public Customer = new BehaviorSubject<any>([]);
    getCustomer():Observable<any>{
        return this.Customer.asObservable();
    }
    setCustomer(val:any){
        this.Customer.next(val);
    }
    public Revenue = new BehaviorSubject<any>([]);
    getRevenue():Observable<any>{
        return this.Revenue.asObservable();
    }
    setRevenue(val : any){
        this.Revenue.next(val)
    }
} 


Here we need to get and set the value which we need to pass
we use set from the source component and use get in the destination component.

THIS IS OUR SOURCE COMPONENT

GetCustomerList() {
        this.loading = true;
        this.http.get('api/CustomerRegistration/GetCustomerList')
            .subscribe(res => {
                this.CustomerList = res;
                this.findSum(this.CustomerList)
                this.custservice.setRenewCount(this.CustomerList.filter(a => a.Remaining <= 6).length);
                this.custservice.setCustomer(this.CustomerList);

                this.loading = false;
            }, err => {
                this.messageService.add({ severity: 'error'summary: 'Error Message'detail: err.error });
                this.loading = false;
            })
    }

THIS IS OUR DESTINATION

ngOnInit(){
        this.custservice.getRenewCount()
        .subscribe(val =>{
            this.count = val;
        })
        this.custservice.getCustomer()
        .subscribe(val=>{
            this.loading=true;
            this.customerval;
            console.log(this.customer)
            this.loading=false;
        })

Friday, 5 August 2016

Ultrasonic Range Meter

                                  Ultrasonic Range Meter

     
                  In this project, a Portable Ultrasonic Range Meter is designed which can be used to measure distance of a target in non-contact fashion. The project is based on Arduino, Ultrasonic Sensor and an LCD display.

Description: In this technique, a high frequency sound wave is transmitted by a transmitter and the reflected echo from a target is captured by a receiver.

As the velocity of the sound wave is known, by measuring the time of travel, the distance between the source and the target can be calculated.
Depending on the frequency of the sound wave, the SONAR can be either Infrasonic or Ultrasonic. Ultrasonic sensors produce sound waves with frequencies higher than the audible range (20Hz to 20 KHz) i.e. greater than 20 KHz. In case of an infrasonic sensor, the frequency of sound wave is less than 20Hz.

Hardware Required:

  • Arduino Uno
  • Ultrasonic Sensor HC-SR04
  • 16X2 LCD Display
  • 10KΩ POT

Circuit Diagram:


Code:


 #include <LiquidCrystal.h>
#define trigPin 10
#define echoPin 13
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

}
void loop() {
  float duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) * 0.0344;

  if (distance >= 400 || distance <= 2){
    lcd.print("Out of range");
    delay(500);
  }
  else {
    lcd.print(distance);
    lcd.print(" cm");
    delay(500);
  }
  delay(500);
  lcd.clear();
}



That's the end of this cool project session. Hope you liked it. If you think it was good, then do comment and share this post and do post your pictures if you have made them. Do not forget to comment or ask any questions if you have any doubt.And stay tuned for my next cool posts on electronics ;)
Thanks for watching :)

Bubye...take care and all the very best to all.

Friday, 25 March 2016

How to make a led VU meter..!!!!!



                                            LED VU METER

This is a cool LED project I am undertaking. The heart of this project is using the LM3915N (or similar) LED driver. Once completed this can be connected to your sound card or can be connected via a 3.5mm jack for some really cool effects to light up your room. I connected this via 2x4.5v rechargeable battery.
                   Lets 1st get to know more about this cool projects,that what exactly is this vu meter and how does it works.

DESCRIPTION:We can consider the Volume Meter as an Equalizer, which is present in the Music systems. In which we can see the dancing of lights (LEDs) according to the music, if the music is loud, equalizer reaches to its peak and in low music it remains Low. We have built a Volume Meter or VU meter, with the help of LM3915, which glows the LEDs as per strength of the sound, if sound is low, lesser LEDs will glow, and if sound is High more LEDs will glow, check the Video at the end ,I will provide you the link. VU meter also serves as a volume measurement device.

COMPONENTS REQUIRED:

1. 20LED'S(red,blue,green,yellow)
2. LM3915 IC
3.10K pot
4.1k resistor
5. Power supply 5v or 9v(battery)

Leds VU meter





PIN CONFIGUARATION(LM3915):

CIRCUIT DIADRAM:



AFTER COMPLETION:



So you're done making your own music reactive color changing lights! Now you just have to connect it to an audio device, play some good music and watch the lights glowing in the dark changing their colors with every beat.Your friends would surely be jealous with such a cool thing!
This makes the end of this post. Hope you liked it. Please share if you think it was awesome. Don't forget to follow for more cool projects!
You can even follow my facebook page https://www.facebook.com/technoboticss/?ref=bookmarks 
And for the video demonstration you can subscribe to my youtube channel https://www.youtube.com/channel/UCW4PLi-ObJt3m6YTSEQY3gw

THANKYOU..!!!!!
Bubye take care and STAY CREATIVE ;)

Wednesday, 24 February 2016

How to make your own homemade amplifier by using LM386

                        PORTABLE SPEAKER

uuhhmm....an amplifier,i think is quite interesting while making an amplifier which gives us maximum output.


so why not we all should make it by our own :)


Speakers can be a better and awesome option to listen together. But the problem comes when you have to carry those large, bulky speakers in your suitcase or backpack which should not be a good idea. They are expensive and need to be plugged to an external power supply which is not available everywhere. Portable speakers can be a better option but they are too expensive and some of them do not have that loud and clear sound. Why don't make your own portable- battery operated and solar powered speakers that has sound much louder and better quality than normal portable speakers? This post will guide you the same thing.

So i will show you all the steps that required to make an amplifierby using LM386.


SO LET'S GET STARTED.......................


First of all you all must know about the IC which we are going to use for making the amplifier.


LM386 is a low voltage audio amplifier and frequently used in battery powered music devices like radios, guitars, toys etc. The gain range is 20 to 200, gain is internally set to 20 (without using external component) but can be increased to 200 by using resistor and capacitor between PIN 1 and 8, or just with a capacitor. Voltage gain simply means that Voltage out is 200 times the Voltage IN. LM386 has a wide supply voltage range 4-12v. Below is the Pin diagram of LM386.


3.5mm audio jack.

Audio Amplifier LM386 Pinout

Parts:

  1. 1xLM386
  2. 1x10k pot
  3. 1x220 or 250uf capacitor
  4. 0.05uf capacitor
  5. 1x10uf capacitor
  6. 1x10ohm resistor
  7. 1x3.5mm jack
  8. speaker (4 to 16ohm)


Circuit Diagram:



The input is given to the audio jack wire.
The 10k pot is used to control the volmume.



NOTE: Do not increase the value of capacitor more than 10uf which is connected between 1 and 8


Finally this brings this post to an end. Enjoy the sound of your own do it yourself speakers while traveling or camping. Use it to watch movies on your laptop or your mobile at night with high quality and loud sound.
If you have any doubt related to this project or found an error, feel free to comment or ask a question. Do post your pictures if you've made one yourself or did some modifications.
So that's it for today,hope you all like it.
Stay tuned for my next post.
Thankyou very much:)
good bye take care :) 

Sunday, 21 February 2016