GithubHelp home page GithubHelp logo

andrewjbateman / angular-data-charts Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 11.04 MB

:clipboard: The Coronavirus API this app is based on no longer exists. Covid-19 data was displayed using angular-google-charts module. Covid data/news from api.coronatracker.com was shown in mat-cards.

License: MIT License

JavaScript 2.42% TypeScript 60.92% HTML 28.18% CSS 7.40% SCSS 1.08%
angular-material navbar scss-styles scss angular-data-charts google-charts covid-data mat-cards user-country angular

angular-data-charts's Introduction

โšก Angular Data Charts

  • The Coronavirus API this app is based on no longer exists
  • This is a responsive Angular app that displayed Covid API data & news for the user country and worldwide. Data was displayed using google-charts and Angular Material tables/display components.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

๐Ÿ“„ Table of contents

๐Ÿ“š General info

  • General: Chart data from Corona API JSON time-series of coronavirus cases (confirmed, deaths and recovered) per country. Detects user location and shows data from that country.
  • Home Page: World and local Covid data - using iPapa API to detect user country. Data shown in tables on Mat-cards and on Google charts using tab-groups to select between confirmed cases, deaths and recovered.
  • Countries Page: Covid data is fetched from local storage and displayed using a Mat-Table of countries.
  • News & NewsDetail Pages: Covid news data is shown on Mat-cards. The Day.js npm module is used to convert the UTC format date into '... ago'. Clicking on a news card will route the user to a news detail page with the JSON data passed using angular router navigation extras. The Coronatracker API does not have a lot of the latest news but it demonstrates a working app.
  • Charts Page Pie and column charts using angular-google-charts.
  • About Page: Mat-cards show details of each page with useful links.
  • Contact Page: Mat-card with Github and contact details from the Github API (no API access key required for this).

๐Ÿ“ท Screenshots

Example screenshot Example screenshot Example screenshot Example screenshot Example screenshot Example screenshot Example screenshot Example screenshot

๐Ÿ“ถ Technologies

๐Ÿ’พ Setup

  • Install dependencies by running npm i
  • Run ng test for Jasmine tests carried out in Karma console
  • 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
  • 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
  • Deploy using firebase deploy

๐Ÿ”ฆ Testing

  • Run ng test to execute the unit tests via Karma.
  • Run ng e2e to execute the end-to-end tests via Protractor.

๐Ÿ’ป Code Examples

  • extract from covid-news.component.ts to subscribe to news API data and store it in local storage.
// subscribe to news API data observable
getCovidNews(): void {
  this.covidDataService.getCovidNews().subscribe((data: NewsItems) => {
    this.storageService.set("totalNewsItems", data.total);
    this.storageService.set("storedNewsItems", data.items);
    this.newsItems = this.storageService.get("storedNewsItems");
  });
}

 // create news API observable
getCovidNews(): Observable<NewsItems> {
  this.newsArrayLength = 20;
  this.storageService.set('newsArrayLength', this.newsArrayLength);
  this.userCountry = this.storageService.get('userCountryData').name;
  return this.http
    .get<NewsItems>(
      apiNewsBaseUrl +
        `?limit=${this.newsArrayLength}&offset&country=${this.userCountry}`
    )
    .pipe(
      // tap((data: NewsItems) => console.log('news data', data)),
      map((data: NewsItems) => data),
      catchError((err) => {
        return throwError(() => new Error('News Item data not found, error: '));
      })
    );
}

๐Ÿ†’ Features

  • Separate Material module with all Material modules accessed via Shared module - review this decision!
  • Detects user location data during the Home page ng 'on initialisation' lifecycle using a simple API GET request via the location.service.ts file.

๐Ÿ“‹ Status & To-Do List

  • Status: This was a working app until the Coronavirus API was removed. This code could be adapted to a new API.
  • To-Do: Nothing. Consider Archiving.

๐Ÿ‘ Inspiration

๐Ÿ“ License

  • This project is licensed under the terms of the MIT license.

โœ‰๏ธ Contact

angular-data-charts's People

Contributors

andrewjbateman avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.