Skip to content

Commit

Permalink
feat: improve graph rendering speed with image nodes (#72)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrián Insua Yañez <[email protected]>
  • Loading branch information
AdrianInsua and adrianiy authored Apr 27, 2020
1 parent 1e2350d commit 22f1c96
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/assets/visualization/components/graphGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const noEmptyLines = function(lines) {
}

const fitCaptionIntoCircle = function(node, style) {
const template = style.forNode(node).get('caption')
const shouldRenderImage = style.shouldRenderImageCaption();
const template = shouldRenderImage ? '' : style.forNode(node).get('caption')
const captionText = style.interpolate(template, node)
const fontFamily = 'sans-serif'
const fontSize = parseFloat(style.forNode(node).get('font-size'))
Expand Down
2 changes: 1 addition & 1 deletion src/components/card/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Card(props) {
setResults(null);
fecthData();
}
}, [props, fecthData]);
}, [props.query, fecthData]);

const toggleExpand = () => {
setExpanded(!expanded);
Expand Down
2 changes: 0 additions & 2 deletions src/components/card/components/Configurator/Configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function Configurator(props) {
}

const renderPropSelector = (defaultProps, className, activeProp, title, style) => {
console.log(props.styleForItem.get("color"));
return defaultProps.map((prop, i) => {
const onClick = () => {
updateStyle(props.styleForItem.selector, prop);
Expand All @@ -34,7 +33,6 @@ function Configurator(props) {
}

const renderCaptionSelector = (defaultCaptions, className, activeCaption) => {
console.log(props.styleForItem.get("caption"))
return Object.entries(defaultCaptions).map((cap, i) => {
const onClick = () => {
updateStyle(props.styleForItem.selector, {
Expand Down
16 changes: 10 additions & 6 deletions src/global/components/chart/Chart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useCallback } from 'react';
import React, { useState, useEffect, useCallback, useRef } from 'react';
import GraphComponent from './../../../assets/visualization/Graph';
import { getQuery } from './../../../service/neo.service';

Expand Down Expand Up @@ -27,6 +27,7 @@ function Chart (props) {
const [nodes, setNodes] = useState([]);
const [relationships, setRelationships] = useState([]);
const user = useSelector(state => state.currentUser);
const _prevResults = useRef(null);
let _graph;
let _autoCompleteCallback;

Expand Down Expand Up @@ -59,12 +60,15 @@ function Chart (props) {
}, [checkNodesLength]);

useEffect(() => {
const { records = [] } = props.result;
if (records && records.length > 0) {
setNodes([]);
populateDataFromRecords(records);
if (_prevResults.current !== props.result) {
const { records = [] } = props.result;
if (records && records.length > 0) {
setNodes([]);
populateDataFromRecords(records);
_prevResults.current = props.result;
}
}
}, [props, populateDataFromRecords]);
}, [populateDataFromRecords, props.result]);

const autoCompleteRelationships = async (existingNodes, newNodes) => {
if (props.autoComplete) {
Expand Down

0 comments on commit 22f1c96

Please sign in to comment.