Dynamic intervals

Is there any clever, and broadly generic, way I’m missing to dynamically change the interval of a query based on the graph dimensions?

I have had success with a Flux query where I can compare the current $__interval to the time range and such and be able to draw a graph with an interval that relates to 1, 3, 5, 10, 20 pixels, in order to smooth out the spikes and make a graph more useful.

Other variables I can calculate as a variable in the dashboard, and then import in as a finished value, but here the desired data interval is related to the size of each given graph window, so impossible to do outside of the scope of each panel… right?

It’s really frustrating that whilst there is the Max Data Points setting, it is in no way readable in code. If I could just divide the known width of the graph window by 2, 4, 8… that’d be fantastic. But I can’t. It feels really strange that there appears to be no way to cleanly change this sort of thing, irrelevant to the data source being used, unless I’m missing something?

I’ve searched and seen a few similar queries over the years, but typically they go unanswered.