Skip to content

Commit fcb14af

Browse files
Merge pull request #2195 from Idkirsch/issue-1579/filled-sankey-zero-add
Fix non-dashed empty results after empty segment in makeSankeySegments
2 parents 84232fa + ee2f7cf commit fcb14af

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.spec.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,82 @@ describe('makeSankeySegments()', () => {
537537
},
538538
]);
539539
});
540+
541+
it('handles adding nothing to empty stream', () => {
542+
const result = makeSankeySegments([
543+
{
544+
change: 0,
545+
filter: {
546+
config: {
547+
fields: {
548+
first_name: 'aaaaaaaaaaa',
549+
},
550+
organizations: [1],
551+
},
552+
op: OPERATION.ADD,
553+
type: FILTER_TYPE.PERSON_DATA,
554+
},
555+
matches: 0,
556+
result: 0,
557+
},
558+
{
559+
change: 100,
560+
filter: {
561+
config: {
562+
fields: {
563+
first_name: 'a',
564+
},
565+
organizations: [1],
566+
},
567+
op: OPERATION.ADD,
568+
type: FILTER_TYPE.PERSON_DATA,
569+
},
570+
matches: 100,
571+
result: 100,
572+
},
573+
]);
574+
575+
expect(result).toEqual(<SankeySegment[]>[
576+
{
577+
kind: SEGMENT_KIND.EMPTY,
578+
},
579+
{
580+
kind: SEGMENT_KIND.PSEUDO_ADD,
581+
main: null,
582+
side: {
583+
style: SEGMENT_STYLE.STROKE,
584+
width: 0,
585+
},
586+
stats: {
587+
change: 0,
588+
input: 0,
589+
matches: 0,
590+
output: 0,
591+
},
592+
},
593+
{
594+
kind: SEGMENT_KIND.ADD,
595+
main: {
596+
style: SEGMENT_STYLE.FILL,
597+
width: 0.05,
598+
},
599+
side: {
600+
style: SEGMENT_STYLE.FILL,
601+
width: 0.95,
602+
},
603+
stats: {
604+
change: 100,
605+
input: 0,
606+
matches: 100,
607+
output: 100,
608+
},
609+
},
610+
{
611+
kind: SEGMENT_KIND.EXIT,
612+
output: 100,
613+
style: SEGMENT_STYLE.FILL,
614+
width: 1,
615+
},
616+
]);
617+
});
540618
});

src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function makeSankeySegments(
7676
kind: SEGMENT_KIND.PSEUDO_ADD,
7777
main: null,
7878
side: {
79-
style: SEGMENT_STYLE.FILL,
79+
style: change == 0 ? SEGMENT_STYLE.STROKE : SEGMENT_STYLE.FILL,
8080
width: change / maxPeople,
8181
},
8282
stats,

0 commit comments

Comments
 (0)