pikers / piker

(e2e) foss trading for non-tinas
GNU Affero General Public License v3.0
103 stars 17 forks source link

Fast step curve #240

Closed goodboy closed 2 years ago

goodboy commented 2 years ago

This adds a so called "step curve" graphic that is drawn as sequence of line segments per discrete datum in the domain. It can be thought of what a histogram typically looks like except we don't draw "separator lines" (vertical segments that touch the zero line) between each datum thus giving the appearance of a continuous curve where for each sample in the x, there is a flat segment in the y spanning that sample index in the x.

pyqtgraph actually already has this feature inside the PlotCurveItem type but it's somewhat hard to configure correctly to our sampling style (OHLC typically) and is not optimized for real-time update like our rewrite of PlotCurveItem. Further the fillLevel support is horrendously slow is used with stepMode as is demonstrated (and hopefully solved) in https://github.com/pyqtgraph/pyqtgraph/pull/2032.

I actually personally prefer the style now of this non-filled version anyway but we may want to support it if it's improved in pyqtgraph core.

Some additional niceties include highlighting the most recent curve-step-segment to distinguish it from history data. It's much easier to see what is the live data step, even from a far out zoom.

Also note, this PR does not include any actual usage of the new graphic 😂

That is all coming in #231.