Skip to content

Commit

Permalink
Replace chartHasMoreThanOneSeries with chartHasMoreThanOneBarSeries i…
Browse files Browse the repository at this point in the history
…n enableHistogram mode logic
  • Loading branch information
PavithraCP committed Oct 1, 2020
1 parent 9b06824 commit 6743b8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -918,16 +918,14 @@ describe('xy_expression', () => {
expect(component.find(BarSeries).at(0).prop('enableHistogramMode')).toEqual(true);
});

test('it does not apply histogram mode to more than one the series for unstacked bar chart', () => {
test('it does not apply histogram mode to more than one bar series for unstacked bar chart', () => {
const { data, args } = sampleArgs();
const firstLayer: LayerArgs = { ...args.layers[0], seriesType: 'bar', isHistogram: true };
delete firstLayer.splitAccessor;
const secondLayer: LayerArgs = { ...args.layers[0], seriesType: 'bar', isHistogram: true };
delete secondLayer.splitAccessor;
const component = shallow(
<XYChart
data={data}
args={{ ...args, layers: [firstLayer, secondLayer] }}
args={{ ...args, layers: [firstLayer] }}
formatFactory={getFormatSpy}
timeZone="UTC"
chartsThemeService={chartsThemeService}
Expand Down
11 changes: 8 additions & 3 deletions x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ export function XYChart({
yRight: true,
};

const chartHasMoreThanOneBarSeries =
filteredLayers
.filter((layer) => layer.seriesType.includes('bar'))
.reduce((sum, layer) => sum + layer.accessors.length, 0) > 1;

function calculateMinInterval() {
// check all the tables to see if all of the rows have the same timestamp
// that would mean that chart will draw a single bar
Expand Down Expand Up @@ -589,9 +594,9 @@ export function XYChart({
enableHistogramMode:
isHistogram &&
(seriesType.includes('stacked') || !splitAccessor) &&
(!seriesType.includes('bar') ||
seriesType.includes('stacked') ||
!chartHasMoreThanOneSeries),
(seriesType.includes('stacked') ||
!seriesType.includes('bar') ||
!chartHasMoreThanOneBarSeries),
stackMode: seriesType.includes('percentage') ? StackMode.Percentage : undefined,
timeZone,
areaSeriesStyle: {
Expand Down

0 comments on commit 6743b8b

Please sign in to comment.