barrard Posted August 28, 2022 Share Posted August 28, 2022 Hey all, I have a PIXI.Graphics line with about 500k points. Draws fine, I added PIXI-Viewport for zoom and pan. When I zoom in the line resolution is not good. 2 questions. Main Question, how to fix the sharpness of the line on zoom-in Second question, how can I limit the zoom and pan to the min and max of this line I've drawn? Thanks! pixi-graph.mp4 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 28, 2022 Share Posted August 28, 2022 Use https://github.com/pixijs/graphics-smooth/ However 500k might be a bit much for it ) Quote Link to comment Share on other sites More sharing options...
barrard Posted September 7, 2022 Author Share Posted September 7, 2022 Thanks for your response Ivan, sorry for my delay. Weekend side project I don't get much time to hack on. I realized the line was not being scaled by the same factor as the zoom. Also, I wasn't really happy with how the Pixi-ViewPort zoom worked, as I only wanted to zoom the left and right, and keep the min and max values on the top and bottom scale. I ended up slicing my data according to mouse position and zoom, and then redraw the line. It's terrible slow though at first, as I'm redrawing the line with so many points, but as the sliced data gets reduced the line redraws quicker. ``` drawPriceLine() { this.priceGfx.clear(); console.log(`Draw line with ${this.allTicks.length} points`); //Tick line this.priceGfx.lineStyle(1, 0xffffff, 1); this.allTicks.forEach((tick, i) => { const x = this.xScale(tick.datetime); const y = this.priceScale(tick.close); if (i === 0) { this.priceGfx.moveTo(x, y); } else { this.priceGfx.lineTo(x, y); } }); } ``` Do you have any suggestions that might be more efficient? ticks-zoom.mp4 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 7, 2022 Share Posted September 7, 2022 > I realized the line was not being scaled by the same factor as the zoom the plugin has all scale modes: scale with zoom or not. or scale with only X zoom, or Y zoom. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.