Skip to content

Commit

Permalink
[TSVB] Disable enableHistogramMode prop when user selects non-stacked…
Browse files Browse the repository at this point in the history
… bar (#74930)

* Remove enableHistogramMode prop from TSVB as it causes bugs with non-stacked bars

* Disable enableHistogramMode property to false only when thr user selects the nobn-stacked option

* small change to be more human readbale

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
stratoula and elasticmachine authored Aug 21, 2020
1 parent 7b23e7c commit ec44ee0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { MarkdownSimple } from '../../../../../../../plugins/kibana_react/public
import { replaceVars } from '../../lib/replace_vars';
import { getAxisLabelString } from '../../lib/get_axis_label_string';
import { getInterval } from '../../lib/get_interval';
import { areFieldsDifferent } from '../../lib/charts';
import { createXaxisFormatter } from '../../lib/create_xaxis_formatter';
import { STACKED_OPTIONS } from '../../../visualizations/constants';
import { getCoreStart } from '../../../../services';
Expand Down Expand Up @@ -164,7 +163,6 @@ export class TimeseriesVisualization extends Component {
const mainAxisGroupId = yAxisIdGenerator('main_group');

const seriesModel = model.series.filter((s) => !s.hidden).map((s) => cloneDeep(s));
const enableHistogramMode = areFieldsDifferent('chart_type')(seriesModel);
const firstSeries = seriesModel.find((s) => s.formatter && !s.separate_axis);

const mainAxisScaleType = TimeseriesVisualization.getAxisScaleType(model);
Expand Down Expand Up @@ -243,7 +241,6 @@ export class TimeseriesVisualization extends Component {
series={series}
yAxis={yAxis}
onBrush={onBrush}
enableHistogramMode={enableHistogramMode}
backgroundColor={model.background_color}
showGrid={Boolean(model.show_grid)}
legend={Boolean(model.show_legend)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export const TimeSeries = ({
onBrush,
xAxisFormatter,
annotations,
enableHistogramMode,
}) => {
const chartRef = useRef();
const updateCursor = (_, cursor) => {
Expand Down Expand Up @@ -181,6 +180,7 @@ export const TimeSeries = ({
) => {
const stackAccessors = getStackAccessors(stack);
const isPercentage = stack === STACKED_OPTIONS.PERCENT;
const isStacked = stack !== STACKED_OPTIONS.NONE;
const key = `${id}-${label}`;
// Only use color mapping if there is no color from the server
const finalColor = color ?? colors.mappedColors.mapping[label];
Expand All @@ -201,7 +201,7 @@ export const TimeSeries = ({
xScaleType={xScaleType}
yScaleType={yScaleType}
timeZone={timeZone}
enableHistogramMode={enableHistogramMode}
enableHistogramMode={isStacked}
useDefaultGroupDomain={useDefaultGroupDomain}
sortIndex={sortIndex}
y1AccessorFormat={y1AccessorFormat}
Expand All @@ -227,7 +227,7 @@ export const TimeSeries = ({
xScaleType={xScaleType}
yScaleType={yScaleType}
timeZone={timeZone}
enableHistogramMode={enableHistogramMode}
enableHistogramMode={isStacked}
useDefaultGroupDomain={useDefaultGroupDomain}
sortIndex={sortIndex}
y1AccessorFormat={y1AccessorFormat}
Expand Down Expand Up @@ -283,5 +283,4 @@ TimeSeries.propTypes = {
onBrush: PropTypes.func,
xAxisFormatter: PropTypes.func,
annotations: PropTypes.array,
enableHistogramMode: PropTypes.bool.isRequired,
};

0 comments on commit ec44ee0

Please sign in to comment.