-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing bottom padding for gauge charts legend #1441
Comments
billboard.js/src/internals/ChartInternal.js Lines 936 to 938 in b929b98
|
This code is my fault. I added it to create a gap between legend and gauge labels, as there was no padding between them. I actually don't think that the legend is the only problem for the missing padding at the bottom of the chart. By removing The reason for this could be that the starting y coordinate for gauge labels is placed in the arc (not outside like you can see in the screenshot below) and is than moved by Line 843 in b929b98
![]() But as I wrote above, adding margin to the legend won't fix the issue for all use cases. |
@watnab gauge height is calculated here: billboard.js/src/internals/ChartInternal.js Lines 535 to 541 in b929b98
I tried few things and got following results:
I removed } else if (target === "legend") {
x = $$.margin3.left;
y = $$.margin3.top;
} I added following function to arc.js: getPaddingBottomForGauge() {
const $$ = this;
const defaultGaugeLabelHeight = 20; // value returned by 'getGaugeLabelHeight' if 'label_show: true'
const legendShow = $$.config.legend_show;
const gaugeLabelShow = $$.config.gauge_label_show;
if (legendShow && gaugeLabelShow) {
return $$.getGaugeLabelHeight() * ($$.isLegendRight ? 1.5 : 1);
} else if (legendShow && !gaugeLabelShow) {
return defaultGaugeLabelHeight * 1.5;
} else if (!legendShow && gaugeLabelShow) {
return $$.getGaugeLabelHeight() * 1.5;
} else {
return defaultGaugeLabelHeight * 1.5;
} changed the $$.arcHeight = $$.height - ($$.hasType("gauge") ? $$.getPaddingBottomForGauge() : ($$.isLegendRight ? 0 : 10)); It works for all gauge types, and it's only breaking 1 gauge test which can be easily updated. If this solution is ok for @netil I could make a pull request. |
@michkami, can you make PR to |
I think this is ok! Another solution would be to position the legend more to the value title so gauge does not get smaller. But this is up to you how you handle that. The current workaroud of mine was also to make the gauge little bit smaller in the height and to put a small padding outside of the svg |
Positioning the legend closer to value would overlap gauge min and gauge max as you can have multiple data columns: @netil I think it is necessary to make the |
Yes you're right! So making the gauge smaller would be the best solution! Thank you very much for fixing that! Kind regards Ronny |
thanks @RonnyWeiss, @michkami for the contribution! |
# [2.0.0](1.12.11...2.0.0) (2020-07-16) ### Bug Fixes * **all:** Fix test cases ([2e1ad79](2e1ad79)) * **arc:** fix applying data.labels.colors ([#1448](#1448)) ([c128fad](c128fad)), closes [#1440](#1440) * **axis:** fix incorrect clip node handling ([a8c6f96](a8c6f96)), closes [#1449](#1449) * **axis:** make axis clip-path to fit real axis size ([7419f44](7419f44)), closes [#1449](#1449) * **bar:** fix bar width scale on zoom ([59073bd](59073bd)), closes [#1476](#1476) * **data:** fix for data.labels=false ([b7a0972](b7a0972)), closes [#1444](#1444) * **data.selection:** fix selection.isselectable value check ([9d41a04](9d41a04)) * **gauge:** fixed wrong bottom padding calculation ([0542586](0542586)), closes [#1441](#1441) [#1471](#1471) * **legend:** Don't bind event when interaction is false ([4546c00](4546c00)) * **point:** Correct focus.only to work in mobile env ([67eea16](67eea16)) * **point:** Correct point.focus.only ([1686594](1686594)) * **point:** update point generation ([da63e39](da63e39)) * **subchar:** correct subchart rendering ([44ed216](44ed216)), closes [#1458](#1458) ### Code Refactoring * **all:** v2 updates ([e23998f](e23998f)), closes [#758](#758) [#757](#757) [#756](#756) [#36](#36) * **module:** implement ESM index ([85caf71](85caf71)) ### Features * **axis:** Intent to ship log scale ([6fdf3e4](6fdf3e4)), closes [#1351](#1351) * **bar:** Intent to ship bar.label.threshold ([72a7b7f](72a7b7f)), closes [#1427](#1427) * **gauge:** Intent to ship gauge.label.threshold ([#1443](#1443)) ([9a0807e](9a0807e)), closes [#1439](#1439) * **interaction:** split selection, subchart & zoom ([ba1e4f2](ba1e4f2)) * **point:** Intent to ship point.focus.only ([bb70347](bb70347)) ### BREAKING CHANGES * **all:** v2 updates * **module:** new index for ESM build - split Axis releated size from size.ts --> size.axis.ts - split common main option from Options.ts --> ./common/main.ts - Instead export Axis class, add .getAxisInstance() to make beneficial from tree-shaking
Hello
When using Gauges with Legends then therese no padding at the bottom of the legend. The others charts types have the padding at the bottom.
Gauge:

Line:

Would be very cool if you could fix that.
Kind regards and a nice weekend
Ronny
The text was updated successfully, but these errors were encountered: