Interactive Periodic Table in JavaScript version 1.0

The periodic table is a chart found pinned to the wall of every school chemistry lab showing various pieces of information on each element, or type of atom. The information is tightly packed and often difficult to read and understand so I decided to develop an interactive web-based version in JavaScript which is easier to use and comprehend than a static paper version.

My original intention was to simply produce a filterable version of the table, and in this post I have done just that. However, while researching the topic I found that it was far more complex than I originally realised and that there is huge scope for expanding the topic to show more infomation and also to show the existing information in different formats. This is therefore an ongoing project which I will enhance in the future. Watch this space...

Continue reading

SVG Library in JavaScript version 1.0

I have already written a couple of small SVG libraries, one in C and one in Python. However, the most useful and widespread use of the SVG format is within web pages so in this post I will begin to develop a JavaScript SVG library.

This first version has quite modest ambitions: just the ability to draw a few simple shapes as well as text. However, SVG is far more capable than most people realise so I will add further functionality in the future with the aim of creating a far more comprehensive library.

Continue reading

SI Prefixes in JavaScript

Most people are familiar with a few of the more common prefixes used before many units to denote a fraction or a multiple of the unit - kilograms, megabytes, centimetres etc.. As well as these there a number of less well known ones, going right up to yotta and right down to yocto.

A while ago I wrote a post on SI Prefixes in Python to list all the prefixes along with their corresponding powers and multipliers. When I started writing an equivalent in JavaScript I soon hit a brick wall when I realised that JavaScript's Number type couldn't provide the precision needed.

Searching around for a solution to the problem I discovered the excellent math.js library which, amongst many other things, provides us with a BigNumber type and I thoroughly recommend reading the documentation here. This post covers my simple little JavaScript project to list the numeric SI prefixes.

Continue reading

Benford’s Law in JavaScript

Benford's Law describes the distribution of the first digits of many, if not most, sets of numeric data and in this post I will implement a demonstration of the law in JavaScript.

Benford's Law centres on the perhaps surprising fact that in numeric data such as financial transaction, populations, sizes of geographical features etc. the frequencies of first digits follow a roughly reciprocal pattern.

Continue reading

Image Histograms in JavaScript

Most cameras and image editing applications will generate histograms of image data, showing the distributions of colours for the three channels, red, green and blue. As part of an Electron application I am working on I developed a JavaScript implementation of image histograms using the NodeJS Jimp package. This is it...

Continue reading

Levenshtein Word Distance in JavaScript

In this post I'll write a JavaScript implementation of the Levenshtein Word Distance algorithm which measures the "cost" of transforming one word into another by totalling the number of letters which need to be inserted, deleted or substituted.

The Levenshtein Word Distance has a fairly obvious use in helping spell checkers decided which words to suggest as alternatives to mis-spelled words: if the distance is low between a mis-spelled word and an actual word then it is likely that word is what the user intended to type. However, it can be used in any situation where strings of characters need to be compared, such as DNA matching.

Continue reading