Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Fix scatterplot and histogram fill colors. (#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
BinarySoftware authored Apr 4, 2021
1 parent 75a569e commit 2b60985
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const X_AXIS_LABEL_WIDTH = 10
const Y_AXIS_LABEL_WIDTH = 10
const ANIMATION_DURATION = 1000
const LINEAR_SCALE = 'linear'
const LIGHT_PLOT_COLOR = '#00E890'
const DARK_PLOT_COLOR = '#E0A63B'
const DEFAULT_NUMBER_OF_BINS = 50
const BUTTON_HEIGHT = 25

Expand Down Expand Up @@ -516,11 +514,10 @@ class Histogram extends Visualization {

this.yAxis.call(yAxis)

let accentColor = LIGHT_PLOT_COLOR

if (document.getElementById('root').classList.contains('dark')) {
accentColor = DARK_PLOT_COLOR
}
const fill = d3
.scaleSequential()
.interpolator(d3.interpolateViridis)
.domain([0, d3.max(bins, d => d.x0)])

const items = this.plot.selectAll('rect').data(bins)

Expand All @@ -531,7 +528,7 @@ class Histogram extends Visualization {
.attr('transform', d => 'translate(' + x(d.x0) + ',' + y(d.length) + ')')
.attr('width', d => x(d.x1) - x(d.x0))
.attr('height', d => this.canvas.inner.height - y(d.length))
.style('fill', accentColor)
.style('fill', d => fill(d.x0))

items.exit().remove()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ class ScatterPlot extends Visualization {

let sizeScaleMultiplier = 100

let color = this.theme.get('accent')
let fillColor = `rgba(${color.red * 255},${color.green * 255},${color.blue * 255},0.8)`

scatter
.selectAll('dataPoint')
.data(dataPoints)
Expand All @@ -468,7 +471,7 @@ class ScatterPlot extends Visualization {
'transform',
d => 'translate(' + scaleAndAxis.xScale(d.x) + ',' + scaleAndAxis.yScale(d.y) + ')'
)
.style('fill', d => d.color ?? '#00000080')
.style('fill', d => d.color ?? fillColor)

if (points.labels === VISIBLE_POINTS) {
scatter
Expand Down

0 comments on commit 2b60985

Please sign in to comment.