Skip to content

Commit

Permalink
Merge pull request #357 from eve-bright/add-star-counts-to-legend
Browse files Browse the repository at this point in the history
Show total counts for all labels and rel types in legend
  • Loading branch information
pe4cey authored Apr 6, 2017
2 parents 4040cfa + 42d4be0 commit 7b770dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/browser/modules/D3Visualization/components/GrassEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,23 @@ export class GrassEditorComponent extends Component {
let pickers
let title
if (this.props.selectedLabel) {
const styleForLabel = this.graphStyle.forNode({ labels: [this.props.selectedLabel.label] })
const labelList = this.props.selectedLabel.label !== '*' ? [this.props.selectedLabel.label] : []
const styleForLabel = this.graphStyle.forNode({ labels: labelList })
const inlineStyle = {'backgroundColor': styleForLabel.get('color'), 'color': styleForLabel.get('text-color-internal')}
pickers = [this.colorPicker(styleForLabel.selector, styleForLabel), this.sizePicker(styleForLabel.selector, styleForLabel), this.captionPicker(styleForLabel.selector, styleForLabel, this.props.selectedLabel.propertyKeys)]
title = (<StyledLabelToken className='token token-label' style={inlineStyle}>{this.props.selectedLabel.label}</StyledLabelToken>)
title = (<StyledLabelToken className='token token-label' style={inlineStyle}>{this.props.selectedLabel.label || '*'}</StyledLabelToken>)
} else if (this.props.selectedRelType) {
const styleForRelType = this.graphStyle.forRelationship({type: this.props.selectedRelType.relType})
const relTypeSelector = this.props.selectedRelType.relType !== '*' ? {type: this.props.selectedRelType.relType} : {}
const styleForRelType = this.graphStyle.forRelationship(relTypeSelector)
const inlineStyle = {'backgroundColor': styleForRelType.get('color'), 'color': styleForRelType.get('text-color-internal')}
pickers = [this.colorPicker(styleForRelType.selector, styleForRelType), this.widthPicker(styleForRelType.selector, styleForRelType), this.captionPicker(styleForRelType.selector, styleForRelType, this.props.selectedRelType.propertyKeys, true)]
title = (<StyledTokenRelationshipType className='token token-relationship' style={inlineStyle}>{this.props.selectedRelType.relType}</StyledTokenRelationshipType>)
title = (<StyledTokenRelationshipType className='token token-relationship' style={inlineStyle}>{this.props.selectedRelType.relType || '*'}</StyledTokenRelationshipType>)
} else {
return null
}
return (
<StyledInlineList className='style-picker'>
<StyledInlineListItem>{title}</StyledInlineListItem>
{title}
{pickers}
</StyledInlineList>
)
Expand Down
11 changes: 3 additions & 8 deletions src/browser/modules/D3Visualization/components/styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import styled from 'styled-components'

export const legendRowHeight = 32
export const inspectorFooterContractedHeight = 21
export const inspectorFooterContractedHeight = 22

export const StyledSvgWrapper = styled.div`
line-height: 0;
Expand Down Expand Up @@ -188,12 +188,6 @@ export const StyledStatusBar = styled.div`
margin-bottom: -39px;
`

// .status-bar .btn-group {
// absolute: top 3px right 12px;
// }
// .status-bar .icon-warning-sign {
// font-size: 18px;
// }
export const StyledStatus = styled.div`
position: relative;
float: left;
Expand Down Expand Up @@ -276,6 +270,7 @@ export const StyledPickerListItem = styled(StyledInlineListItem)`
padding-right: 5px;
padding-left: 0;
vertical-align: middle;
line-height: 0;
`

export const StyledPickerSelector = styled.a`
Expand Down Expand Up @@ -303,7 +298,7 @@ export const StyledCaptionSelector = styled.a`
display: inline-block;
padding: 1px 6px;
font-size: 12px;
line-height: 12px;
line-height: 1em;
color: #9195A0;
border: 1px solid #9195A0;
overflow: hidden;
Expand Down
2 changes: 0 additions & 2 deletions src/browser/modules/D3Visualization/graphStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export default function neoGraphStyle () {
diameter: '10px'
}, {
diameter: '20px'
}, {
diameter: '35px'
}, {
diameter: '50px'
}, {
Expand Down
16 changes: 16 additions & 0 deletions src/browser/modules/D3Visualization/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export function getGraphStats (graph) {
let relTypeStats = {}
graph.nodes().forEach((node) => {
node.labels.forEach((label) => {
if (labelStats['*']) {
labelStats['*'].count = labelStats['*'].count + 1
} else {
labelStats['*'] = {
count: 1,
properties: []
}
}
if (labelStats[label]) {
labelStats[label].count = labelStats[label].count + 1
labelStats[label].properties = Object.assign({}, labelStats[label].properties, node.propertyMap)
Expand All @@ -55,6 +63,14 @@ export function getGraphStats (graph) {
})
})
graph.relationships().forEach((rel) => {
if (relTypeStats['*']) {
relTypeStats['*'].count = relTypeStats['*'].count + 1
} else {
relTypeStats['*'] = {
count: 1,
properties: []
}
}
if (relTypeStats[rel.type]) {
relTypeStats[rel.type].count = relTypeStats[rel.type].count + 1
relTypeStats[rel.type].properties = Object.assign({}, relTypeStats[rel.type].properties, rel.propertyMap)
Expand Down

0 comments on commit 7b770dd

Please sign in to comment.