Page 1 of 2

Make production graphs cleaner

Posted: Wed Feb 03, 2021 5:01 pm
by coppercoil
TL;DR
Prod2Prod.png
Prod2Prod.png (63.38 KiB) Viewed 3056 times
What ?
1. Remove high frequencies in the graphs.
2. Make graph lines smooth.
Why ?
Graphs will be cleaner and nicer.

Re: Make production graphs cleaner

Posted: Wed Feb 03, 2021 8:59 pm
by valneq
thing to consider: smoothing out the graphs will remove details that can be very informative

Re: Make production graphs cleaner

Posted: Wed Feb 03, 2021 9:07 pm
by Koub
Hands would be cleaner, nicer, and smoother looking without finger, but way less practical :mrgreen: .
Functionality >> Looks.
Graphs don't need to look nice, but to inform us what's going on in our factory.

Re: Make production graphs cleaner

Posted: Wed Feb 03, 2021 9:55 pm
by coppercoil
Just switch to shorter time scale for details. Large scale already hides short peaks, so smoothing would be not so "destructive" as you think. I mean, graphs hide fine details by now, and players are fine with that :)

Re: Make production graphs cleaner

Posted: Wed Feb 03, 2021 10:07 pm
by foamy
coppercoil wrote:
Wed Feb 03, 2021 9:55 pm
Just switch to shorter time scale for details. Large scale already hides short peaks, so smoothing would be not so "destructive" as you think. I mean, graphs hide fine details by now, and players are fine with that :)
Problem there is that you can't examine arbitrary segments at high resolution, just the most recent one. :(

Re: Make production graphs cleaner

Posted: Thu Feb 04, 2021 5:51 am
by pichutarius
My guess, currently it counts how many of each item is produced x minutes ago, and divide by x. Bigger x for bigger timescale and vice versa.

From math perspective, I wonder how to implement smoothing, probably need convolution with bell curve, and therefore cost ups. Its not that easy.

Re: Make production graphs cleaner

Posted: Thu Feb 04, 2021 6:38 am
by ickputzdirwech
The graphs are already smoothed. Anyone remember the old spiky fluid graphs?

Smoother graphs aren’t necessarily less functional. True they include less information. But if they have too many details it’s hard to interpret what they actually represent. Especially if you are interested in long time trends. I think I wouldn’t mind a bit more smoothing.

Re: Make production graphs cleaner

Posted: Thu Feb 04, 2021 7:07 am
by Koub
In that case, like in Excel charts, a feature "average over N points" with obviously possibility to set whatever N positive integer you'd like. Like that when "trend" needed, it's possible, when details needed, it's possible too.

Re: Make production graphs cleaner

Posted: Fri Feb 05, 2021 7:00 am
by Taneeda
+1

My first thought on this topic was "YES, please" :)
Koub wrote:
Thu Feb 04, 2021 7:07 am
In that case, like in Excel charts, a feature "average over N points" with obviously possibility to set whatever N positive integer you'd like. Like that when "trend" needed, it's possible, when details needed, it's possible too.
Why not add a slider to statistics panel to adjust N between 1..10, with default of 3? Same for electric stats panel...

Re: Make production graphs cleaner

Posted: Sat Feb 06, 2021 9:13 am
by ssilk
Technically this is nothing else than a function that takes more ore less points in a time-frame of the graph and uses the average, instead of each single point. It looks like it is loosing information , but this is in practice used very often, for example to see, if values are rising or falling.

For example when we have the load of the CPU’s in a cluster, then both is very interesting: you want to see, if there are peaks in the load and you want to see a general trend of the load. The first is needed to find events that causes such peaks, and the second is used to see, when it is time to add a new node to the cluster.

But as the stats in Factorio are currently working I don’t see, how that might be useful. To make sense for that graph, you need to see both types side by side.
...

What I really would like to see here are free configurable dashboards. Like with Grafana.
Image

And I would be able to say: when power under x for n seconds raise alarm. Or when pollution is over x turn mines off. Just need to create a new dashboard, add the right values, the type of the graph, set alarms, ready.

But that would cost many cpu-cycles to create, would slow down Factorio significantly. I think we need to live with the current compromise. But I don’t like it. :)

Smooth graph in electrical network info and production statistics

Posted: Sun Oct 24, 2021 5:15 pm
by mrvn
TL;DR
Add an option to the graphs in electrical network info and production statistics to make the lines smoother.
What ?
Add a slider "Smoothing: N" to the GUI. If one pixel in the graph covers 10 seconds then the value of each pixel is the avergage of the 10 * N seconds before the pixel. Depending on N this will smooth out spikes and make for a much more readable graph.

