Skip to content

Commit 95d85c7

Browse files
author
Andy Lee
committed
Make sure colour-scale points still have semi-transparent fill (#75)
1 parent 386c93d commit 95d85c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/perspective-viewer-d3fc/src/js/series/pointSeries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as d3 from "d3";
1010
import * as fc from "d3fc";
1111
import {tooltip} from "../tooltip/tooltip";
1212
import {groupFromKey} from "./seriesKey";
13-
import {withoutOpacity} from "./seriesColours";
13+
import {withOpacity, withoutOpacity} from "./seriesColours";
1414

1515
const symbols = [d3.symbolCircle, d3.symbolCross, d3.symbolDiamond, d3.symbolSquare, d3.symbolStar, d3.symbolTriangle, d3.symbolWye];
1616

@@ -30,7 +30,7 @@ export function pointSeries(settings, seriesKey, size, colour, symbols) {
3030
series.decorate(selection => {
3131
tooltip()(selection, settings);
3232
if (colour) {
33-
selection.style("stroke", d => withoutOpacity(colour(d.colorValue || seriesKey))).style("fill", d => colour(d.colorValue || seriesKey));
33+
selection.style("stroke", d => withoutOpacity(colour(d.colorValue || seriesKey))).style("fill", d => withOpacity(colour(d.colorValue || seriesKey)));
3434
}
3535
});
3636

packages/perspective-viewer-d3fc/src/js/series/seriesColours.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export function withoutOpacity(colour) {
3939
}
4040

4141
export function withOpacity(colour) {
42+
if (colour.includes("rgba")) return colour;
43+
4244
const toInt = offset => parseInt(colour.substring(offset, offset + 2), 16);
4345
return `rgba(${toInt(1)},${toInt(3)},${toInt(5)},0.5)`;
4446
}

0 commit comments

Comments
 (0)