-
Notifications
You must be signed in to change notification settings - Fork 1
Graph Sources
Shadow992 edited this page Dec 7, 2017
·
10 revisions
The JSON objects to be visualized by TGView usually come from web services; currently mostly the MMT system.
Currently we have five graph sources from the MMT system.
- pgraph,
- docgraph,
- archivegraph,
- thgraph,
- models (MPDs)
TGView uses an URL which is constructed dynamically in JS to get data depending on graph type and graph data. In detail the construction looks like the following:
function createNewGraphURL(type,graphdata)
{
var serverUrl= (typeof serverBaseURL=="undefined") ? ((window.location.protocol=='file:') ? "/" : "/mh/mmt/") : serverBaseURL;
if (location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "")
serverUrl="/";
var finalDataURL=serverUrl+":jgraph/json?key=" + type + "&graphdata=" + graphdata;
return finalDataURL;
}
MMT_base_url is passed in by another Javascript, if needed. The code looks more complicated than it truely is. It just handles different execution-ways on different ways:
- Opening by File (Drag and Drop the HTML into browser; For this you may need other permissions/paths to get data from mmt)
- Opening by Localhost (Running MMT local; This requires a few changes regarding paths)
- Opening by URL (Running MMT on Server; The default case)
In general you can safely ignore the localhost and file case and only focus on the default way. An example URL generated for loading graph data looks like this:
https://mathhub.info/mh/mmt/graphs/tgview.html?type=archivegraph&graphdata=Teaching/KRMT
Whereas
- type=archivegraph is the type of graph to view (see MMT-based Graph Sources above for all possible graph types)
- graphdata=Teaching/KRMT is the archive to load/use