Note: Values for pixels will overlap by N-1. The value of the next pixel can be calculated with minimal overhead by adding (current value - value N-1 steps ago) / N. So regardless of N the cost of computing values will remain constant.
Why ?
With the way back-pressure works to stop assemblers there is a constant stop and go action depending on the ratios of buildings and speed of recipes. It's rare that anything has a constant consumption or production. Even increasing the time span of the graph so each pixel represents a longer timeframe doesn't get rid of the spikeyness of the graph. Some of it because there are longer duration spikes, like when a train is loaded and all the ore miners start up till the buffer chests are full again. So short term spikes get replaced by long term spikes.

Currently the graph can look like this:
graph.png
graph.png (31.99 KiB) Viewed 2891 times
With the lines overlapping and spiking like this they become unreadable. A smooth out line for each item in the graph would reduce the clutter and make it more useful.
Alternatives?
Instead of calculating a value for every pixel only compute those pixels that are labeled on the X axis and connect them with a dot.

Instead of drawing the value at time X draw the average from X to now. So the 1m graph would have the 60s average on the left, the 30s average in the middle and the current value on the right.

Re: Smooth graph in electrical network info and production statistics

Posted: Sun Oct 24, 2021 5:43 pm
by mmmPI
mrvn wrote:
Sun Oct 24, 2021 5:15 pm
With the lines overlapping and spiking like this they become unreadable. A smooth out line for each item in the graph would reduce the clutter and make it more useful.
You can select one or several item and then the graph only shows them.

but i agree with you it would be interesting to have better visual information.

Not sure i understand your proposition however making the line smoother and reducing the spikes is not desirable in my eyes, i think the tab should reflect as accurate as possible what is happening.

Then having options to interpret such as average, trend, +/- total production , and so on i'm favourable.

Re: Smooth graph in electrical network info and production statistics

Posted: Sun Oct 24, 2021 6:51 pm
by mrvn
mmmPI wrote:
Sun Oct 24, 2021 5:43 pm
mrvn wrote:
Sun Oct 24, 2021 5:15 pm
With the lines overlapping and spiking like this they become unreadable. A smooth out line for each item in the graph would reduce the clutter and make it more useful.
You can select one or several item and then the graph only shows them.

but i agree with you it would be interesting to have better visual information.

Not sure i understand your proposition however making the line smoother and reducing the spikes is not desirable in my eyes, i think the tab should reflect as accurate as possible what is happening.

Then having options to interpret such as average, trend, +/- total production , and so on i'm favourable.
It would be selectable. Set N=1 (default) and you get the current graph. N=2 and each pixel is averaged with the previous value. The higher you select N the more smoothed out it is.

For me in the 1m view each pixel represents 0.2s or 12 ticks. So N=2 would show a 24 ticks average. N=5 would give 1s averages. Just now I have a case where a pretty power hungry electrolyser runs once per second. So I would want a fairly big N to smooth that. Unless I'm looking to see if anything stutters. That's why it needs to be a slider so you can easily set a value that works for you.

Re: Smooth graph in electrical network info and production statistics

Posted: Sun Oct 24, 2021 8:31 pm
by mmmPI
You can already read the power consumption of the 1 electrolyser if you select its icon under the power graph, it will show only its graph, and also on the table under the graph read the averaged value for last 5 sec 30 sec 1 minutes 10 minutes 1 hour and so on.

If it's impossible to distinguish because you use many eletrolysers of the same tier, you need to isolate a few on a power grid ( with solar for example). It will be easier to read their cycle.

What you want is that the graph offer the possibility to reflects a curve of the different averages on a period of N times ? instead of trying to represent consumption in real time ?

Re: Smooth graph in electrical network info and production statistics

Posted: Mon Oct 25, 2021 12:11 am
by mrvn
I know that. But that is just the average over the whole time of the graph. One value. And if you have items close together they randomly switch positions and can be very hard to read and compare.

Try reading 2 or three numbers at the bottom at the same time? You basically have to make a screenshot or pause the game (which you can't in multiplayer). Comparing the number of X with that of Y 5 seconds ago like you can in a graph? Forget it.

Re: Smooth graph in electrical network info and production statistics

Posted: Mon Oct 25, 2021 7:29 am
by ssilk
The only thing I could add here is
A) Factorio is not though for that, far beyond of what’s needed in vanilla.
B) the stats had been always a source for criticism.
C) there is the Graftorio mod https://mods.factorio.com/mod/graftorio2 which I can recommend to exactly produce those graphs and much more. It has of course the disadvantage of needing some CPU and it takes some time to configure it for your needs.

