Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The chart is blank on printed page in Chromium (Ctrl+P) #873

Closed
dtanp-rft opened this issue Oct 15, 2021 · 8 comments · Fixed by #818
Closed

The chart is blank on printed page in Chromium (Ctrl+P) #873

dtanp-rft opened this issue Oct 15, 2021 · 8 comments · Fixed by #818
Assignees
Labels
bug Unexpected problem or unintended behavior.
Milestone

Comments

@dtanp-rft
Copy link

Lightweight Charts Version: 3.7.0

Steps/code to reproduce:

Actual behavior:

None of the chart is printed. It's blank canvas.

Expected behavior:

It should be printed

Note:

  • Firefox, Safari works fine
  • It seems that only little square on the bottom right is printed
  • Same issue with r-click on chart canvas and save image
@timocov
Copy link
Contributor

timocov commented Oct 15, 2021

Same issue with r-click on chart canvas and save image

That's because due performance optimizations we're creating several canvases for panes/price axis/time axis. If you want to get an image of chart, please use takeScreenshot function instead.

Firefox, Safari works fine

Doesn't it mean that this is a bug in Chromium? 🤔

@dtanp-rft
Copy link
Author

Yeah it could be a bug in Chromium. Is there a chance to fix the printing? It would be easier for us if the printing work out of the box.

@timocov
Copy link
Contributor

timocov commented Oct 18, 2021

Is there a chance to fix the printing?

@dtanp-rft Do you have any idea what it could be? I mean, it seems that Chrome just ignores canvas elements on the page (or at least some "specific" canvases)? I think you can start with filing a report to Chromium team so they will be aware of the issue and probably they might have any workaround which we can use in the library.

@dtanp-rft
Copy link
Author

@timocov Really sorry for late response. I was on road trip last week :)

I have tried to debug in lightweight chart to see why some bit of canvas is able to print, while other parts are failed. Unfortunately, I don't think I understand enough of the code as the process of painting looks very similar ...

I was thinking that it must be a quirk on Chrome engine as well that causes the issue. However, other Canvas Chart e.g. ChartJS can print correctly ....

@timocov timocov added the needs investigation Needs further investigation. label Nov 1, 2021
@timocov
Copy link
Contributor

timocov commented Nov 1, 2021

If someone wants to investigate this and create an issue in chromium - you're more than welcomed to do it (or find a workaround for the library).

@timocov timocov changed the title Chart prints out as a blank canvas (Ctrl + P) The chart is blank on printed page in Chromium (Ctrl+P) Nov 1, 2021
@timocov timocov added the help wanted Asking for outside help and/or contributions to this particular issue or PR. label Nov 1, 2021
@subzey
Copy link
Member

subzey commented Nov 3, 2021

I believe the reason is that when being printed the page is briefly switched to the media: print.

image

And in this mode the window.devicePixelRatio and the (resolution) media doesn't match anymore. Looks like the media reflects the printer pixel density and the window.devicePixelRatio is the screen pixel density.

The workaround could be not changing the canvas size in the fancy-canvas if the window.devicePixelRatio hasn't really changed.

@timocov timocov added bug Unexpected problem or unintended behavior. and removed help wanted Asking for outside help and/or contributions to this particular issue or PR. needs investigation Needs further investigation. labels Nov 3, 2021
@timocov timocov added this to the 4.0 milestone Nov 3, 2021
@timocov
Copy link
Contributor

timocov commented Nov 3, 2021

Thanks @subzey! It seems that the first fix should be done in https://github.com/tradingview/fancy-canvas/ package. @Nipheris fyi

@edew edew linked a pull request Jun 16, 2022 that will close this issue
3 tasks
@keithlfs
Copy link

keithlfs commented Sep 5, 2022

That PR merge is still pending as of Sept '22 😬

Would be great to be able to print charts properly, this bug affects also affects chart PDF rendering when using Puppeteersharp/Chromium.

@Nipheris Nipheris mentioned this issue Sep 15, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants