Build beautiful charts in your SwiftUI apps

Apple introduced SwiftUI in 2019 as a lightweight and easy-to-use way to create user interfaces. This article is the third in a series that explores how the SwiftUI framework can help us build clean, simple, and stunning data visualization tools. This time, we take a look at how to make pie charts!

What Is A Pie Chart?

A Pie Chart, also known as a Circle Chart, is a data visualization that represents each data value as a proportionally sized slice of a circle. …


Build beautiful charts in your SwiftUI apps

Apple introduced SwiftUI in 2019 as a lightweight and easy-to-use way to create user interfaces. This article is the second in a series that explores how the SwiftUI framework can help us build clean, simple, and stunning data visualization tools. Today, the spotlight falls on an old workhorse — the Bar Chart.

What Is A Bar Chart?

A bar chart (or bar graph) is a data visualization that deals with categorical data. The chart renders a rectangular bar for all variables, each with a height proportional to the values they represent.

The above text sounds nice, but what does it mean in normal-people language?

A…


Build beautiful charts in your SwiftUI apps

Charts
Charts

Apple introduced SwiftUI in 2019 as a lightweight and easy-to-use way to create user interfaces. This article series will explore how the SwiftUI framework can help us build clean, simple, and stunning data visualization tools, starting with the radar chart.

What Is a Radar Chart?

A radar chart (also known as a web chart, spider chart, or Kiviat diagram) is a way to represent multiple variables in the same plot on axes that start at the same point but extend in different directions. The image below shows an example of a radar chart and happens to be precisely the one we are building in this…


A guide to decomposing complex tasks and getting them right

Sometimes you are assigned to program something that you know. It may be a piece of UI that you have created before, or it may be an algorithm that you know by heart and can work out in a matter of minutes.

Other times, you are faced with harder problems and need to write code to perform tasks you may not even understand. These are situations where you need to think before you act, or end up in a tangled mess. …


Add the power of UIKit to your SwiftUI toolbox.

SwiftUI has spellbound an entire developer community since the introduction at WWDC 2019, and it is quite easy to understand why. It is fast, concise, and lets you build an entire working application with very few lines of code.

However, SwiftUI is still in its infancy and lacks many of the standard components we take for granted with more mature frameworks. Luckily, Apple’s engineers have developed ways to connect elements from UIKit straight into our SwiftUI applications. In this article, we look at how to leverage those mechanisms to create a SwiftUI wrapper for the good old UICollectionView.

A playground…


Add out-of-sync protection to your wrapper objects.

Since the birth of Swift’s property wrappers, I have seen numerous articles discussing how to create a wrapped variable that can persist itself to the UserDefaults sector. While many of the code examples suffice for the simplest case, I’ve still had some questions gnawing at the back of my head.

  • If several of these instances would ever need to be alive at the same time, how will they synchronize?
  • How do they synchronize if another process accesses the UserDefaults file, perhaps directly through the file system?

In this article, we look at how to make a property wrapper that persists…


Leveraging protocols to increase code reuse

Protocol Oriented Programming is probably one of the more advanced topics in Swift programming. To some, it means that a defining protocol should accompany the public interface of any class or struct in a project. To others, it is a concept that is only used by developers who like to show off their mad skills. In this article, we take a look at how we can leverage protocols to do useful work in our programs.

Let’s Dive Right Into Code!

We will extend a few standard library components to add methods and properties for statistical analysis. Most of us probably already have some experience with…


How can we use Monte Carlo simulations to evaluate risks and rewards?

Some problems are impossible to know the exact answer to. They involve random variables that aren’t guaranteed to have the same value every time, which ruins our chances of drawing conclusions with certainty. When we find ourselves in such situations, we turn to probabilistic theories for help. This article takes a look at the Monte Carlo Method, which allows us to get a sense of how likely a specific outcome is.

The code used to perform the simulations is available on Github.

What is a Monte Carlo Method?

Monte Carlo methods, or Monte Carlo experiments, are a broad class of computational algorithms that rely on repeated…


Working on remote is becoming increasingly popular among developers. Some of us choose to work remotely every day; some of us are happy with a few days per week. However, some still need to go into the office every single day. The issue could be that the company is not familiar with the concept of working remotely. It could also be that they fear losing control of their employees daily contributions. There is extensive research conducted on the subject of remote work. …


I believe that we, as working developers, need to be very careful about what frameworks we add to our projects. The list of questions we should ask ourselves before adding a framework to our projects is at least a mile long (depending on your font size of choice). However, there are some frameworks that are so fundamental that doing anything without them would be very difficult and cumbersome. In this article, we take a look at four frameworks that all iOS Developers will need to get a grasp on very early on in their careers.

Foundation

The Foundation Framework provides some…

Jimmy M Andersson

Data Scientist | Software Engineer | Author

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store