Re: Smooth graph in electrical network info and production statistics

Posted: Mon Oct 25, 2021 8:22 am
by mmmPI
mrvn wrote:
Mon Oct 25, 2021 12:11 am
I know that. But that is just the average over the whole time of the graph. One value. And if you have items close together they randomly switch positions and can be very hard to read and compare.

Try reading 2 or three numbers at the bottom at the same time? You basically have to make a screenshot or pause the game (which you can't in multiplayer). Comparing the number of X with that of Y 5 seconds ago like you can in a graph? Forget it.
haaa you have to select the longer tab "250H" usually those are not jumping items, even the last 2 or 3 numbers at the bottom. Select the 3 desired machine and then switcback to the 5 second graph. You have only 3 graph visible, go to 10 minutes ,same, you have the average value written for each interval at the bottom and a spiky graph to help you realise what was averaged to give you the value.

Re: Smooth graph in electrical network info and production statistics

Posted: Mon Oct 25, 2021 5:44 pm
by UkcsAlias
ssilk wrote:
Mon Oct 25, 2021 7:29 am
A) Factorio is not though for that, far beyond of what’s needed in vanilla.
The only issue i see is that for long durations, rather than taking a static point, you are going to take a bigger set of data to calculate, which adds load.

But even here you can use keyframes for statistics. Each keyframe then can just take a certain value for each stat (average, max, min). The longer the graph, the more of those keyframes get averaged out (the 10min marker could have 4 keyframe values). It doesnt matter that the graph doesnt update every second at that point as thats not realy what you are looking for.

Base, peak and average load are all 3 a statistic that generaly are relavent to diagnose certain issues (lack of power during peaks can be buffered, for which the average might be interesting to get an idea of required buffer size. And the lowest gives a good identification of minimum load you will always consume). On large bases power can fluctuate a lot. And if you can isolate sections (which with power switches you can), you can gather some info about general load for each section. Which in turn can be used for some logic you can apply.

Sure, it might not be an optimal way to handle issues or monitor your factory. But its still a way that can aid to plenty of playstyles because it doesnt require perfect calculations. Especialy the casual player might want to get such info because of that.
But in the end, if it adds too much load, its going to be a bad idea anyway. This to me remains the most important aspect. The casual player might like such stats, the huge base builders might find the load it adds a major issue.

And maybe this is something that can be added in an expansion. Because who knows what will be added then? Do note that satisfactory relies quite a bit on the power graph while in that game factories are generaly more reliable at power usage because you can sink items (and therefor factories keep running). But then again, thats a game where instead of brownouts that slowly increase the problem, it instantly blacks out, which is a lot more harsh than this game.

I would say its something worthy enough to investigate for potential low cost solutions. But then again, im not a gigabase builder, so i am biased on that.

Re: Smooth graph in electrical network info and production statistics

Posted: Mon Oct 25, 2021 11:29 pm
by mrvn
UkcsAlias wrote:
Mon Oct 25, 2021 5:44 pm
The only issue i see is that for long durations, rather than taking a static point, you are going to take a bigger set of data to calculate, which adds load.
You aren't. You don't add up all the data points that go into each pixel. Instead it's a sliding window. As the graph advances the data point from "T-N" is subtracted and the data point for "T" is added. All the data points in between are carried over.

So for N > 1 the computation becomes twice as expensive but it's always the same no matter what N is except for a startup cost for the first pixel. That happens once and then the graph scrolls and only does one add and sub and a division per pixel scrolled.

Re: Smooth graph in electrical network info and production statistics

Posted: Thu Oct 28, 2021 6:17 am
by ssilk
Using keyframes: yes, would be useful.

In general, if I had the knowledge of programming c++ I would completely rewrite the stats. 8-) :lol: :twisted:
Because they lack on so many edges. :cry:

In general I would turn the stats so, that the player is enabled to create his own set of dashboards. I like for example Grafana
Image
Seeing what’s possible there and what’s implemented in Factorio makes me sad.
Of course I know that it’s not possible to put so much effort into a game to program such nice types of graphs. Because that’s needed, otherwise (see graftorio mod) it takes easily 10-20% of the performance. But I think the stats could really get some love.

Some examples:
- consistent colors (player preferences assignable?)
- support of boxed items (relationship between items)
- remember the settings of the timeframe
- scrolling/zooming in timeframe, much longer records in high resolution (player can say how much memory should be used and how much should be cut for saving)
- own stats, e.g. total amount of power from adding all power sources, how much copper is used for producing copper wire, …
- different types of lines (visibility), displaying the item in the graph
- stats on own screen (veeeery useful with the above features)
- some kind of alarms from stats