Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
feat(sunburst-chart): Exposing sunburst node data in tooltip config.
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroMosquera authored and tomheller committed May 4, 2021
1 parent db40009 commit 1fb9c13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ export interface DtSunburstChartOverlayData {
changeDetection: ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
exportAs: 'dt-sunburst-chart-segment',
host: {
'(mouseenter)': 'overlayTemplate && _handleMouseEnter($event)',
'(mouseleave)': 'overlayTemplate && _handleMouseLeave($event)',
},
})
export class DtSunburstChartSegment
extends DtOverlayTrigger<{
$implicit: DtSunburstChartOverlayData;
$implicit: Partial<DtSunburstChartOverlayData>;
}>
implements AfterContentInit {
/**
Expand All @@ -79,7 +83,7 @@ export class DtSunburstChartSegment
*/

@Input() overlayTemplate: TemplateRef<{
$implicit: DtSunburstChartOverlayData;
$implicit: Partial<DtSunburstChartOverlayData>;
}>;

elementReference: ElementRef;
Expand All @@ -98,9 +102,9 @@ export class DtSunburstChartSegment
ngAfterContentInit(): void {
if (this.overlayTemplate) {
this.overlay = this.overlayTemplate;

this.dtOverlayConfig = {
data: {
...this.slice.data,
label: this.slice.data.origin.label,
value: this.slice.value,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ export const sunburstChartMock = [
{
value: 3,
label: 'Red',
description: 'Red item',
},
{
value: 1,
label: 'Blue',
description: 'Blue item',
},
],
},
Expand All @@ -36,10 +38,12 @@ export const sunburstChartMock = [
{
value: 3,
label: 'Yellow',
description: 'Yellow item',
},
{
value: 1,
label: 'Blue',
description: 'Blue item',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe('DtSunburstChart', () => {
expect(overlayContainer).toBeDefined();
});

it('should display and hide an overlay when calledff', () => {
it('should display and hide an overlay when called', () => {
component.openOverlay(component.slices[0]);
fixture.detectChanges();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ describe('SunburstChart util', () => {
id: '0.0',
label: 'Blue',
origin: {
description: 'Blue item',
label: 'Blue',
value: 1,
},
Expand All @@ -430,6 +431,7 @@ describe('SunburstChart util', () => {
id: '0.1',
label: 'Red',
origin: {
description: 'Red item',
label: 'Red',
value: 3,
},
Expand All @@ -445,10 +447,12 @@ describe('SunburstChart util', () => {
origin: {
children: [
{
description: 'Red item',
label: 'Red',
value: 3,
},
{
description: 'Blue item',
label: 'Blue',
value: 1,
},
Expand Down

0 comments on commit 1fb9c13

Please sign in to comment.