ReGraph forms part of the front end of your application and is entirely divorced from any backend architecture. It is up to you how to pull data into your page and format it into ReGraph's object format.
ReGraph is typically kept in a stateful container within your application. This container is responsible for updating ReGraph's state and integrating it with the other components.
State can exist simply in the state of a component, or a store provided by a React Hook, or in a Redux store. ReGraph is agnostic to this and behaves well in each environment, as long as its props are set correctly. See ReGraph Re-rendering for more details.
Examples in our documentation typically assume that state is held in a component and passed to ReGraph by returning JSX from the component, as shown in the example below:
// Import various dependencies into the environment
import React from 'react';
import { Chart } from 'regraph';
import { fetchData, convertToReGraphFormat } from './myapp/helpers';
// Define the component
function App() {
// Initialize app state
const [state, setState] = React.useState({ items: {} });
React.useEffect(() => {
// Load data from a data source
fetchData().then((data) => {
const items = convertToReGraphFormat(data); // your own custom formatter
// When data is ready, set it on the component's state
setState({ items });
})
}, []);
// Create a ReGraph chart and push data into it from state
return <Chart items={state.items} />
}Note that the ReGraph source code needs to be sufficiently obfuscated before your application is distributed.