Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
fix: paint the range brush above the histogram bars (#3753)
Javier Andrés García5e3f07947cb0
diff --git a/src/components/src/common/histogram-plot.tsx b/src/components/src/common/histogram-plot.tsxindex 0829bd3cc..750149d5e 100644--- a/src/components/src/common/histogram-plot.tsx+++ b/src/components/src/common/histogram-plot.tsx@@ -287,7 +287,6 @@ function HistogramPlotFactory() {<rect x="0" y="0" width={width} height={height} /></clipPath></defs>- <g transform={`translate(${isRanged ? 0 : fallbackBarWidth / 2}, 0)`}>{brushComponent}</g><g clipPath={`url(#${clipId})`} style={{pointerEvents: 'none'}}>{groupKeys.map((key, i) => (<g key={key} className="histogram-bars">@@ -338,6 +337,7 @@ function HistogramPlotFactory() {))}</g>) : null}+ <g transform={`translate(${isRanged ? 0 : fallbackBarWidth / 2}, 0)`}>{brushComponent}</g></HistogramWrapper>);};diff --git a/test/browser/components/common/histogram-plot-test.js b/test/browser/components/common/histogram-plot-test.jsnew file mode 100644index 000000000..279d2d90c--- /dev/null+++ b/test/browser/components/common/histogram-plot-test.js@@ -0,0 +1,45 @@+// SPDX-License-Identifier: MIT+// Copyright contributors to the kepler.gl project++import React from 'react';+import test from 'tape';+import {mountWithTheme} from 'test/helpers/component-utils';+import {appInjector, HistogramPlotFactory, HISTOGRAM_MASK_MODE} from '@kepler.gl/components';++const HistogramPlot = appInjector.get(HistogramPlotFactory);++const histogramProps = {+ width: 200,+ height: 60,+ margin: {top: 0, bottom: 0, left: 0, right: 0},+ isRanged: true,+ range: [0, 4],+ value: [1, 3],+ histogramsByGroup: {+ default: [+ {count: 5, x0: 0, x1: 1},+ {count: 8, x0: 1, x1: 2},+ {count: 3, x0: 2, x1: 3},+ {count: 6, x0: 3, x1: 4}+ ]+ },+ brushComponent: <g className="test-brush" />+};++// SVG paints its children in document order, so whatever comes later is drawn on top.+const paintOrder = (svg, selector) =>+ Array.from(svg.children).findIndex(child => child.querySelector(selector));++test('Components -> HistogramPlot -> brush is painted above the bars', t => {+ const wrapper = mountWithTheme(+ <HistogramPlot {...histogramProps} isMasked={HISTOGRAM_MASK_MODE.NoMask} />+ );+ const svg = wrapper.find('svg').getDOMNode();++ const bars = paintOrder(svg, '.histogram-bars');+ const brush = paintOrder(svg, '.test-brush');+ t.ok(bars >= 0 && brush >= 0, 'should render both the bars and the brush');+ t.ok(brush > bars, 'should paint the brush after the bars, so the bars do not cover it');++ t.end();+});diff --git a/test/browser/components/common/index.js b/test/browser/components/common/index.jsindex 14032dc50..0a4f544f9 100644--- a/test/browser/components/common/index.js+++ b/test/browser/components/common/index.js@@ -6,6 +6,7 @@ import './color-legend-test';import './range-slider-test';import './item-selector-test';import './range-plot-test';+import './histogram-plot-test';import './animation-control-test';import './column-stats-chart-test';import './json-editor-test';