Skip to main content

5 posts tagged with "class"

View All Tags

Visualizing flight search results with charts

· 7 min read
Simon Porritt
VisuallyJs Development

Flight search bubble chart

In a previous post I mentioned a book that introduced to me the concept of the "data-ink" ratio - the amount of ink used to represent data vs the total amount of ink used to draw the entire image. At that time I was working for a travel company, and I was so enamoured with this book that I instantly went off and started designing prototypes for alternative ways we could present our users with the results of their searches.

None of my ideas were adopted: I couldn't find a champion amongst the middle managers. But that didn't make me think they were no good. One of my favourites was what I'm going to talk about today - flight search results using a scatter chart.

Searching for flights

When I search for a flight I most often have:

  • a general idea of when I want to depart
  • a budget
  • a personal list of airline preferences
  • a preference for getting there quickly, but
  • an aversion to flights longer than 15 hours

Maximising the data-ink ratio in a World Cup visualization

· 3 min read
Simon Porritt
VisuallyJs Development

Many years ago a manager of mine introduced me to a fantastic book about data visualization, entitled The Visual Display of Quantitative Information, by Edward Tufte:

The Visual Display of Quantitative Information

You should go to a bookstore and buy this book, it's great.

One of the core concepts in this book is that of the "data-ink" ratio - the amount of ink used to represent data vs the total amount of ink used to draw the entire image. There are many examples of this throughout the book, and it's a concept that has stuck with me.

FIFA World Cup

We recently dusted off our FIFA World Cup Visualizer and released it as an app that people can use in their sites. In this app we're particularly pleased with the group stage visualization, because we think it has a satisfying data-ink ratio:

World cup group stage

For a given team in the group stage, this visualization lets the user track 10 discrete pieces of information:

How we improved our apidocs with Typedoc groups and categories

· 10 min read
Simon Porritt
VisuallyJs Development
info

This post is from JsPlumb, which is now in maintenance mode. To see the VisuallyJs apidocs, visit this page

JsPlumb uses the excellent Typedoc documentation generator to create our API documentation, but since we adopted it last year we haven't really made the most of it. We would run Typedoc over our codebase with the default settings, and the result is a page in which everything is listed alphabetically, grouped by Enumerations Classes, Interfaces, etc.

It can be a useful page - if you know what you're looking for. But it doesn't lend itself very well to browsing, and browseable docs are great, because they lead to discovery.

The last 6.x release API docs page looks like this:

TS4111 - noPropertyAccessFromIndexSignature

· 2 min read
Simon Porritt
VisuallyJs Development
info

This post is from JsPlumb, which is now in maintenance mode. We've updated the Gantt chart link to point to VisuallyJs.

While working on an Angular version of our popular Gantt chart demonstration this morning I stumbled across a Typescript linting issue whose purpose is not at all clear to me.

THE PROBLEM

Say I have this interface for a person:

export interface Person {    
firstName:string
lastName:string
}

and this for a serialized person:

export interface Person {    
firstName:string
lastName:string
fullName:string
}

Now I want to write a serializer to export a bunch of these people:

export function serializePeople(persons:Array<Person>):string {
return persons.map(p => {
return {
fullName:`${p.firstName} ${p.lastName}`,
firstName:p.firstName,
lastName:p.lastName
}
})
}

This looks ok, right? Well in fact the default settings for Angular's tsconfig.json cause an error:

Property 'firstName' comes from an index signature, so it 
must be accessed with ['firstName']

Testing class compatibility with isAssignableFrom

· 4 min read
Simon Porritt
VisuallyJs Development
info

This post is from JsPlumb, which is now in maintenance mode. We still use this code in VisuallyJs though.

Classes are a controversial topic in the Javascript/Typescript world. Are they a terrible idea? Are they really useful, when used sensibly? This post will make no attempt at answering either of these questions. This post is about a niche method that I first encountered many years ago in the world of Java - isAssignableFrom - and how you can go about writing it for use in Typescript/Javascript.

What does it do?

This is what the Javadocs have to say about it:

public boolean isAssignableFrom(Class<?> cls)

Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false.

So, given some class, you can use isAssignableFrom to figure out whether that class is a subclass of some other class.

Why would I need this?

If you're thinking it's a bit niche, yes, I agree. isAssignableFrom is one of those methods you don't use much. But when you need it, you need it.