Skip to content

Commit 90e9f3c

Browse files
committed
handle stateless
1 parent f0ce2f7 commit 90e9f3c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/app/actions/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
12
import * as types from '../constants/actionTypes';
23

34
export const toggleMode = mode => ({

src/app/components/Chart.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
/* eslint-disable max-len */
3+
/* eslint-disable @typescript-eslint/ban-types */
4+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
15
/* eslint-disable eqeqeq */
26
/* eslint-disable react/prop-types */
37
/* eslint-disable no-mixed-operators */
@@ -10,7 +14,6 @@
1014
/* eslint-disable no-use-before-define */
1115
/* eslint-disable react/no-string-refs */
1216

13-
1417
import React, { Component } from 'react';
1518
import * as d3 from 'd3';
1619

@@ -19,15 +22,22 @@ import * as d3 from 'd3';
1922
*/
2023
const colors = ['#95B6B7', '#475485', '#519331', '#AA5039', '#8B2F5F', '#C5B738', '#858DFF', '#FF8D02', '#FFCD51', '#ACDAE6', '#FC997E', '#CF93AD', '#AA3939', '#AA6C39', '#226666', '#2C4870'];
2124

25+
const filter = (data:any[]) => {
26+
console.log('data from filter', data)
27+
if (data[0].children && data[0].state === 'stateless') {
28+
return filter(data[0].children);
29+
}
30+
return JSON.stringify(data[0].state);
31+
};
32+
2233
interface ChartProps {
2334
hierarchy: Record<string, unknown>;
2435
}
2536

2637
let root = {};
2738
class Chart extends Component {
2839
/**
29-
*
30-
* @method maked3Tree :Creates a new D3 Tree
40+
* @method maked3Tree :Creates a new D3 Tree
3141
*/
3242
constructor(props:ChartProps) {
3343
super(props);
@@ -80,6 +90,7 @@ class Chart extends Component {
8090

8191
// if we consider the container for our radial node graph as a box encapsulating
8292
// half of this container width is essentially the radius of our radial node graph
93+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8394
const radius = width / 2;
8495

8596
// d3.hierarchy constructs a root node from the specified hierarchical data
@@ -145,11 +156,12 @@ class Chart extends Component {
145156
.duration(50)
146157
.style('opacity', 0.9);
147158

148-
tooltipDiv.html(JSON.stringify(d.data.stateSnapshot.children[0].state), this)
159+
tooltipDiv.html(filter(d.data.stateSnapshot.children), this)
149160
.style('left', (d3.event.pageX - 90) + 'px')
150161
.style('top', (d3.event.pageY - 65) + 'px');
151162
})
152163
// eslint-disable-next-line no-unused-vars
164+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
153165
.on('mouseout', function (d:any) {
154166
d3.select(this)
155167
.transition()

0 commit comments

Comments
 (0)