How to use the ontospy.viz.utils.build_D3treeStandard function in ontospy

To help you get started, we’ve selected a few ontospy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lambdamusic / Ontospy / ontospy / viz / xx_viz_d3packHierarchy.py View on Github external
def run(graph, save_on_github=False, main_entity=None ):
	"""
	"""
	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = ";".join([s for s in graph.sources])

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "d3_packHierarchy.html", "r")
	t = Template(ontotemplate.read())

	jsontree_classes = build_D3treeStandard(0, 99, 1, graph.toplayer)
	c_total = len(graph.classes)


	if len(graph.toplayer) == 1:
		# the first element can be the single top level
		JSON_DATA_CLASSES = json.dumps(jsontree_classes[0])
	else:
		# hack to make sure that we have a default top level object
		JSON_DATA_CLASSES = json.dumps({'children': jsontree_classes, 'name': 'owl:Thing',})

	c = Context({
					"ontology": ontology,
					"main_uri" : uri,
					"STATIC_PATH": ONTOSPY_VIZ_STATIC,
					"save_on_github" : save_on_github,
					'JSON_DATA_CLASSES' : JSON_DATA_CLASSES,
github lambdamusic / Ontospy / ontospy / viz / xx_viz_sigmajs.py View on Github external
ontology = graph.ontologies[0]
        uri = ontology.uri
    except:
        ontology = None
        uri = ";".join([s for s in graph.sources])

    # ontotemplate = open("template.html", "r")
    ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "sigmajs.html", "r")

    t = Template(ontotemplate.read())

    dict_graph = build_class_json(graph.classes)
    JSON_DATA_CLASSES = json.dumps(dict_graph)

    if False:
        c_mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)
        p_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerProperties)
        s_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerSkosConcepts)
    
        c_total = len(graph.classes)
        p_total = len(graph.properties)
        s_total = len(graph.skosConcepts)
    
        # hack to make sure that we have a default top level object
        JSON_DATA_CLASSES = json.dumps({'children' : c_mylist, 'name' : 'owl:Thing', 'id' : "None" })
        JSON_DATA_PROPERTIES = json.dumps({'children' : p_mylist, 'name' : 'Properties', 'id' : "None" })
        JSON_DATA_CONCEPTS = json.dumps({'children' : s_mylist, 'name' : 'Concepts', 'id' : "None" })
    

    c = Context({
                    "ontology": ontology,
                    "main_uri" : uri,
github lambdamusic / Ontospy / ontospy / viz / xx_viz_sigmajs.py View on Github external
except:
        ontology = None
        uri = ";".join([s for s in graph.sources])

    # ontotemplate = open("template.html", "r")
    ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "sigmajs.html", "r")

    t = Template(ontotemplate.read())

    dict_graph = build_class_json(graph.classes)
    JSON_DATA_CLASSES = json.dumps(dict_graph)

    if False:
        c_mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)
        p_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerProperties)
        s_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerSkosConcepts)
    
        c_total = len(graph.classes)
        p_total = len(graph.properties)
        s_total = len(graph.skosConcepts)
    
        # hack to make sure that we have a default top level object
        JSON_DATA_CLASSES = json.dumps({'children' : c_mylist, 'name' : 'owl:Thing', 'id' : "None" })
        JSON_DATA_PROPERTIES = json.dumps({'children' : p_mylist, 'name' : 'Properties', 'id' : "None" })
        JSON_DATA_CONCEPTS = json.dumps({'children' : s_mylist, 'name' : 'Concepts', 'id' : "None" })
    

    c = Context({
                    "ontology": ontology,
                    "main_uri" : uri,
                    "STATIC_PATH": ONTOSPY_VIZ_STATIC,
                    "classes": graph.classes,
github lambdamusic / Ontospy / ontospy / viz / xx_viz_sigmajs.py View on Github external
uri = ontology.uri
    except:
        ontology = None
        uri = ";".join([s for s in graph.sources])

    # ontotemplate = open("template.html", "r")
    ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "sigmajs.html", "r")

    t = Template(ontotemplate.read())

    dict_graph = build_class_json(graph.classes)
    JSON_DATA_CLASSES = json.dumps(dict_graph)

    if False:
        c_mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)
        p_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerProperties)
        s_mylist = build_D3treeStandard(0, 99, 1, graph.toplayerSkosConcepts)
    
        c_total = len(graph.classes)
        p_total = len(graph.properties)
        s_total = len(graph.skosConcepts)
    
        # hack to make sure that we have a default top level object
        JSON_DATA_CLASSES = json.dumps({'children' : c_mylist, 'name' : 'owl:Thing', 'id' : "None" })
        JSON_DATA_PROPERTIES = json.dumps({'children' : p_mylist, 'name' : 'Properties', 'id' : "None" })
        JSON_DATA_CONCEPTS = json.dumps({'children' : s_mylist, 'name' : 'Concepts', 'id' : "None" })
    

    c = Context({
                    "ontology": ontology,
                    "main_uri" : uri,
                    "STATIC_PATH": ONTOSPY_VIZ_STATIC,
github lambdamusic / Ontospy / ontospy / viz / xx_viz_d3partitionTable.py View on Github external
"""
	"""
	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = ";".join([s for s in graph.sources])

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "d3_partitionTable.html", "r")
	t = Template(ontotemplate.read())

	c_total = len(graph.classes)

	mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)

	JSON_DATA_CLASSES = json.dumps({'children': mylist, 'name': 'owl:Thing',})

	c = Context({
					"ontology": ontology,
					"main_uri" : uri,
					"STATIC_PATH": ONTOSPY_VIZ_STATIC,
					"save_on_github" : save_on_github,
					'JSON_DATA_CLASSES' : JSON_DATA_CLASSES,
					"TOTAL_CLASSES": c_total,
				})

	rnd = t.render(c)

	return safe_str(rnd)
github lambdamusic / Ontospy / ontospy / viz / xx_viz_d3cluster.py View on Github external
"""
	"""
	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = ";".join([s for s in graph.sources])

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "d3_cluster.html", "r")
	t = Template(ontotemplate.read())

	c_total = len(graph.classes)

	mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)

	JSON_DATA_CLASSES = json.dumps({'children': mylist, 'name': 'owl:Thing',})

	c = Context({
					"ontology": ontology,
					"main_uri" : uri,
					"STATIC_PATH": ONTOSPY_VIZ_STATIC,
					"save_on_github" : save_on_github,
					'JSON_DATA_CLASSES' : JSON_DATA_CLASSES,
					"TOTAL_CLASSES": c_total,
				})

	rnd = t.render(c)

	return safe_str(rnd)
github lambdamusic / Ontospy / ontospy / viz / xx_viz_d3barHierarchy.py View on Github external
"""
	"""
	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = ";".join([s for s in graph.sources])

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ONTOSPY_VIZ_TEMPLATES + "d3_barHierarchy.html", "r")
	t = Template(ontotemplate.read())

	c_total = len(graph.classes)

	mylist = build_D3treeStandard(0, 99, 1, graph.toplayer)

	JSON_DATA_CLASSES = json.dumps({'children': mylist, 'name': 'owl:Thing',})

	c = Context({
					"ontology": ontology,
					"main_uri" : uri,
					"STATIC_PATH": ONTOSPY_VIZ_STATIC,
					"save_on_github" : save_on_github,
					'JSON_DATA_CLASSES' : JSON_DATA_CLASSES,
					"TOTAL_CLASSES": c_total,
				})

	rnd = t.render(c)

	return safe_str(rnd)