Giter Club home page Giter Club logo

histogram's Introduction

A Simple Histogram.

By Farbod Ghiasi.

๐Ÿ”ง Technologies & Tools

Description

This is a minimalistic and extensible Canvas API that renders a Histogram. It is written in JavaScript without dependency on third-party libraries.

Running

Clone the repository or download index.html, style.css, and script.js all in one directory and then open the index.html file in your favorite browser.

Features

  • Acceptable input format must be comma-delimited list of values.
  • The histogram is accurate no more than 2 decimal on x-axis.
  • It accepts positive and negative floating points as input up to any decimal points.
  • The histogram generates dynamic numbers of bars based on The Rice Rule is presented as a simple alternative to Sturges' rule.
  • The Rice Rule dictates the number of bars to be floor(2 * cubic root of number of data points).
  • It is responsive on smaller or larger screens.

Quickstart

  • To play around with the Histogram, open the index.html file on your browser: This will take you to an URL that looks like this on your browser and the home page with randomly generated histogram is shown as follows:
    https://localhost:PORT/src/index.html
    


  • To reset the Histogram click in reset and the histogram will be reset.



  • Enter your desired comma-delimited list of values in the input box and select Show button.



  • See the result:



  • To update the current histogram, enter your desired comma-delimited list of values in the input box and select Update button.



  • see the result:



Folder structure

This shows the folder structure of the default template.

histogram
โ”œโ”€โ”€ src                   # primary app folder
โ”‚   โ”œโ”€โ”€ index.html        # html file to that has the display layouts
โ”‚   โ”œโ”€โ”€ style.css         # css file that has the style for html tags
โ”‚   โ””โ”€โ”€ script.js         # Histogram class that has show + update + reset functionalities.
โ””โ”€โ”€ images                # all the images shown in the README file that shows use cases.

Road Maps from Start to End:

  • It was a long time since I coded JavaScript, so I spent a couple of days finishing JavaScript Tutorial beginner, and Intermediate sections.
  • Then I spent a day finishing Canvas Tutorial
  • First problem I encounter was to have a dynamic number of bars based on the given input so this wiki helped Histogram Algorithm.
  • I used Map data structure to compute the frequencies of input.
  • I used fillRect rather than line stokes to have consistency for computing offsets.

Resources

histogram's People

Contributors

fghiasi 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.