Skip to content

Commit

Permalink
fix group label positioning in multi-bars demo
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Dec 29, 2020
1 parent 698764f commit 7990578
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions demos/multi-bars.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@
}

function seriesBarsPlugin(opts) {
const labels = opts.labels;
const pxRatio = devicePixelRatio;

const labels = opts.labels;

const groupWidth = 0.9;
const groupDistr = SPACE_BETWEEN;

const barWidth = 1;
const barDistr = SPACE_BETWEEN;

const font = Math.round(10 * devicePixelRatio) + "px Arial";
const font = Math.round(10 * pxRatio) + "px Arial";

/*
function doOverlap(curs, rect) {
Expand Down Expand Up @@ -202,8 +204,8 @@
qt.clear();
},
setCursor: u => {
curs.x = u.cursor.left * devicePixelRatio;
curs.y = u.cursor.top * devicePixelRatio;
curs.x = u.cursor.left * pxRatio;
curs.y = u.cursor.top * pxRatio;

let found = null;

Expand All @@ -214,7 +216,7 @@

if (found) {
if (found != hovered) {
let pxRatio = devicePixelRatio;


barMark.style.display = null;
barMark.style.left = (found.x / pxRatio) + "px";
Expand Down Expand Up @@ -258,8 +260,8 @@
let splits = [];

distr(u.data[0].length, groupWidth, groupDistr, null, (di, lftPct, widPct) => {
let groupLftPx = (width * lftPct);
let groupWidPx = (width * widPct);
let groupLftPx = (width * lftPct) / pxRatio;
let groupWidPx = (width * widPct) / pxRatio;

let groupCenterPx = groupLftPx + groupWidPx / 2;

Expand Down

0 comments on commit 7990578

Please sign in to comment.