diff --git a/src/app/components/AtomsRelationship.jsx b/src/app/components/AtomsRelationship.jsx index fff4dd217..5257a363a 100644 --- a/src/app/components/AtomsRelationship.jsx +++ b/src/app/components/AtomsRelationship.jsx @@ -1,86 +1,113 @@ import React, { Component, useEffect, useState, Fragment } from 'react'; -import { Chart } from 'react-google-charts' +import { Chart } from 'react-google-charts'; function AtomsRelationship(props) { - const {atomsRel} = props + const { atomsRel } = props; - const atomsAndComp = atomsRel.filter(e => e[2] !== 'atoms and selectors').map(e => { - let copy = [...e]; - copy[2] = 1; - return [...copy] - }); + const atomsAndComp = atomsRel + .filter((e) => e[2] !== 'atoms and selectors') + .map((e) => { + let copy = [...e]; + copy[2] = 1; + return [...copy]; + }); - const atomsAndSelectors = atomsRel.filter(e => e[2] === 'atoms and selectors').map(e => { + const atomsAndSelectors = atomsRel + .filter((e) => e[2] === 'atoms and selectors') + .map((e) => { + let copy = [...e]; + copy[2] = 1; + return [...copy]; + }); + + const copyatomsRel = atomsRel.map((e) => { let copy = [...e]; copy[2] = 1; - return [...copy] + return copy; }); - - const copyatomsRel = atomsRel.map(e => { let copy = [...e]; copy[2] = 1; return copy; }); const [atoms, setAtoms] = useState([...copyatomsRel]); const [atomAndSelectorCheck, setAtomAndSelectorCheck] = useState(false); const [atomAndCompCheck, setAtomAndCompCheck] = useState(false); - useEffect( () => { - if ((!atomAndSelectorCheck && !atomAndCompCheck) || (atomAndSelectorCheck && atomAndCompCheck)) { + useEffect(() => { + if ( + (!atomAndSelectorCheck && !atomAndCompCheck) || + (atomAndSelectorCheck && atomAndCompCheck) + ) { setAtoms(copyatomsRel); } else if (atomAndSelectorCheck) { setAtoms(atomsAndSelectors); } else { setAtoms(atomsAndComp); } - }, [atomAndSelectorCheck, atomAndCompCheck, props]) + }, [atomAndSelectorCheck, atomAndCompCheck, props]); return (
{atoms && ( - - + Loading Chart
} + label: { color: '#fff', fontSize: '13', fontName: 'Monaco' }, + nodePadding: 50, + width: 15, + }, + }, + tooltip: { textStyle: { color: 'white', fontSize: 0.1 } }, + }} + loader={
Loading Chart
} data={[['Atom', 'Selector', ''], ...atoms]} - rootProps={{ 'data-testid': '1' }} - /> -
- setAtomAndCompCheck(atomAndCompCheck ? false: true)}/> - - setAtomAndSelectorCheck(atomAndSelectorCheck ? false : true)} /> - -
+ rootProps={{ 'data-testid': '1' }} + /> +
+ + setAtomAndCompCheck(atomAndCompCheck ? false : true) + } + /> + + + setAtomAndSelectorCheck(atomAndSelectorCheck ? false : true) + } + /> + +
- ) - - } + )} ); } diff --git a/src/app/components/History.tsx b/src/app/components/History.tsx index ff2c15cf9..2e6c45930 100644 --- a/src/app/components/History.tsx +++ b/src/app/components/History.tsx @@ -108,8 +108,13 @@ function History(props) { .enter() .append('g') .style('fill', function (d) { - let loadTime = - d.data.stateSnapshot.children[0].componentData.actualDuration; + let loadTime; + if (d.data.stateSnapshot.children[0].componentData.actualDuration){ + loadTime = d.data.stateSnapshot.children[0].componentData.actualDuration; + } else{ + loadTime = 1; + } + if (loadTime !== undefined) { if (loadTime > 16) { diff --git a/src/app/components/PerfView.tsx b/src/app/components/PerfView.tsx index 3d1915730..c8a56c5ab 100644 --- a/src/app/components/PerfView.tsx +++ b/src/app/components/PerfView.tsx @@ -56,12 +56,6 @@ const PerfView = (props: PerfViewProps) => { '#c6e6ff', ]); - // Alternate color scaling function - // const colorScale = d3.scaleLinear() - // .domain([0, 7]) - // .range(['hsl(200,60%,60%)', 'hsl(255,30%,40%)']) - // .interpolate(d3.interpolateHcl); - // Set up circle-packing layout function const packFunc = useCallback( (data: object) => { diff --git a/src/app/components/StateRoute.tsx b/src/app/components/StateRoute.tsx index d158f46f9..8c89ba79b 100644 --- a/src/app/components/StateRoute.tsx +++ b/src/app/components/StateRoute.tsx @@ -20,7 +20,8 @@ const History = require('./History').default; const ErrorHandler = require('./ErrorHandler').default; -const NO_STATE_MSG = 'No state change detected. Trigger an event to change state'; +const NO_STATE_MSG = + 'No state change detected. Trigger an event to change state'; // eslint-disable-next-line react/prop-types interface StateRouteProps { @@ -53,7 +54,16 @@ const StateRoute = (props: StateRouteProps) => { // Map const renderComponentMap = () => { if (hierarchy) { - return ; + return ( + + ); } return
{NO_STATE_MSG}
; }; @@ -62,13 +72,15 @@ const StateRoute = (props: StateRouteProps) => { // when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized // if true involk render chart with hierarchy const renderHistory = () => { - if (hierarchy.children.length > 0) { + if (hierarchy) { return ; } - return
History graph will render on first state change
; + return
{NO_STATE_MSG}
; }; - const renderAtomsRelationship = () => ; + const renderAtomsRelationship = () => ( + + ); // the hierarchy gets set on the first click in the page // when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized @@ -80,17 +92,20 @@ const StateRoute = (props: StateRouteProps) => { return
{NO_STATE_MSG}
; }; - const perfChart = ( - - ); - - const renderPerfView = () => {perfChart}; + const renderPerfView = () => { + if (hierarchy) { + return ( + + ); + } + return
{NO_STATE_MSG}
; + }; return ( @@ -114,12 +129,15 @@ const StateRoute = (props: StateRouteProps) => { Map - {isRecoil - && ( - - Relationships - - )} + {isRecoil && ( + + Relationships + + )}