Make something already!

Ok, so we’re gonna be pulling down loads of information from the CREST API so it’s going to have to be displayed in a sensible way and there’s nothing more sensible than graphs. Graph Maker is a fantastic plugin for Unity that allows the creation of fully dynamic 2D graphs and charts, honestly, the work put into this is just incredible - oh and it’s fully supported by the new Unity UI framework.

The first thing to do is set up a graph ready for holding the information. In this case a line graph. The graph contains a whole load of configuration options for auto scaling axis, colour, grid display, labels, legends - anything you can think of. After the required series where added to the graph object (it’s a good idea to break the prefab instance so you don’t overwrite it!) you can start populating it with data!

From our previous progress, the history has been deserialised into the history object (RootObject). The following populates each series by firstly clearing any current values, and adding one for each history entry with the average, min/max price, and volume.


int _i = 0;
foreach (Item _item in hist.items) {
    series1.pointValues.Add(new Vector2(_i, (float)_item.avgPrice));
    series2.pointValues.Add(new Vector2(_i, (float)_item.highPrice));
    series3.pointValues.Add(new Vector2(_i, (float)_item.lowPrice));
    series4.pointValues.Add(new Vector2(_i, (float)_item.volume));

Frustratingly GraphMaker uses the Vector2 type to store it’s point values - but this causes problems when casting the Double values from the history into floats; this could be a problem because of EVE’s currency commonly enters into the billions. I may look at converting the Vector2 types to a custom container that supports Doubles.

Anyway - when the application runs the graph is populated with the desired data. Nice.

And with a little time configuring the various GraphMaker prameters, we have a pretty snazzy looking graph. The bar chart at the bottom is a second graph with one series and only 200px high. Both Y axis auto expand or shrink based on the data provided, maximising the real-estate of the graph area. The X axis, time/date, is currently fixed to the 12 month period, in time this will be configured dynamically based on the search period.

Links in this post