Skip to content

Commit

Permalink
Merge pull request #46 from maastrichtlawtech/dev-display-color-fix
Browse files Browse the repository at this point in the history
Dev display color fix
  • Loading branch information
shashankmc authored Dec 19, 2023
2 parents 77d05a4 + c98e513 commit 30c33dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions components/CaseLawExplorer/RenderNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export const RenderNode = (props: RenderNodeProps) => {
: element.hovered()
? fill.hovered
: visualization.nodeColor
? calculateColor(fill.default, item, graphEditorRef, visualizationRangeMap, visualization.nodeColor)
? calculateColor(fill.default, item, fullGraph, visualizationRangeMap, visualization.nodeColor)
: fill.default

let sizePerc = calculateNodeSize(item, graphEditorRef, visualizationRangeMap, visualization.nodeSize)
let sizePerc = calculateNodeSize(item, fullGraph, visualizationRangeMap, visualization.nodeSize)

if (controllerProps.activeCluster === null) {
let sum = fullGraph.nodes.filter(n => fullGraph.networkStatistics[n.id].community == item.id).length
Expand Down
2 changes: 1 addition & 1 deletion components/CaseLawExplorer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const ACTIONS = {
TEST_API: 'TEST_API'
}

const DEFAULT_LAYOUT = Graph.Layouts.cose
const DEFAULT_LAYOUT = Graph.Layouts.euler
export const NODE_LIMIT = 2000
const HELP_VIDEO_ID = 'OrzMIhLpVps'

Expand Down
16 changes: 8 additions & 8 deletions components/CaseLawExplorer/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {NODE_SIZE_RANGE_MAP} from '../constants'
import * as R from 'colay/ramda'
import Color from 'color'

import {Graph} from '../types'
export const filterEdges = (nodes: {id: string}[]) => (edges: {source: string; target: string}[]) => {
const nodeMap = R.groupBy(R.prop('id'))(nodes)
return R.filter(edge => nodeMap[edge.source] && nodeMap[edge.target])(edges)
Expand Down Expand Up @@ -77,20 +77,20 @@ export const calculateNetworkStatisticsRange = (
}
}

const getStatisticsValue = (item: any, graphEditorRef: GraphEditorRef, fieldName?: keyof typeof NODE_SIZE_RANGE_MAP) =>
graphEditorRef.current.context.localDataRef.current.networkStatistics.local?.[item.id]?.[fieldName] ??
item.data[fieldName]
const getStatisticsValue = (item: any, fullGraph: Graph, fieldName?: keyof typeof NODE_SIZE_RANGE_MAP) => {
return fullGraph.networkStatistics?.[item.id]?.[fieldName] ?? item.data[fieldName]
}

export const calculateNodeSize = (
item: object,
graphEditorRef: GraphEditorRef,
fullGraph: Graph,
rangeMap: any,
fieldName?: keyof typeof NODE_SIZE_RANGE_MAP
) => {
if (!fieldName) {
return 0 //rangeMap.size[0]
}
const value = getStatisticsValue(item, graphEditorRef, fieldName)
const value = getStatisticsValue(item, fullGraph, fieldName)
const fieldRange = rangeMap[fieldName]
const sizeRangeGap = rangeMap.size[1] - rangeMap.size[0]
const fieldRangeGap = fieldRange[1] - fieldRange[0]
Expand All @@ -105,7 +105,7 @@ export const calculateNodeSize = (
export const calculateColor = (
color: number,
item: object,
graphEditorRef: GraphEditorRef,
fullGraph: Graph,
rangeMap: any,
fieldName?: keyof typeof NODE_SIZE_RANGE_MAP
) => {
Expand All @@ -115,7 +115,7 @@ export const calculateColor = (
const fieldRange = rangeMap[fieldName]
const sizeRangeGap = rangeMap.size[1] - rangeMap.size[0]
const fieldRangeGap = fieldRange[1] - fieldRange[0]
const value = getStatisticsValue(item, graphEditorRef, fieldName)
const value = getStatisticsValue(item, fullGraph, fieldName)
const fieldRangeValue = (value ?? fieldRange[0]) - fieldRange[0]
if (fieldRangeGap === 0) {
return perc2color(color, 0)
Expand Down

0 comments on commit 30c33dc

Please sign in to comment.