klinecharts / KLineChart

📈Lightweight k-line chart that can be highly customized. Zero dependencies. Support mobile.(可高度自定义的轻量级k线图,无第三方依赖,支持移动端)

Home Page:https://klinecharts.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] consider using devicePixelContentBox to fix blur

oneart-dev opened this issue · comments

Version

9.5.0

Steps to Reproduce

  1. Open chart on PC

Current Behavior

For PC users chart bars and text can be blurry.

Expected Behavior

It's probably not easy fix to make pixel perfect render, but big chunk of users using Chrome or Chromium based browsers and for them we can use this - https://web.dev/device-pixel-content-box/
I didn't managed to apply it properly outside library code, but maybe you have morel luck

Environment

- OS: Windows
- Browser: Chrome
- Framework: not related

Any additional comments?

Confirmed blur on 27'' display with 2560x1440 resolution on latest chrome

commented

Welcome to PR

@liihuu after quite a few hours of debugging i probably found the problem with blur. Scrolling is very smooth, but endup with very long floating point. Using Math.floor on bars helps a lot. I will prepare PR.

Also have a question, why you are using "rect" to draw a wick with fixed 1 width for candle chart. I think migrating to line can improve performance but need testing. Probably new simple line without logic for smoothing can be even faster.

And for solid candles you don't need 2 figures to draw one wick. It can be one figure. Maybe i'm missing something?

commented

Upgrade 9.7.1

@liihuu nope, I assume docs running on latest version. This is how it looks here: https://klinecharts.com/en-US/sample/indicator.html

Pay attention to green candles blur
Screenshot 2023-12-23 at 14 47 20

I already fixed it in my fork. The only solution is to use floor to make half pixel hack works.