mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix(world-map): remove categorical color option (#19781)
This commit is contained in:
parent
fcc8080ff3
commit
5e468f7a4c
@ -23,7 +23,6 @@ import { extent as d3Extent } from 'd3-array';
|
|||||||
import {
|
import {
|
||||||
getNumberFormatter,
|
getNumberFormatter,
|
||||||
getSequentialSchemeRegistry,
|
getSequentialSchemeRegistry,
|
||||||
CategoricalColorNamespace,
|
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import Datamap from 'datamaps/dist/datamaps.world.min';
|
import Datamap from 'datamaps/dist/datamaps.world.min';
|
||||||
|
|
||||||
@ -56,8 +55,6 @@ function WorldMap(element, props) {
|
|||||||
showBubbles,
|
showBubbles,
|
||||||
linearColorScheme,
|
linearColorScheme,
|
||||||
color,
|
color,
|
||||||
colorScheme,
|
|
||||||
sliceId,
|
|
||||||
} = props;
|
} = props;
|
||||||
const div = d3.select(element);
|
const div = d3.select(element);
|
||||||
div.classed('superset-legacy-chart-world-map', true);
|
div.classed('superset-legacy-chart-world-map', true);
|
||||||
@ -72,24 +69,15 @@ function WorldMap(element, props) {
|
|||||||
.domain([extRadius[0], extRadius[1]])
|
.domain([extRadius[0], extRadius[1]])
|
||||||
.range([1, maxBubbleSize]);
|
.range([1, maxBubbleSize]);
|
||||||
|
|
||||||
const linearColorScale = getSequentialSchemeRegistry()
|
const colorScale = getSequentialSchemeRegistry()
|
||||||
.get(linearColorScheme)
|
.get(linearColorScheme)
|
||||||
.createLinearScale(d3Extent(filteredData, d => d.m1));
|
.createLinearScale(d3Extent(filteredData, d => d.m1));
|
||||||
|
|
||||||
const colorScale = CategoricalColorNamespace.getScale(colorScheme);
|
const processedData = filteredData.map(d => ({
|
||||||
|
...d,
|
||||||
const processedData = filteredData.map(d => {
|
radius: radiusScale(Math.sqrt(d.m2)),
|
||||||
let color = linearColorScale(d.m1);
|
fillColor: colorScale(d.m1),
|
||||||
if (colorScheme) {
|
}));
|
||||||
// use color scheme instead
|
|
||||||
color = colorScale(d.name, sliceId);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...d,
|
|
||||||
radius: radiusScale(Math.sqrt(d.m2)),
|
|
||||||
fillColor: color,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapData = {};
|
const mapData = {};
|
||||||
processedData.forEach(d => {
|
processedData.forEach(d => {
|
||||||
|
@ -106,7 +106,6 @@ const config: ControlPanelConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
['color_picker'],
|
['color_picker'],
|
||||||
['color_scheme'],
|
|
||||||
['linear_color_scheme'],
|
['linear_color_scheme'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -127,9 +126,6 @@ const config: ControlPanelConfig = {
|
|||||||
color_picker: {
|
color_picker: {
|
||||||
label: t('Bubble Color'),
|
label: t('Bubble Color'),
|
||||||
},
|
},
|
||||||
color_scheme: {
|
|
||||||
label: t('Categorical Color Scheme'),
|
|
||||||
},
|
|
||||||
linear_color_scheme: {
|
linear_color_scheme: {
|
||||||
label: t('Country Color Scheme'),
|
label: t('Country Color Scheme'),
|
||||||
},
|
},
|
||||||
|
@ -20,14 +20,8 @@ import { rgb } from 'd3-color';
|
|||||||
|
|
||||||
export default function transformProps(chartProps) {
|
export default function transformProps(chartProps) {
|
||||||
const { width, height, formData, queriesData } = chartProps;
|
const { width, height, formData, queriesData } = chartProps;
|
||||||
const {
|
const { maxBubbleSize, showBubbles, linearColorScheme, colorPicker } =
|
||||||
maxBubbleSize,
|
formData;
|
||||||
showBubbles,
|
|
||||||
linearColorScheme,
|
|
||||||
colorPicker,
|
|
||||||
colorScheme,
|
|
||||||
sliceId,
|
|
||||||
} = formData;
|
|
||||||
const { r, g, b } = colorPicker;
|
const { r, g, b } = colorPicker;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -38,7 +32,5 @@ export default function transformProps(chartProps) {
|
|||||||
showBubbles,
|
showBubbles,
|
||||||
linearColorScheme,
|
linearColorScheme,
|
||||||
color: rgb(r, g, b).hex(),
|
color: rgb(r, g, b).hex(),
|
||||||
colorScheme,
|
|
||||||
sliceId,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user