Closed erozen closed 2 years ago
I believe this is intended behavior. Stacking graphs is the process of adding every value at each interval. If there is not a value at an interval on graph A but there is on graph B, then only graph B's value will be used.
In the case of stacking queries A and B together, I 100% agree it would be correct behaviour. In this case though only query B is stacked, and it is then overlaid on top of query A. We're not combining the values in any way, so I don't think it makes sense to reaggregate to the same granularity.
I can't think of a use case where you want those intermediate values to be zero, other than when stacking both queries together as you suggest.
As @bossinc mentioned this is the intended behavior. Let's assume we have two series:
Scenario 1: A: 1,1,1,1,1 B: 2,null,2,null, 2
Stacking these two will result int the follwing chart:
Now, let's switch the series:
Scenario 2: A: 2,null,2,null, 2 B: 1,1,1,1,1
The chart indicates the stacking clearly, the missing (null) values are treated as 0 for the stack to work.
Now, if I understand correctly, what you @erozen would expect to happen is to keep the nulls as missing values and do not consider them when accumulating the stacks, which would result in the following charts:
Scenario 1:
Scenario 2:
Now, the missing values - even though not rendered as data points - are shown in the stack in a way that can result in misinterpreting the chart.
Hi @dprokop,
I obviously wasn't clear enough as both yourself and @bossinc got the wrong end of the stick - hopefully this comment clears it up.
In the situation you detail, behaviour is correct - however that's not the scenario I'm trying to describe. The two series are NOT being stacked together, only only one series is being stacked.
Take data for example: Series 1: 00:00:00,"z",40 00:30:00,"z",60
Series 2: 00:00:00,"a",20 00:00:00,"b",30 00:10:00,"a",10 00:10:00,"b",20 00:20:00,"a",20 00:20:00,"b",20 00:30:00,"a",30 00:30:00,"b",30
When both these series are overlaid on the same graph, you get lines for "z", "a", and "b" on the same scale with the points joined directly, as per my first screenshot. If you set the second series to stacked but NOT the whole graph ( so "a" and "b" are stacked but "z" is not), you get the nulls incorrectly injected - as per my second screenshot.
The important thing to note is that you are NOT stacking both series - only one. In that case, since they remain separate, the granularity shouldn't be shared.
@grafana/grafana-bi-squad Could you please have a look at this again. Closing https://github.com/grafana/grafana/issues/43782.
@erozen thanks for detailing. I've put a sample data that you provided into Grafana, and I think I'm still not getting the results you are describing. Please have a look at the attached dashboard[1], using the TestData datasource.
I've configured the stacking exactly as you have described and IMO this works exactly as it is supposed to work. Stacking configuration: Series 2 (a) and Series 2 (b) stacked, Series 1 not stacked:
I've tested the attached dashboard against main
version as well as agains 8.3.2 which you report was about.
Could you please share your query results with us? You can get those by exporting CSV from the Panel Inspect. Please make sure Formatted data in Data options is disabled.
Hi,
Sample data attached, and the config and chart it generates in the screenshot.
With stacking of query B off, looks like it should :
Thanks @erozen, I'll have a look soon.
@erozen I finally had a chance to investigate this and see how we can fix the described issue. I've opened this PR https://github.com/grafana/grafana/pull/44324 - please have a look at the attached screenshots in it if this is the expected behaviour.
Hi,
Definite improvement, removing all the bars instead of having them zero makes the line graph and point plot look perfect - the bar is still narrow though, so a perfect fix would probably be to keep the granularity of the original data too. With stacking off they are the full width of the data, but when it's on the bars are reduced to the width of the other, more granular, data set, so there are large gaps between the bars and it looks like they represent smaller time spans than they actually do.
Hopefully that makes sense?
What happened: When creating a time series plot with two series using different intervals, when stack series is "off" the lower granularity series links values up as expected, however when set to "normal" the values are reduced to the granularity of the other series, and the intermediate slots are zero-filled.
What you expected to happen: Stacked rendering to occupy the same space as normal
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?: See below screenshots - First shows the expected behaviour - Query B data linked up. Second shows the change when one stack series is set to "normal" (please ignore the US date format, I haven't worked out how to change that yet).
Environment: