billboard.js icon indicating copy to clipboard operation
billboard.js copied to clipboard

Regions and label, what about coordinates?

Open Phil353556 opened this issue 10 months ago • 5 comments

Hello, This a follow up of https://github.com/naver/billboard.js/issues/3950 with regions now added.

I used what you shared on #3950 . That's great. And I added "regions" like (labels are months name : Janvier > January, Février -> February and so on) Image

I ran a few tests and as the number of values on the X axis increased, the label was no longer displayed in the correct region. The issue I have is about the position of this label. Until 180 values (=6 months) that's ok, then the label is not at the right place. There is a shift on the right. see screenshots: OK :
Image

Not Ok : Image Image

May you tell me more about coordinates x and y for label? What I should in a perfect world, is to have the label displayed in the center of each region.

best regards / Phil

Phil353556 avatar Mar 04 '25 12:03 Phil353556

@Phil353556 can you provide a working example?

netil avatar Mar 07 '25 05:03 netil

Hello @netil, Here it is, rename the file to remove .txt extension several tests possibles with comment or uncomment the lines "values" and "data1". Thank you for your time Phil github3958.php.txt

Phil353556 avatar Mar 07 '25 08:03 Phil353556

@Phil353556 is because, specifying x & y coordinate value for each region will make to positioned as is. If you remove (or set x & y both as zero), will make region text to be positioned at the top left, and from that position specify relative values where you want to be.

    regions: [
      {
        start: "1",
        end: "31",
        label: {
          text: "january",
          // x: 200,  // x coordinate is relative to the region start position(left top)
          // y: 50,  // y coordinate is relative to the region start position(left top)
          color: "red"
        }
      },
      {
        start: "32",
        end: "59",
        label: {
          text: "February",
          color: "red"
        }
      },

So, the default coordinate for region text will looks like: Image

netil avatar Mar 10 '25 05:03 netil

Planning to implement new feature to align region label text at the middle on next release.

netil avatar Mar 10 '25 08:03 netil

Hello @netil Thank you for your answer and thanks for the new feature, that's excellent. Phil

Phil353556 avatar Mar 10 '25 12:03 Phil353556