Skip to content

Commit 7ccf51f

Browse files
committed
World color option for SimpleMap
1 parent 7a1d467 commit 7ccf51f

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/main/resources/static/css/shared/controls.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,14 @@ output {
347347
text-align: end;
348348
}
349349
}
350+
351+
.dv-color-input {
352+
border: 1px solid var(--border-color);
353+
border-radius: var(--border-radius);
354+
background-color: var(--bg-color);
355+
cursor: pointer;
356+
357+
&:focus {
358+
outline: 1px solid var(--primary);
359+
}
360+
}

src/main/resources/static/js/shared/modules/inputFactories.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,14 @@ export default {
147147

148148
return createElement("div", { className: "dv-switch" }, [input, track]);
149149
},
150+
151+
color(key, value, _, onchange) {
152+
return createElement("input", {
153+
name: key,
154+
type: "color",
155+
value,
156+
className: "dv-color-input",
157+
onchange,
158+
});
159+
},
150160
};

src/main/resources/static/js/widgets/charts/SimpleMap.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export default class SimpleMap extends D3Visualization {
66
type: "SimpleMap",
77
title: "Simple Map",
88
generator: { id: "" },
9-
options: {},
9+
options: {
10+
worldColor: "#b8b8b8",
11+
},
1012
icon: "bi bi-map",
1113
w: 8,
1214
h: 6,
@@ -21,6 +23,10 @@ export default class SimpleMap extends D3Visualization {
2123
label: "Generator",
2224
options: () => getGeneratorOptions("MapCoordinates"),
2325
},
26+
"options.worldColor": {
27+
type: "color",
28+
label: "World color",
29+
},
2430
};
2531
static previewData = [
2632
{
@@ -41,6 +47,8 @@ export default class SimpleMap extends D3Visualization {
4147

4248
constructor(root, config) {
4349
super(root, config, { top: 0, right: 0, bottom: 0, left: 0 });
50+
51+
this.worldColor = config.options.worldColor || "#b8b8b8";
4452
}
4553

4654
async fetch() {
@@ -71,7 +79,7 @@ export default class SimpleMap extends D3Visualization {
7179
.join("path")
7280
.attr("class", "world")
7381
.attr("d", path)
74-
.attr("fill", "#b8b8b8")
82+
.attr("fill", this.worldColor)
7583
.style("stroke", "#fff")
7684
.style("stroke-width", 0.1);
7785

0 commit comments

Comments
 (0)