-
Notifications
You must be signed in to change notification settings - Fork 2
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
Documentation: how to add a new graph / contribute #53
Comments
@extua can i work on this ? |
Thank you, yes of course.
|
Very briefly, this needs to be expanded, but: Connect to the databaseTry this connection mongosh mongodb+srv://databaseReader:[email protected]/
> use communities
> db.hourly_snapshot.aggregate([<QUERY HERE>]) Or, for an easier time, try MongoDB Compass. The connection string above is not permanent and will change when this is moved to production. Or, run MongoDB locally. Here is the documentation on creating an aggregation. Add your query to graphql_server/mongodb_queriesIn the following format: const query = [ <QUERY HERE> ];
module.exports = query; See latest_nodes_per_community.js for an example. Add it to /graphql_server/mongodb_queries with a name which describes what the query does. Add resolver to graphql_server/server.jsUnder resolvers, add an item for the query, see for example: grouped_nodes_timeseries: async (args, context) => {
const db = await context();
const pipeline = require('./mongodb_queries/grouped_nodes_timeseries.js');
return db.collection('hourly_snapshot').aggregate(pipeline).toArray();
} Add it to the GraphQL schemaSee the schema file here If your query involves creating a new schema object, add it to this file. Documentation here. Add the query to webpageIn Add the query in the format: const query_nodes_timeseries = JSON.stringify({ query: "{ grouped_nodes_timeseries { date avgNodes } }" }); And add a graph element like this: <h2>Graph 2</h2>
<figure>
<svg id="graph2_container" width="640" height="480"></svg>
<figcaption>Nodes over time</figcaption>
</figure> Create the graph in visualisations/graphsSee for example graph1.js, using the d3.js library. Add a graph caller to the pageAlong the following lines: import { createGraph2 } from './graphs/graph2.js';
createGraph2(query_nodes_timeseries).then(
(graph2) => {
graph2_container.replaceWith(graph2.node());
console.log("graph2 appended to DOM");
}
); Ok, so, when I write it all out it doesn't look like such a simple process. I'm open to suggestions on how to improve this! |
@extua so basically, I need to rewrite and expand this documentation by doing the following: Am I right? |
Following on from #52
The text was updated successfully, but these errors were encountered: