Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Separate node colors #1567

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/app/scripts/charts/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class Node extends React.Component {
}

render() {
const { blurred, focused, highlighted, label, matches = makeMap(), networks,
pseudo, rank, subLabel, scaleFactor, transform, zoomScale, exportingGraph,
const { blurred, colorKey, focused, highlighted, label, matches = makeMap(), networks,
pseudo, subLabel, scaleFactor, transform, zoomScale, exportingGraph,
showingNetworks, stack } = this.props;
const { hovered, matched } = this.state;
const nodeScale = focused ? this.props.selectedNodeScale : this.props.nodeScale;

const color = getNodeColor(rank, label, pseudo);
const color = getNodeColor(colorKey, label, pseudo);
const truncate = !focused && !hovered;
const labelTransform = focused ? `scale(${1 / zoomScale})` : '';
const labelWidth = nodeScale(scaleFactor * 4);
Expand Down
1 change: 1 addition & 0 deletions client/app/scripts/charts/nodes-chart-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class NodesChartNodes extends React.Component {
nodeCount={node.get('nodeCount')}
subLabel={node.get('subLabel')}
metric={metric(node)}
colorKey={node.get('colorKey')}
rank={node.get('rank')}
layoutPrecision={layoutPrecision}
selectedNodeScale={selectedNodeScale}
Expand Down
1 change: 1 addition & 0 deletions client/app/scripts/charts/nodes-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class NodesChart extends React.Component {
topology.forEach((node, id) => {
nextStateNodes = nextStateNodes.mergeIn([id], makeMap({
id,
colorKey: node.get('colorKey'),
label: node.get('label'),
pseudo: node.get('pseudo'),
subLabel: node.get('label_minor'),
Expand Down
9 changes: 9 additions & 0 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ export function rootReducer(state = initialState, action) {
// apply pinned searches, filters nodes that dont match
state = applyPinnedSearches(state);

// optimize color coding for nodes
const nodeRankPrefix = longestCommonPrefix(state.get('nodes')
.valueSeq()
.map(n => n.get('rank')).toJS());

state = state.update('nodes',
nodes => nodes.map(node => node.set('colorKey',
nodeRankPrefix ? node.get('rank').substr(nodeRankPrefix.length) : node.get('rank'))));

// TODO move this setting of networks as toplevel node field to backend,
// to not rely on field IDs here. should be determined by topology implementer
state = state.update('nodes', nodes => nodes.map(node => {
Expand Down