[Lens] Fix area percentage gaps with zero fitting function (#94086)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Marco Liberati 2021-03-11 17:03:58 +01:00 committed by GitHub
parent 91f7711da6
commit ed95c08d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(
@ -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],
@ -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: {
@ -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 (