Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
donquixote
Contributor
Contributor

Qlik charts respond strangely to transform: scale()

This is actually a bug report. Please move to different category, or tell me where to open bug reports.

Motivation

I am working on Qlik charts that are embedded in a website as mashups.

I am preparing a special print view, where I have to scale the charts to fit into the page without any horizontal scrolling.
I am trying to achieve this with `transform: scale(..)`on the element that contains a Qlik chart.

Problem

When I apply `transform: scale(factor)`, when Qlik redraws the element (e.g. on resize event), the chart is actually resized by the square of that factor. E.g. scale(.5) results in a resize that is more like scale(.25).

Steps to reproduce

I found an online demo where this can be reproduced easily.

https://webapps.qlik.com/masters/index.html#/stats

  • (I can reproduce in Chromium-like browsers and in Firefox).
  • Open browser developer tools (F12).
  • Inspect the pie chart "2023 Masters Golfers by Nationality".
  • On a parent element, e.g. ".qv-object-content-container", set the inline CSS rule "transform: scale(.5)".
    • -> you see the pie chart shrink to 50% width
  • Trigger a page resize event, e.g. by changing the size of the developer tools panel.
    • -> now the pie chart is redrawn and shows as 25% width.

Expected: Pie chart stays at 50% size after redraw.
Actual: Pie chart appears at 25% size after redraw.

 

Technical explanation

On redraw, Qlik recalculates the positions and sizes of canvas and svg elements inside an `.ng-scope` wrapper.
For some reason, these calculations get confused if a parent element has transform: scale() on it.

Workaround with limitations

As a workaround, I am now trying to scale the parent only by the square root of the actual factor. E.g. if I want to scale by .64, instead I apply transform: scale(.8).

However this has some problem because not all elements are resized in this bad/squared way.
E.g. some of the charts are actually html tables, and these will only be resized by the correct scale factor.

Trying to target exactly the elements that need the special scale factor is tricky, because there are no good selectors to distinguish the different types.

Labels (2)
4 Replies
donquixote
Contributor
Contributor
Author

From https://community.qlik.com/t5/New-to-Qlik-Sense/How-to-report-a-bug/td-p/1076062


Or start a discussion in the Qlik Sense space and try to attract the attention of a Qlik employee like Dirk Scharffetter‌, Jeffrey Goldberg, Mattias Malre‌ orMichael Tarallo

So.. ping 🙂

Damien_Villaret
Support
Support

Hi @donquixote 

This was previously reported as QB-775 to Qlik R&D but closed with no resolution.

Please feel free to log an idea in Qlik ideation so that other customers interested in this can vote on it.

https://community.qlik.com/t5/Submit-an-Idea/ct-p/qlik-ideationsubmit

If the issue is solved please mark the answer with Accept as Solution.
donquixote
Contributor
Contributor
Author

Hello,

the link gives me this:


Trying to access the Support Case Portal? or Downloads page? Connect with an agent now via live chat (click help icon lower right of page)
Product issue? Please post a question in one of our many product forums [https://community.qlik.com/t5/Forums/ct-p/Forums] or create a case with Qlik Support [https://community.qlik.com/t5/crmsupport/page]

Perhaps I don't have enough privileges.
I have colleagues (at least one) with higher level customer profiles, but I am just posting as a regular guy.
I already talked with him about this, he implied he did something but I don't remember what exactly. I will ping him again.
donquixote
Contributor
Contributor
Author

Btw for the time being I used a workaround:

  • We have one page where I "prepare" the print view, so that the charts all render in the way that I want them in print, but I intentionally give them more space (using width/height attributes and negative margins).
  • Once you actually click print in the browser, the print CSS is applied, with the transform: scale().

This way the charts are never redrawn while transform: scale() is active. Qlik js never sees the page with print CSS applied.

All of this is to make sure that all labels show up in print.

But, this workaround is not ideal.