-
Notifications
You must be signed in to change notification settings - Fork 9
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
Importing graph-explorer via Unpkg returns an error #25
Comments
Hi @lolive! Here is a full basic working example using unpkg for all imports, to illustrate how you can run the app: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Graph Explorer</title>
<!-- Import "Font Awesome" for the icons -->
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/css/font-awesome.min.css"
/>
<!-- Basic style, just that we can see something -->
<style>
h1 {
height: 42px;
}
#graph-explorer {
width: 100%;
height: calc(100vh - 100px);
}
</style>
</head>
<body>
<h1>Graph Explorer demo</h1>
<!-- This is where Graph Explorer will be mounted -->
<div id="graph-explorer"></div>
<!-- Import required libraries -->
<script src="https://unpkg.com/[email protected]/dist/graph-explorer-full.min.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<!-- Tell where to mount the app -->
<script>
// Some configuration for the Graph Explorer
const graphExplorerConfig = {
// Replace this with your own SPARQL endpoint
endpointUrl: "https://ld.admin.ch/query",
acceptBlankNodes: true,
dataLabelProperty: "<http://schema.org/name> | rdfs:label",
schemaLabelProperty: "<http://schema.org/name> | rdfs:label",
language: "en",
languages: [
{ code: "en", label: "English" },
{ code: "de", label: "German" },
{ code: "fr", label: "French" },
{ code: "it", label: "Italian" },
],
};
const SparqlDialect = GraphExplorer.OWLStatsSettings;
SparqlDialect.dataLabelProperty = graphExplorerConfig.dataLabelProperty;
SparqlDialect.schemaLabelProperty =
graphExplorerConfig.schemaLabelProperty;
const onWorkspaceMounted = async (workspace) => {
if (!workspace) {
return;
}
const model = workspace.getModel();
model.importLayout({
dataProvider: new GraphExplorer.SparqlDataProvider(
{
endpointUrl: graphExplorerConfig.endpointUrl,
acceptBlankNodes: graphExplorerConfig.acceptBlankNodes,
imagePropertyUris: ["http://xmlns.com/foaf/0.1/img"],
queryMethod: GraphExplorer.SparqlQueryMethod.GET,
},
SparqlDialect
),
});
};
const props = {
ref: onWorkspaceMounted,
languages: graphExplorerConfig.languages,
language: graphExplorerConfig.language,
};
// Tell React to mount the app in the div with the id "graph-explorer"
ReactDOM.render(
React.createElement(GraphExplorer.Workspace, props),
document.getElementById("graph-explorer")
);
</script>
</body>
</html> Some notes:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to try graph-explorer in one of my web project.
In that project, files are served statically, so I do not have any NodeJS instance.
Usually, in that case, my html points the js libs at Unpkg.com, which handles the delivery of a browser-ready version of libs I need, taking care of all the require/imports/modules mess.
I tried this HTML for graph-explorer:
and got this error:
In parallel, I built locally from sources the file dist/graph-explorer.js, and pointing at my built version of the file from my .html returns the same error.
Any idea what I did wrong?
The text was updated successfully, but these errors were encountered: