Skip to content

Commit

Permalink
[Lens] Cleanup bar value labels configuration (#106231)
Browse files Browse the repository at this point in the history
* 🐛 Rework value labels config

* 📷 Update snapshots
  • Loading branch information
dej611 authored and kibanamachine committed Jul 29, 2021
1 parent 11f80ae commit 81368c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ export const getXyChartRenderer = (dependencies: {
});

function getValueLabelsStyling(isHorizontal: boolean) {
const VALUE_LABELS_MAX_FONTSIZE = 15;
const VALUE_LABELS_MAX_FONTSIZE = 12;
const VALUE_LABELS_MIN_FONTSIZE = 10;
const VALUE_LABELS_VERTICAL_OFFSET = -10;
const VALUE_LABELS_HORIZONTAL_OFFSET = 10;

return {
displayValue: {
fontSize: { min: VALUE_LABELS_MIN_FONTSIZE, max: VALUE_LABELS_MAX_FONTSIZE },
fill: { textInverted: true, textBorder: 2 },
fill: { textContrast: true, textInverted: false, textBorder: 0 },
alignment: isHorizontal
? {
vertical: VerticalAlignment.Middle,
Expand Down Expand Up @@ -792,9 +792,12 @@ export function XYChart({
// * in some scenarios value labels are not strings, and this breaks the elastic-chart lib
valueFormatter: (d: unknown) => yAxis?.formatter?.convert(d) || '',
showValueLabel: shouldShowValueLabels && valueLabels !== 'hide',
isValueContainedInElement: false,
isAlternatingValueLabel: false,
isValueContainedInElement: true,
overflowConstraints: [LabelOverflowConstraint.ChartEdges],
overflowConstraints: [
LabelOverflowConstraint.ChartEdges,
LabelOverflowConstraint.BarGeometry,
],
},
};
return <BarSeries key={index} {...seriesProps} {...valueLabelsSettings} />;
Expand Down

0 comments on commit 81368c4

Please sign in to comment.