Skip to content

Commit

Permalink
Match node and link colors
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Nov 8, 2024
1 parent 410f1d0 commit fc2018b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export default function transformProps(
const refs: Refs = {};
const metricLabel = getMetricLabel(metric);
const colorFn = CategoricalColorNamespace.getScale(colorScheme as string);
const firstColor = colorFn.range()[0];
const nodes: { [name: string]: number } = {};
const categories: Set<string> = new Set();
const echartNodes: EChartGraphNode[] = [];
Expand Down Expand Up @@ -256,11 +257,10 @@ export default function transformProps(
: undefined;
const sourceNodeColor = sourceCategoryName
? colorFn(sourceCategoryName)
: colorFn('node');
: firstColor;
const targetNodeColor = targetCategoryName
? colorFn(targetCategoryName)
: colorFn('node');
const linkColor = colorFn('link');
: firstColor;

const sourceNode = getOrCreateNode(
sourceName,
Expand All @@ -283,7 +283,7 @@ export default function transformProps(
target: targetNode.id,
value,
lineStyle: {
color: linkColor,
color: firstColor,
},
emphasis: {},
select: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('EchartsGraph transformProps', () => {
links: [
{
emphasis: { lineStyle: { width: 12 } },
lineStyle: { width: 6, color: '#ff7f0e' },
lineStyle: { width: 6, color: '#1f77b4' },
select: {
lineStyle: { opacity: 1, width: 9.600000000000001 },
},
Expand All @@ -154,7 +154,7 @@ describe('EchartsGraph transformProps', () => {
},
{
emphasis: { lineStyle: { width: 5 } },
lineStyle: { width: 1.5, color: '#ff7f0e' },
lineStyle: { width: 1.5, color: '#1f77b4' },
select: { lineStyle: { opacity: 1, width: 5 } },
source: '2',
target: '3',
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('EchartsGraph transformProps', () => {
{
id: '0',
itemStyle: {
color: '#2ca02c',
color: '#1f77b4',
},
col: 'source_column',
name: 'source_value',
Expand All @@ -244,7 +244,7 @@ describe('EchartsGraph transformProps', () => {
{
id: '1',
itemStyle: {
color: '#d62728',
color: '#ff7f0e',
},
col: 'target_column',
name: 'target_value',
Expand Down

0 comments on commit fc2018b

Please sign in to comment.