Skip to content

Commit

Permalink
[Lens] Fix area percentage gaps with zero fitting function (#94086) (#…
Browse files Browse the repository at this point in the history
…94452)

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Marco Liberati <[email protected]>
  • Loading branch information
kibanamachine and dej611 authored Mar 11, 2021
1 parent 93e526b commit 5ae7dd7
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,14 @@ export function XYChart({
layersAlreadyFormatted
);

const isStacked = seriesType.includes('stacked');
const isPercentage = seriesType.includes('percentage');
const isBarChart = seriesType.includes('bar');
const enableHistogramMode =
isHistogram &&
(isStacked || !splitAccessor) &&
(isStacked || !isBarChart || !chartHasMoreThanOneBarSeries);

// For date histogram chart type, we're getting the rows that represent intervals without data.
// To not display them in the legend, they need to be filtered out.
const rows = tableConverted.rows.filter(
Expand All @@ -674,7 +682,7 @@ export function XYChart({

const seriesProps: SeriesSpec = {
splitSeriesAccessors: splitAccessor ? [splitAccessor] : [],
stackAccessors: seriesType.includes('stacked') ? [xAccessor as string] : [],
stackAccessors: isStacked ? [xAccessor as string] : [],
id: `${splitAccessor}-${accessor}`,
xAccessor: xAccessor || 'unifiedX',
yAccessors: [accessor],
Expand Down Expand Up @@ -710,13 +718,8 @@ export function XYChart({
);
},
groupId: yAxis?.groupId,
enableHistogramMode:
isHistogram &&
(seriesType.includes('stacked') || !splitAccessor) &&
(seriesType.includes('stacked') ||
!seriesType.includes('bar') ||
!chartHasMoreThanOneBarSeries),
stackMode: seriesType.includes('percentage') ? StackMode.Percentage : undefined,
enableHistogramMode,
stackMode: isPercentage ? StackMode.Percentage : undefined,
timeZone,
areaSeriesStyle: {
point: {
Expand Down Expand Up @@ -797,7 +800,11 @@ export function XYChart({
case 'area_stacked':
case 'area_percentage_stacked':
return (
<AreaSeries key={index} {...seriesProps} fit={getFitOptions(fittingFunction)} />
<AreaSeries
key={index}
{...seriesProps}
fit={isPercentage ? 'zero' : getFitOptions(fittingFunction)}
/>
);
case 'area':
return (
Expand Down

0 comments on commit 5ae7dd7

Please sign in to comment.