DataViz in Unreal Engine
We have been looking ways to get data visualisation working in Unreal Engine. Currently this research is still in early stages. We are working with test data to get a simple bar graph from a blueprint. If you are working on a similar project we hope you will find these resources useful.
These are the steps I took towards getting data visualisation working in Unreal Engine. This has been a very experimental process and is constantly evolving. Hopefully some of these will give you a step in the right direction if you are looking to undertake a similar project
Importing data into Unreal Engine The first hurdle to overcome was importing the actual data into Unreal. If you're just starting out and want a sample set to use Rawgraphs is a good source. I used the Spotify Top 50 data set from this site to do my testing when first starting.
Unreal uses Data Structs, which is essentially just a database. You can import your data sets from elsewhere into unreal and have it populate your struct for you. As far as I am aware, you must create the struct prior to importing the data set into Unreal, it will not create fields for you.
Here are some useful resources to get you started on structs and their behaviour:
Unreal Struct Documentation The official documentation about structs from Unreal devs
WTF Is? A Struct Matthew Wadstein (who's videos are very helpful) covers the basics of what a struct is in this video
Blueprint Structure Explanation A quick explanation from the Unreal forums that I found very helpful when trying to make sense of how to bring data in
HTF do I? Data Table Importing of Arrays and Structs ( UE4 ) Another Matthew Wadstein video explaining how to import your data into your struct
Having your data reflect changes in the Unreal environment
This was a bit of a bigger hurdle to tackle, so to begin with I found this tutorial quite helpful:
It covers how to have objects reflect an input from a user. I took this structure and replaced the user input with an input from my data structure and was able to get a start from there.
With this information in mind, I wanted to start looking for more ways to reflect information contained within my data set. I eventually found this video:
This is an extremely helpful tutorial about creating meshes that can be altered by the user. As before, the user inputs can simply be replaced with an input from the data structures. Setting this up is a little more difficult though, especially with so many different kinds of data to show. This tutorial will take you through making loops, creating variables and having meshes behave dynamically in a way you want. An excellent place to start.
Incrementing through a data table
After learning about loops to create custom structures, the next step was to find a way to have the size of the structure be determined by data in our data set. I found the following videos helpful in starting this process.
The method I ended up using was as follows:
- Turn the row name into an Integer
- Create the base of the structure
- Add the blocks of the structure on according to the "Liveness" rating from our data set
This gave me what essentially amounted to the beginnings of a bar graph. It will iterate through our table until the end and reflect the information we requested from it.
Next came labeling the songs from our data set. Text cannot be manipulated the same was as meshes can, so I had to find a bit of a different method than earlier to get this part working.
Below are two videos that helped me get a feel for text editing:
I tried a few different methods to get text labels working correctly but the same nodes that I used for earlier work could not be applied in this case.
I ended up creating a variable to store the the information needed for the text loop, then used the Add Text Render Component node and set the text. A Make Transform node was needed to transform this as instancing isn't possible as far as I'm aware. In this way it can be added to our loop.
How it was done
Let's take a look at the blueprint that got us to this point
We can see the process in it's current form in the image above. All of this takes place in the construction script of our blueprint.
We start with a loop which is set to end when it reaches the end of our data scruct. In this case, 50 entries.
Start of by getting the data table and making a variable out of the row name, which we will call later to loop our structure. Next, break the structure into it's individual elements, to give us access to the data we want to pull. Then we create the base of the table along with a variable telling them how far apart to create each instance.
Set the Liveness by connecting it to the broken table from earlier, then create a for loop to go through each time this data is updated. We create instances of blocks for each number inside the Liveness variable.
When this is complete, we add the name. I created a Track Name variable to see us through it. We use a text render component with a transform (making sure to bring the same numbers from earlier to ensure the spacing matches your current data set) to bring in the text meshes we need. We then connect up our track name and set the text.
With all of this in place we increment, bringing our Row Num Int variable into play and the blueprint will run through it all until complete.
This work is continuing and this page will be updated along with it. I hope to have our first test completed to show you soon.