Giter Club home page Giter Club logo

covid19-animation-generator's Introduction

COVID-19 Animation Generator

Node.js CI

Generates an animation based on COVID-19 daily data.

Sample

About

Requirements

  • Node 18.x
  • GNU make

Initialize

  • Run: npm install

Build

  • Run: make

Running

node dist/main

The data is downloaded automatically

Parameters

All parameters are optional.

  • --help: Displays a help message and exits.
  • --source: Sets the data source. Default: global. See the contents of config.json, section dataSources, for possible values.
  • --filter: Filters the series configurations from the datasource using its code. Multiple codes can be included, separated by comma.
  • --schema: Sets the color schema. Default: dark. Possible values:
    • dark: Dark theme
  • --days: Number of days for which the animation will be generated. Default: 30. Use 0 to plot all days.
  • --frames: Number of frames per day. Default: 30.
  • --extraFrames: Number of extra frames for the last image. Default: 300.
  • --horizontalAxisLabel: Horizontal axis label. Default: "total confirmed cases (log)".
  • --verticalAxisLabel: Vertical axis label. Default: "new confirmed cases (log, last week)".
  • --zoomEasing: Easing function for the zoom effect. Default: easeInOutCubic.
  • --timebarEasing: Easing function for the timebar. Default: linear.
  • --dateFormat: Sets the date format based on the Luxon tokens. Default: yyyy-MM-dd.
  • --drawMarkers: Draws series markers over the scale. Disabled by default.
  • --skipZoom: Skips the zoom effect. Enabled by default.
  • --hideWatermark: Hides the watermark. Enabled by default.
  • --seriesLineWidth: Series line width. Default: 3.
  • --horizontalMin: Horizontal scale minimum. Default: dynamic.
  • --horizontalMax: Horizontal scale maximum. Default: dynamic.
  • --verticalMin: Vertical scale minimum. Default: dynamic.
  • --verticalMax: Vertical scale maximum. Default: dynamic.
  • --scale: Scale. Default: log. Possible values:
    • log: Logaritmic (log10)
    • linear: Linear scale
    • linear-center: Linear scale for stacked area center
    • linear-avg7: Liner scale with 7 days change average
  • --scaleDateFormat: Date format for the scale labels. Applies only for linear scale. Default: MM/dd.
  • --scaleNumberFormat: Number format for the scale labels. Applies only for linear scale. Default: suffix. Possible values:
    • suffix: 1K for 1,000, 2K for 2,000, etc
    • plain: Plain number
    • spanish: Number in Spanish format (#.###)
  • --stackedAreaNumberFormat: Number format for the stacked area number label. Default: plain. Possible values:
    • plain: Plain number
    • english: Number in English format (#,###)
    • spanish: Number in Spanish format (#.###)
  • --stackedAreaIncludePercentage: Include percentage in the stacked area label. Default: true. Possible values:
    • true: Display the percentage
    • false: Do not display the percentage
  • --horizontalJump: Distance between scale labels (horizontal axis).
  • --verticalJump: Distance between scale labels (vertical axis).
  • --horizontalLines: Horizontal lines with format numericvalue:label (example: 10:mylabel, multiple lines separated by comma)
  • --verticalLines: Vertical lines with format numericvalue:label (example: 10:mylabel, multiple lines separated by comma)
  • --singleDynamicScale: Use single axis to calculate the dynamic scale.
  • --type: Chart type. Default: line. Possible values:
    • line: Line chart
    • stacked-area: Stacked area
  • --outputDirectory: Output directory. If the value starts with /, it will be read as an absolute path. Otherwise, it will be relative to the project root. Default value: output.
  • --debug: Prints debugging information to the console and the output images.
  • --sample: Overrides frame configuration to output only one frame as a sample.
  • --useAreaColor: Uses areaColor instead of color to draw line graphs.

Examples

  • node dist/main
  • node dist/main --source global
  • node dist/main --layout square
  • node dist/main --source us --layout vertical
  • node dist/main --source us --layout vertical --frames 20

Output

The generated images will be in the output directory

Generate animation

You can generate an animation (60 fps). Requires ffmpeg. Run:

npm run video

The video will be here: output/animation.mp4

If you used --outputDirectory to generate the images, you can pass the directory path to the video script as:

npm run video -- /tmp/some/temporary/directory

covid19-animation-generator's People

Contributors

juancri avatar pescap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

covid19-animation-generator's Issues

Add License

  • Add a explicit license (MIT)
  • Include badge

RNE Araucania

Angol
Victoria
Temuco
Padre Las Casas
Villarrica
Loncoche
Gorbea
Carahue
Saavedra

Move scale operations to pre processors

Some scale operations, like 7-day moving average, are part of the scale definition. Other dimensions can be added, incrementing the complexity of these scales.

We should move all these operations to be (pre) processors.

Add fps parameter

We have parameters for frames per day and extra frames but other animations steps, like the zoom, are hard coded as a frame number. We could use an FPS parameter to avoid the need of having to specify frame numbers.

This also may help when running npm run video if this script could receive the fps parameter as well.

Improve README

README.md references "convert" but then it states that ffmpeg and parallel are required to generate the video. This can be improved.

Highlight individual series

There could be an animation to highlight individual series after the main animation has finished.

This highlight would mean to make other series transparent or gray scale in order to have a better picture of the series being highlighted.

Automate help

Add possible values and default automatically when using --help

Support multiple scales

Right now, the scale for each axis is determined by the way we process the time series. Log10PlotPointsGenerator sets the scale to be used.

We could have some way to define a different scale if needed. Examples:

  • Linear
  • Log10
  • Log10(today - 7 days)
  • Date

Fix vertical layout

The watermark is misplaced.
Probably an issue when rotating to draw the vertical axis label.

Make objects immutable

To avoid issues, we should make plain objects immutable.

For example, all pre-processors should return new series instead of overwriting values.

Test por día

Hola, muchas gracias por tu página. ¿es posible realizar un gráfico con la comparación de los test realizados por día en distintos países?

Add milestones

  • Add milestones to master
  • Milestones could be defined in the series config

Daily summary photo

Generate a daily summary photo right after the Chilean daily report (around 10AM).

It should include:

  • Graphs
    • ICU
    • CPU Hospitalizations
    • Deaths
    • Cases
  • Picture: Deaths every x seconds
  • Big numbers:
    • New / total cases
    • New / total deaths

Typo en FAQ

Dice “ en Chile no se realiza un examen PCR de

saluda

”.

Creo que debiera decir “salida”.

Use temporary directory

Use a temporary directory to store the images. This will allow multiple instances of the software to run in parallel without overwriting other instances images.

Add source to the image

Having different data sources, it would be good (and nice to the sources) to include them in the generated image

Linear scale is broken

Linear scales produces an empty animation. Example

node dist/main.js \
  --scale linear \
  --days 1 \
  --verticalMin 0 --verticalMax 1000000 --verticalJump 100000 \
  --horizontalMin 100 --horizontalMax 200 --horizontalJump 30 \
  --skipZoom \
  --extraFrames 0

Evaluate if series labels should be restricted to the plot area

Currently, series labels are restricted to the plot area. This forces us to extend the scale just to provide space for the series labels. This should not be really necessary when there's enough space at the right margin of the plot area for the labels to be rendered.

Split ImageGenerator

ImageGenerator, right now, is a class that knows too much and does too much. We can split it so a main class could just plug layer drawing classes and use them to generate the final image.

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.