Skip to content

Commit

Permalink
Improve chart scaling script
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Apr 24, 2024
1 parent 44823c0 commit 0213e5d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions gui/admin-gui/src/frontend/js/midpoint-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@ breakLongerTextInTableCell(cellId) {
panel.find("select.resizing-select").width(panel.find("select.width-tmp-select").width());
}

/**
* Used for scaling tables, images and charts (Role Mining)
*
* @param containerId
*/
initScaleResize(containerId) {
let div = document.querySelector(containerId);
let scale = 0.5;
Expand Down Expand Up @@ -674,14 +679,18 @@ breakLongerTextInTableCell(cellId) {
let rectBefore = component.getBoundingClientRect();

if (e.deltaY < 0) {
zoomIn(rectBefore);
zoomIn(rectBefore, containerId === '#chartScaleContainer' ? true : false);
} else if (e.deltaY > 0) {
zoomOut(rectBefore);
zoomOut(rectBefore, containerId === '#chartScaleContainer' ? 1.0 : 0.1);
}
}

function zoomIn(rectBefore) {
function zoomIn(rectBefore, isChart) {
console.log('Zooming in');

if(isChart && scale < 1.0){
scale = 1.0;
}
scale += 0.01;

let prevScale = scale - 0.01;
Expand All @@ -690,10 +699,10 @@ breakLongerTextInTableCell(cellId) {
setTransform(0, 0, scale, rectBefore, scaleFactor);
}

function zoomOut(rectBefore) {
function zoomOut(rectBefore, maxScale) {
console.log('Zooming out');
scale -= 0.01;
scale = Math.max(0.1, scale);
scale = Math.max(maxScale, scale);

setTransform(0, 0, scale, rectBefore, 1);
}
Expand Down

0 comments on commit 0213e5d

Please sign in to comment.