Hide sensor data when the sensor is offline

I have a sensor that is only online 2 hours per day. The sensor reports temperature and humidity. I have a switch that is going on/off for the state online/offline.

When the sensor is offline the temperatue stays at the same value. So in a graph it is a horizontal line. What i want is that the graph only shows the data from when the sensor is online.

I am thinking about setting the item to “undefined” or “uninitliased” state but i do not know how. Or does anyone have another idea?

You can try setting it to undefined, if OH allows it, but I don’t know if you will be able to solve this problem using the charting capabilities built into OH. You may need to use some third party charting tool and a scatter plot instead of a line plot or something like that.