go4webdev

Charts.js injected from Go

There are many ways to create charts. I have found 3 main methods. Javascript, SVG and pixel (png)

Challenge #1: Speed

The part of UX I value the most is speed. Charts.js in combination with Go is one way to achieve this.

Challenge #2: Safety

In order to rise the security, we have both database and API hosted on "locked" servers that are "blocked" for inbound traffic. This means that you must use an internal IP-addresses to connect to the API. This is impossible to use Javascript to connect from the client to the API. But Go can fetch data from an internal IP address.

Challenge #3: Simpicity

My opinion is that Go is way simpler than Javascript. My goal is to use Go whenever it is possible. But Charts cannot be created using Go AFAIK. You must use Javascript in some way. Chart.js have many possibilites and is one of the most used chart libraries.

Challenge #4: Interactivity

The goal is to be able to hover and get the values. You cannot hover a part of a pixel chart and get the values. And svg is even more complicated than Javascript. So I decided to use Javascript.