Commit f77bcd0e authored by James Laver's avatar James Laver

Push for anoe

parent fa126ebf
......@@ -57,7 +57,7 @@ graphCpt = R.hooksComponent "Graph" cpt
ref <- R.useRef null
sigma <- useSigma ref props.sigmaSettings
useCanvasRenderer ref sigma
useData sigma props.graph
-- useData sigma props.graph
useForceAtlas2 sigma props.forceAtlas2Settings
pure $ RH.div { ref, style: {height: "95%"} } []
......@@ -159,7 +159,7 @@ sigmaSettings =
{ animationsTime: 5500.0
, autoRescale: true
, autoResize: true
, batchEdgesDrawing: false
, batchEdgesDrawing: true
, borderSize: 3.0 -- for ex, bigger border when hover
, defaultEdgeType: "curve" -- 'curve' or 'line' (curve iff ourRendering)
, defaultHoverLabelBGColor: "#fff"
......
......@@ -109,7 +109,7 @@ cleanupSigma sigma context = traverse_ kill (readSigma sigma)
errorMsg = prefix <> "Error killing sigma:"
successMsg = prefix <> "Killed sigma"
addRenderer :: forall err. Sigma.Sigma -> Renderer -> Effect (Either err Unit)
addRenderer :: forall err. Sigma.Sigma -> String -> Effect (Either err Unit)
addRenderer sigma renderer = do
ret <- Sigma.addRenderer sigma renderer
(const unit <$> ret) <$ report ret
......
'use strict';
const s = require('sigma').sigma;
const sigma = require('sigma').sigma;
const react_sigma = require('react-sigma');
const FL = require('react-sigma/lib/ForceLink');
if (typeof window === 'undefined') {
window.sigma = s;
if (typeof window !== 'undefined') {
window.sigma = sigma;
}
function _sigma(left, right, opts) {
......@@ -45,6 +47,7 @@ function killSigma(left, right, sigma) {
}
}
exports._sigma = _sigma;
exports._graphRead = graphRead;
exports._refresh = function refresh(sigma) { sigma.refresh(); };
......
......@@ -107,3 +107,23 @@ killForceAtlas2 = runEffectFn1 _killForceAtlas2
foreign import _startForceAtlas2 :: forall s. EffectFn2 Sigma s Unit
foreign import _stopForceAtlas2 :: EffectFn1 Sigma Unit
foreign import _killForceAtlas2 :: EffectFn1 Sigma Unit
newtype SigmaEasing = SigmaEasing String
sigmaEasing :: { linear :: SigmaEasing
, quadraticIn :: SigmaEasing
, quadraticOut :: SigmaEasing
, quadraticInOut :: SigmaEasing
, cubicIn :: SigmaEasing
, cubicOut :: SigmaEasing
, cubicInOut :: SigmaEasing
}
sigmaEasing =
{ linear : SigmaEasing "linear"
, quadraticIn : SigmaEasing "quadraticIn"
, quadraticOut : SigmaEasing "quadraticOut"
, quadraticInOut : SigmaEasing "quadraticInOut"
, cubicIn : SigmaEasing "cubicIn"
, cubicOut : SigmaEasing "cubicOut"
, cubicInOut : SigmaEasing "cubicInOut"
}
'use strict';
var dummyClass = 'DummyClass';
exports.edgeShapesClass = dummyClass;
exports.filterClass = dummyClass;
exports.forceAtlas2Class = dummyClass;
exports.loadGEXFClass = dummyClass;
exports.loadJSONClass = dummyClass;
exports.nOverlapClass = dummyClass;
exports.neoCypherClass = dummyClass;
exports.neoGraphItemsProducersClass = dummyClass;
exports.nodeShapesClass = dummyClass;
exports.randomizeNodePositionsClass = dummyClass;
exports.relativeSizeClass = dummyClass;
exports.sigmaClass = dummyClass;
exports.sigmaEnableSVGClass = dummyClass;
exports.sigmaEnableWebGLClass = dummyClass;
exports.forceLinkClass = dummyClass;
if (typeof window !== 'undefined') {
const SJS = require('react-sigma');
const FL = require('react-sigma/lib/ForceLink');
exports.edgeShapesClass = SJS.EdgeShapes;
exports.filterClass = SJS.Filter;
exports.forceAtlas2Class = SJS.ForceAtlas2;
exports.loadGEXFClass = SJS.LoadGEXF;
exports.loadJSONClass = SJS.LoadJSON;
exports.nOverlapClass = SJS.NOverlap;
exports.neoCypherClass = SJS.NeoCypher;
exports.neoGraphItemsProducersClass = SJS.NeoGraphItemsProducers;
exports.nodeShapesClass = SJS.NodeShapes;
exports.randomizeNodePositionsClass = SJS.RandomizeNodePositions;
exports.relativeSizeClass = SJS.RelativeSize;
exports.sigmaClass = SJS.Sigma;
exports.sigmaEnableSVGClass = SJS.SigmaEnableSVG;
exports.sigmaEnableWebGLClass = SJS.SigmaEnableWebGL;
exports.forceLinkClass = FL.default;
}
exports.setSigmaRef = function(props) {
if (props && props.sigma) {
window.sigmaGargInstance = props.sigma;
}
};
exports.getSigmaRef = function() {
return window.sigmaGargInstance;
};
exports.goToImpl = function(cam) {
return function(props) {
return cam.goTo(props);
......
......@@ -7,136 +7,16 @@ import Data.Sequence (Seq)
import Data.Sequence as Seq
import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React (ReactRef, SyntheticEventHandler)
import React.SyntheticEvent (SyntheticMouseEvent)
import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
foreign import edgeShapesClass :: forall props. ReactClass props
foreign import filterClass :: forall props. ReactClass props
foreign import forceAtlas2Class :: forall props. ReactClass props
foreign import forceLinkClass :: forall props. ReactClass props
foreign import loadGEXFClass :: forall props. ReactClass props
foreign import loadJSONClass :: forall props. ReactClass props
foreign import nOverlapClass :: ReactClass {children :: Children}
foreign import neoCypherClass :: ReactClass {children :: Children}
foreign import neoGraphItemsProducersClass :: forall props. ReactClass props
foreign import nodeShapesClass :: ReactClass {children :: Children}
foreign import randomizeNodePositionsClass :: ReactClass {children :: Children}
foreign import relativeSizeClass :: forall props. ReactClass props
foreign import sigmaClass :: ReactClass {children :: Children}
foreign import sigmaEnableSVGClass :: forall props. ReactClass props
foreign import sigmaEnableWebGLClass :: ReactClass {children :: Children}
neoCypher :: forall o. Optional o NeoCypherOptProps => NeoCypherReqProps o -> ReactElement
neoCypher props = unsafeCreateElement neoCypherClass (unsafeCoerce props) []
loadJSON :: forall o. Optional o (onGraphLoaded :: Effect Unit) => { "path" :: String | o } -> ReactElement
loadJSON props = unsafeCreateElement loadJSONClass props []
loadGEXF :: forall o. Optional o (onGraphLoaded :: Effect Unit) => { "path" :: String | o } -> ReactElement
loadGEXF props = unsafeCreateElement loadGEXFClass props []
forceLink :: forall o. Optional o ForceLinkOptProps => { | o} -> ReactElement
forceLink props = unsafeCreateElement forceLinkClass props []
nOverlap :: forall o. Optional o NOverlapOptProps => { | o } -> ReactElement
nOverlap props = unsafeCreateElement nOverlapClass (unsafeCoerce props) []
randomizeNodePositions :: ReactElement
randomizeNodePositions = createElement randomizeNodePositionsClass {} []
relativeSize :: {initialSize :: Number } -> ReactElement
relativeSize props = unsafeCreateElement randomizeNodePositionsClass (unsafeCoerce props) []
foreign import data SigmaNode :: Type
foreign import data SigmaEdge :: Type
foreign import data SigmaSettings :: Type
type NeoCypherOptProps =
( producers :: String
, onGraphLoaded :: Effect Unit
)
type NeoCypherReqProps o =
{ url :: String
, user :: String
, password :: String
, query :: String
| o
}
type ForceLinkOptProps =
( barnesHutOptimize :: Boolean
, barnesHutTheta :: Number
, adjustSizes :: Boolean
, iterationsPerRender :: Number
, linLogMode :: Boolean
, outboundAttractionDistribution :: Boolean
, edgeWeightInfluence :: Number
, scalingRatio :: Number
, strongGravityMode :: Boolean
, gravity :: Number
, alignNodeSiblings :: Boolean
, nodeSiblingsScale :: Number
, nodeSiblingsAngleMin :: Number
, worker :: Boolean
, background :: Boolean
, easing :: SigmaEasing
, randomize :: Randomize
, slowDown :: Number
, timeout :: Number
)
newtype Randomize = Randomize String
randomize ::
{ globally :: Randomize
, locally :: Randomize
, no :: Randomize
}
randomize =
{ globally : Randomize "globally"
, locally : Randomize "locally"
, no : Randomize "no"
}
newtype SigmaEasing = SigmaEasing String
sigmaEasing :: { linear :: SigmaEasing
, quadraticIn :: SigmaEasing
, quadraticOut :: SigmaEasing
, quadraticInOut :: SigmaEasing
, cubicIn :: SigmaEasing
, cubicOut :: SigmaEasing
, cubicInOut :: SigmaEasing
}
sigmaEasing =
{ linear : SigmaEasing "linear"
, quadraticIn : SigmaEasing "quadraticIn"
, quadraticOut : SigmaEasing "quadraticOut"
, quadraticInOut : SigmaEasing "quadraticInOut"
, cubicIn : SigmaEasing "cubicIn"
, cubicOut : SigmaEasing "cubicOut"
, cubicInOut : SigmaEasing "cubicInOut"
}
type NOverlapOptProps =
( nodes :: Array SigmaNode
, nodeMargin :: Number
, scaleNodes :: Number
, gridSize :: Number
, permittedExpansion :: Number
, speed :: Number
, maxIterations :: Number
, easing :: SigmaEasing
, duration :: Number
)
type SigmaNodeEvent =
{ "data" ::
{ node :: {id :: Int, label :: String}
......@@ -157,14 +37,6 @@ type SigmaEdgeEvent =
}
}
newtype Renderer = Renderer String
webgl :: Renderer
webgl = Renderer "webgl"
canvas :: Renderer
canvas = Renderer "canvas"
newtype SigmaGraphData = SigmaGraphData
{ nodes :: Array SigmaNode
, edges :: Array SigmaEdge
......@@ -221,8 +93,7 @@ foreign import data SigmaInstance' :: # Type
foreign import data CameraInstance' :: # Type
type SigmaInstance = { | SigmaInstance' }
type CameraInstance = { | CameraInstance' }
foreign import setSigmaRef :: EffectFn1 (Nullable ReactRef) Unit
foreign import getSigmaRef :: Effect SigmaInstance
foreign import sigmaOnMouseMove :: {cursorSize :: Number} -> SyntheticMouseEvent -> Effect Unit
cameras :: SigmaInstance -> Array CameraInstance
cameras = unsafeGet "cameras"
......@@ -238,7 +109,7 @@ goTo cam = runEffectFn1 (goToImpl cam)
foreign import pauseForceAtlas2 :: Effect Unit
type SigmaProps =
( renderer :: Renderer
( renderer :: String
, settings :: SigmaSettings
, style :: SigmaStyle
, graph :: SigmaGraphData
......
......@@ -23,7 +23,7 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Gargantext.Hooks.Sigmax.Types as Sigmax
import Gargantext.Hooks.Sigmax.Sigmajs (CameraProps, SigmaEasing, SigmaNode, cameras, getCameraProps, getSigmaRef, goTo, pauseForceAtlas2, sigmaEasing, sigmaOnMouseMove)
import Gargantext.Hooks.Sigmax.Sigmajs (CameraProps, SigmaNode, cameras, getCameraProps, goTo, pauseForceAtlas2, sigmaOnMouseMove)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.RandomText (words)
......@@ -266,37 +266,12 @@ defaultPalette = ["#5fa571","#ab9ba2","#da876d","#bdd3ff","#b399df","#ffdfed","#
intColor :: Int -> String
intColor i = unsafePartial $ fromJust $ defaultPalette !! (i `mod` length defaultPalette)
modCamera0 :: forall o. Optional o CameraProps =>
(Record CameraProps -> Record o) -> Effect Unit
modCamera0 f = do
s <- getSigmaRef
for_ (cameras s !! 0) $ \cam ->
void $ goTo cam (f $ getCameraProps cam)
type NOverlapConfig =
{ nodes :: Array SigmaNode
, nodeMargin :: Number
, scaleNodes :: Number
, gridSize :: Number
, permittedExpansion :: Number
, speed :: Number
, maxIterations :: Number
, easing :: SigmaEasing
, duration :: Number
}
nOverlap :: Array SigmaNode -> NOverlapConfig
nOverlap ns = { nodes : ns
, nodeMargin : 0.4
, scaleNodes : 1.5
, gridSize : 300.0
, permittedExpansion : 1.0
, speed : 7.0
, maxIterations : 8.0
, easing : sigmaEasing.quadraticOut
, duration : 1500.0
}
-- modCamera0 :: forall o. Optional o CameraProps =>
-- (Record CameraProps -> Record o) -> Effect Unit
-- modCamera0 f = do
-- s <- getSigmaRef
-- for_ (cameras s !! 0) $ \cam ->
-- void $ goTo cam (f $ getCameraProps cam)
dispLegend :: Array Legend -> ReactElement
dispLegend ary = div [] $ map dl ary
......@@ -457,22 +432,22 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ span [] [text "Edges"],input [_type "range", _id "myRange", value "90"]
]
-}
, li'
[ button [ className "btn btn-primary"
, onClick \_ -> modCamera0 (const {x: 0.0, y: 0.0, ratio: 1.0})
] [text "Center"]
]
, li [className "col-md-1"]
[ span [] [text "Zoom"],input [ _type "range"
, _id "cameraRatio"
, max "100"
, defaultValue "0"
, min "0"
, onChange \e -> do
let ratio = (100.0 - numberTargetValue e) / 100.0
modCamera0 (const {ratio})
]
]
-- , li'
-- [ button [ className "btn btn-primary"
-- , onClick \_ -> modCamera0 (const {x: 0.0, y: 0.0, ratio: 1.0})
-- ] [text "Center"]
-- ]
-- , li [className "col-md-1"]
-- [ span [] [text "Zoom"],input [ _type "range"
-- , _id "cameraRatio"
-- , max "100"
-- , defaultValue "0"
-- , min "0"
-- , onChange \e -> do
-- let ratio = (100.0 - numberTargetValue e) / 100.0pa
-- modCamera0 (const {ratio})
-- ]
-- ]
, li [className "col-md-1"]
[ span [] [text "MultiNode"]
, input
......
......@@ -3336,7 +3336,7 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-dom@^16.8.2:
react-dom@^16.8.6:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"
integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA==
......@@ -3363,7 +3363,7 @@ react-testing-library@^6.1.2:
"@babel/runtime" "^7.4.2"
dom-testing-library "^3.19.0"
react@^16.8.2:
react@^16.8.6:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
......@@ -3701,6 +3701,11 @@ shelljs@^0.8.2, shelljs@^0.8.3:
interpret "^1.0.0"
rechoir "^0.6.2"
sigma@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/sigma/-/sigma-1.2.1.tgz#2ebf3df2971715afe49ad0c08945c574bb6c5771"
integrity sha512-9Z0m1pssXv6sndPMvOzXnM1mVO73YCWDE6X5bKxJyG+9J0B9zJkgtgoBM7cnxEaJMzmrbxPceKTVpwF7cS/xqA==
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment