Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] Use theme in histogram plot color (#607)

Shan Heec3052147123
diff --git a/src/components/common/range-plot.js b/src/components/common/range-plot.js
index 13758bc8f..f97df3bba 100644
--- a/src/components/common/range-plot.js
+++ b/src/components/common/range-plot.js
@@ -26,18 +26,17 @@ import {max} from 'd3-array';
import {createSelector} from 'reselect';
import {LineSeries, XYPlot, CustomSVGSeries, Hint, MarkSeries} from 'react-vis';
import styled from 'styled-components';
+import classnames from 'classnames';
+
import RangeBrush from './range-brush';
import {getTimeWidgetHintFormatter} from 'utils/filter-utils';
-import {theme} from 'styles/base';
const chartMargin = {top: 18, bottom: 0, left: 0, right: 0};
const chartH = 52;
const containerH = 78;
const histogramStyle = {
highlightW: 0.7,
- unHighlightedW: 0.4,
- highlightedColor: theme.activeColor,
- unHighlightedColor: theme.sliderBarColor
+ unHighlightedW: 0.4
};
export default class RangePlot extends Component {
@@ -145,17 +144,16 @@ const Histogram = ({
.range([0, height]);
return (
- <svg width={width} height={height} style={{marginTop: `${margin.top}px`}}>
+ <HistogramWrapper width={width} height={height} style={{marginTop: `${margin.top}px`}}>
<g className="histogram-bars">
{histogram.map(bar => {
const inRange = bar.x0 >= value[0] && bar.x1 <= value[1];
- const fill = inRange ? histogramStyle.highlightedColor : histogramStyle.unHighlightedColor;
const wRatio = inRange ? histogramStyle.highlightW : histogramStyle.unHighlightedW;
return (
<rect
+ className={classnames({'in-range': inRange})}
key={bar.x0}
- fill={fill}
height={y(bar.count)}
width={barWidth * wRatio}
x={x(bar.x0) + barWidth * (1 - wRatio) / 2}
@@ -167,7 +165,7 @@ const Histogram = ({
})}
</g>
{brushComponent}
- </svg>
+ </HistogramWrapper>
);
};
@@ -178,6 +176,16 @@ const LineChartWrapper = styled.div`
}
`;
+const HistogramWrapper = styled.svg`
+ .histogram-bars {
+ rect {
+ fill: ${props => props.theme.histogramFillOutRange}
+ }
+ rect.in-range {
+ fill: ${props => props.theme.histogramFillInRange}
+ }
+ }
+`
const LineChart = ({
width,
height,
diff --git a/src/styles/base.js b/src/styles/base.js
index 6b3ddc827..1fd31cdf2 100644
--- a/src/styles/base.js
+++ b/src/styles/base.js
@@ -210,6 +210,8 @@ export const sliderInputWidth = 50;
// Plot
export const rangeBrushBgd = '#3A414C';
+export const histogramFillInRange = activeColor;
+export const histogramFillOutRange = sliderBarColor;
// Notification
export const notificationColors = {
@@ -938,6 +940,8 @@ export const theme = {
// Plot
rangeBrushBgd,
+ histogramFillInRange,
+ histogramFillOutRange,
// Notifications
notificationColors,