Skip to content
Snippets Groups Projects
Commit 42f8e8f3 authored by Leander's avatar Leander
Browse files

fix: no duplicated selection color

parent 2deb92d6
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ export type RadarChartConfig = ChartConfig & {
selectedData: RadarChartSelection[],
renderTooltip?: (dataPoint: any, tooltip: d3.Selection<d3.BaseType, unknown, HTMLElement, any>) => void,
axisCircles: number,
idAccessor: (d: any) => any,
attributes: { key: string, label: string }[] | [],
}
......@@ -50,6 +51,7 @@ export default class RadarChart extends Chart {
axisCircles: _config.axisCircles || 2,
selectedData: _config.selectedData || [],
attributes: _config.attributes || [],
idAccessor: _config.idAccessor || (() => null),
}
}
......@@ -155,7 +157,7 @@ export default class RadarChart extends Chart {
const preparedData = this.getPreparedData()
dataWrapper.selectAll('.data')
.data(preparedData)
.data(preparedData, (d: any) => this.config.idAccessor(d.data))
.join(
(enter: any) => {
const data = enter.append("g")
......
......@@ -131,9 +131,10 @@ function updateSelectedNodes(node: Player) {
if (selectedNodes.some(n => n.player === node.player)) {
selectedNodes.splice(selectedNodes.findIndex((n: Player) => n.player === node.player), 1)
} else {
const missingColor = schemeTableau10.find((color) => selectedNodes.findIndex(n => n._color === color) === -1)
selectedNodes.push({
...node,
_color: schemeTableau10[selectedNodes.length]
_color: missingColor ?? schemeTableau10[selectedNodes.length],
})
}
bubbleChart?.updateSelectedNodes(selectedNodes)
......@@ -145,6 +146,7 @@ function updateSelectedNodes(node: Player) {
containerHeight: 750,
margin: {top: 20, right: 20, bottom: 20, left: 20},
axisCircles: 2,
idAccessor: (d: any) => d.player,
attributes: [
{
key: 'Performance _ G+A',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment