Graph Panel with Values stacking works wrong

I have a Graph Panel with Values stacking.
It seems that if some value not exists in one bar, it is copied from last bar where it has a value.

What expected (pay attention to orange State 5):
Expected

What Grafana shows overall and what Grafana shows if I filter State 5 (it correctly shows State 5 bars, but in tooltips still ghost values):.

May be it some how should be releated to Null value option.
But graph looks the same with any Null value options.
And I should note that there is no nulls in data, it just have no value at all and it will be difficult to add there null or 0 since it is GROUP BY that counts events with particular state. No events - no record.

Please help to fix it!

Below is the panel settings and the sample data:

{
  "aliasColors": {},
  "bars": true,
  "dashLength": 10,
  "dashes": false,
  "datasource": "MyDB",
  "fill": 1,
  "fillGradient": 0,
  "gridPos": {
    "h": 9,
    "w": 12,
    "x": 0,
    "y": 0
  },
  "id": 2,
  "legend": {
    "avg": false,
    "current": false,
    "max": false,
    "min": false,
    "show": true,
    "total": false,
    "values": false
  },
  "lines": false,
  "linewidth": 1,
  "nullPointMode": "null",
  "options": {
    "dataLinks": []
  },
  "percentage": false,
  "pointradius": 2,
  "points": false,
  "renderer": "flot",
  "seriesOverrides": [],
  "spaceLength": 10,
  "stack": true,
  "steppedLine": false,
  "targets": [
    {
      "alias": "",
      "format": "time_series",
      "hide": false,
      "rawSql": "SELECT Time as time, Value as value, Metric as metric FROM _Temp ORDER BY Time ASC",
      "refId": "A"
    }
  ],
  "thresholds": [],
  "timeFrom": null,
  "timeRegions": [],
  "timeShift": null,
  "title": "Panel Title",
  "tooltip": {
    "shared": true,
    "sort": 1,
    "value_type": "individual"
  },
  "type": "graph",
  "xaxis": {
    "buckets": null,
    "mode": "time",
    "name": null,
    "show": true,
    "values": []
  },
  "yaxes": [
    {
      "format": "short",
      "label": null,
      "logBase": 1,
      "max": null,
      "min": null,
      "show": true
    },
    {
      "format": "short",
      "label": null,
      "logBase": 1,
      "max": null,
      "min": null,
      "show": true
    }
  ],
  "yaxis": {
    "align": false,
    "alignLevel": null
  }
}
CREATE TABLE [dbo].[_Temp](	[Time] [int] NOT NULL, [Metric] [nvarchar](max) NOT NULL, [Value] [int] NOT NULL)
GO
INSERT INTO [_Temp] ([Time],[Value],[Metric] ) VALUES
(1566201600, 11, N'State 1'),
(1566205200, 18, N'State 1'),
(1566208800, 10, N'State 1'),
(1566212400, 1, N'State 5'),
(1566212400, 26, N'State 1'),
(1566216000, 16, N'State 1'),
(1566219600, 11, N'State 1'),
(1566223200, 15, N'State 1'),
(1566226800, 14, N'State 1'),
(1566230400, 1, N'State 5'),
(1566230400, 11, N'State 1'),
(1566234000, 15, N'State 1'),
(1566237600, 16, N'State 1'),
(1566241200, 15, N'State 1'),
(1566244800, 4, N'State 5'),
(1566244800, 13, N'State 1'),
(1566248400, 14, N'State 1'),
(1566252000, 14, N'State 1'),
(1566255600, 13, N'State 1'),
(1566259200, 6, N'State 5'),
(1566259200, 15, N'State 1'),
(1566262800, 11, N'State 1'),
(1566266400, 13, N'State 1'),
(1566270000, 16, N'State 1'),
(1566273600, 1, N'State 5'),
(1566273600, 12, N'State 1'),
(1566277200, 1, N'State 5'),
(1566277200, 17, N'State 1'),
(1566280800, 13, N'State 1'),
(1566284400, 2, N'State 5'),
(1566284400, 13, N'State 1'),
(1566288000, 1, N'State 5'),
(1566288000, 8, N'State 1')

When stacking make sure your data is uniform (not missing data for some series)

If there is no data point for one time interval for one series you need to insert 0s or let a group by insert 0s (there is a sql macro that can do this if you check grafana docs)

Thank you, $__timeGroup macro has third parameter that solves the issue!