Giter Club home page Giter Club logo

fama-dashboard's Introduction

FAMA Dashboard

Dev Setup

# install dependencies
$ npm install

# serve Nuxt app with hot reload at localhost:3000
$ npm run dev

# serve standalone Express app in /api with hot reload at localhost:4000
$ npm run dev:express

Production Build Setup

# install dependencies
$ npm install

# build and optimize your application with webpack
$ npm run build

# launch server
$ npm run start

# or launch server in the background
$ npm run pm2:start

CSV GroupBy in JavaScript

Source CSV

State Month Quantity
Johor Jan 240
Johor Feb 260
Johor Feb 300
Penang Jan 200

JavaScript Code

const data = [
  {
    State: "Johor",
    Month: "Jan",
    Quantity: 240
  },
  {
    State: "Johor",
    Month: "Feb",
    Quantity: 260
  },
  {
    State: "Johor",
    Month: "Feb",
    Quantity: 300
  },
  {
    State: "Penang",
    Month: "Jan",
    Quantity: 200
  }
];

const formattedData = data.reduce((result, { State, Month, Quantity }) => {
  // init empty object if not there
  result[State] = result[State] || {};
  // init empty object if not there
  result[State][Month] = result[State][Month] || {};
  // init zero if not there
  result[State][Month].Quantity =
    Quantity + (result[State][Month].Quantity || 0);

  return result;
}, {});

Formatted Data Output

{
  "Johor": {
    "Jan": {
      "Quantity": 240
    },
    "Feb": {
      "Quantity": 560
    }
  },
  "Penang": {
    "Jan": {
      "Quantity": 200
    }
  }
}

fama-dashboard's People

Contributors

raaedkabir avatar

Watchers

 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.