naver / billboard.js

📊 Re-usable, easy interface JavaScript chart library based on D3.js
https://naver.github.io/billboard.js/
MIT License
5.84k stars 353 forks source link

Legend overlaps x-axis label with larger font-size #1070

Open irislieuw opened 5 years ago

irislieuw commented 5 years ago

Description

It looks like billboard does a good job giving the x-axis label adequate space depending on the font-size applied to the .bb-axis-x-label element. However when the label is shifted down, the legend does not also get shifted, so they end up overlapping. Is it possible to shift the legend along with the x-axis label so this overlapping does not occur?

with a small font size image

medium font size image

larger font size image

Steps to check or reproduce

Here's the fiddle behind the screenshots. If you change the font-size being applied to the labels you can see the x-axis label get moved up or down, while the legend stays in place. https://jsfiddle.net/irislieuw/qnsk8w1z/

netil commented 5 years ago

@irislieuw, well adjusting via padding.bottom option will fix the issue. Is enough for your use case?

padding: {
    bottom: 30
},
irislieuw commented 5 years ago

Is there a way for billboard to adjust padding automatically? We are attempting to setup media queries to make the charts more responsive, so 1 static padding probably won't work...

On Wed, Sep 4, 2019 at 19:18 Jae Sung Park notifications@github.com wrote:

@irislieuw https://github.com/irislieuw, well adjusting via padding.bottom option will fix the issue. Is enough for your use case?

padding: { bottom: 30 },

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/naver/billboard.js/issues/1070?email_source=notifications&email_token=AC3FQDTYHMJEHGLVY5CKOJLQIBUANA5CNFSM4ITYCE32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD55TAJA#issuecomment-528166948, or mute the thread https://github.com/notifications/unsubscribe-auth/AC3FQDQ3WFN6BQIEEKVH2OTQIBUANANCNFSM4ITYCE3Q .

netil commented 5 years ago

I looked if this can be solved. The issue here is axis label texts are rendered after the axes are generated. To be solved, label text's dimension should be determined before the axes generation, which comes with the cost to determine it.

I'll look for it, how to improve on this.

adschm commented 3 years ago

@irislieuw @netil I have a similar issue, and I've been unable to apply a proper padding manually.

Would somebody be so kind to alter the fiddle linked above (or any other) so that the legend is moved down? Just a stupid fixed-value example I can work on from ...

netil commented 3 years ago

@adschm, you can try also axis.x.height

axis: {
    x: {
        height: 20
    }
}