GithubHelp home page GithubHelp logo

lee-janice / wikigraph Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 2.0 631 KB

A graph-based approach to exploring Wikipedia clickstream data; built with Neo4j, neovis.js, and React

Home Page: https://wikigraph.netlify.app/

HTML 1.73% CSS 9.58% TypeScript 87.52% JavaScript 0.13% Python 1.03%

wikigraph's Introduction

WikiGraph

A non-linear, graph-based approach to exploring the depths of Wikipedia

wikigraph

Component structure

Index
└── App
    ├── Wikigraph
    |   ├── Canvas
    |   |   └── Graph visualization
    |   |   └── Expand visualization button
    |   |   └── *Mobile context menu button*
    |   |   └── Stabilize button
    |   |   └── Center button
    |   |   └── *Context menu*
    ├── Sidebar
    |   └── Home tab
    |   └── About tab
    |   └── User manual tab
    └── Theme toggler

TODOs

Low-lift adjustments

  • Add how-to-use tab on sidebar
  • Add info tab on sidebar
  • Move "Update graph with selection" option to context menu
  • Add ability to full-screen the visualization
  • Add dark mode
  • Recenter visualization when graph rerenders
  • Fix formatting on mobile
  • Add alternative to context menu on mobile
  • Add link to Wikipedia page on the summaries
  • Allow user to double click node to expand the links
  • Allow user to add nodes to existing graph
  • Delete all unconnected nodes
  • Notify user when article is not found in the database
  • Add keep selected nodes to context menu
  • Add expand selected nodes to context menu
  • Add "find path between two nodes" option
  • Indicate when there are no nodes in the expansion when the user double-clicks a node
  • Make the buttons reusable instead of having one component for each button type
  • Make alert for no additional nodes more accurate—alert when there are no new nodes in the graph as a result of the query (currently breaks on Find path between nodes)
  • Maybe change the color of in-going and out-going links when selecting a node? Have to think about case where two connected nodes are selected; maybe only allows this when one node is selected

Clean up code

  • Refactor component/file structure
  • Use styled components instead of css file for one-offs
  • Figure out how to test deploy build to catch errors before Netlify attempts to deploy

Longer-term modifications

  • holy crap the performance for expanding a node is awful
  • Make the physics not so wonky and prone to flying off the screen; something like Neo4j Browser
  • Add filters for nodes: keep only incoming nodes, keep only outgoing nodes, keep nodes above a certain size, keep links above a certain size, keep top n nodes, etc.
  • Allow user to click and drag a node and make it stick
  • Implement cache for summaries and links
  • Add something like Elastic Search to Wikipedia articles
  • Allow user to save/export and load graphs
  • Allow user to click and drag to select all nodes inside an area
  • Make an excerpt of the summary (first sentence) appear on hovering over a node
  • Aggregate more months of data
  • Host the whole database on a server
  • Explore possibility of using the whole Wikipedia data dump with groupings by properties instead of clickstream data

Build

This project was bootstrapped with Create React App and deployed with Netlify. The visualization was created with neovis.js.

wikigraph's People

Contributors

lee-janice avatar qianzhong516 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wikigraph's Issues

Some questions and suggestions

  1. Consider using React.memo on static components since contextMenuState updates often, which causes unnecessary re-rendering. Below is an example
    <input
    type="submit"
    value="Stabilize"
    id="stabilize-button"
    onClick={() => {
    vis?.stabilize();
    }}
    />
    <input type="submit" value="Center" id="center-button" onClick={() => visNetwork?.fit()} />
    {/* Move the alert logic to the APP.tsx since it's part of the global state */}
    <Alert state={alertState}></Alert>
  2. Let's move these handlers in useEffect to a util function. It can make the file look a lot cleaner
    visNetwork.onSelect((e, nodeIds) => {
  3. Is this line doing anything else other than initializing an empty array?
    // get reference to selection so that we can use the current value in the vis event listeners
    // otherwise, the value lags behind
    const selectionRef = useRef(selection);
  4. Following on the above point, correct me if I'm wrong - selection is not being used for any re-rendering purpose, maybe we don't need to juggle between selection and its ref. Keeping the ref only is fine.

We should try our best not to disable strict mode rendering in React

I'd like to call out the implications of disabling the React strict mode. Referencing to this excerpt on React official website.

React offers a “Strict Mode” in which it calls each component’s function twice during development. By calling the component functions twice, Strict Mode helps find components that break these rules.

That's said, if you've noticed bugs due to strict-mode rendering, it indicates that you have impure components causing unpredictable bugs. We should make sure the glitch is only stemmed from the vis API itself (which I doubt), not the code we wrote.

wikigraph/src/index.tsx

Lines 9 to 11 in 88c1329

// React.StrictMode double-invokes renders, so this causes a glitch in the graph visualization
// https://stackoverflow.com/questions/48846289/why-is-my-react-component-is-rendering-twice
// <React.StrictMode>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.