Click here to Skip to main content
15,072,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I accidentally posted this in the discussions section, moving it to Q/A.

Hi guys,

I'm doing an internship where I'm tasked with working with RDF/OWL ontologies. I've converted an OWL document to JSON-LD, which then I've used to make a tree diagram which wasn't too difficult since there are resources on the net which helped quite a bit.

What I want to do now is convert the JSON-LD data to a format with I can use with the force graph layout in D3. It looks something like this:

Hide Expand Copy Code
  "nodes": [
    {"x": 469, "y": 410},
    {"x": 493, "y": 364},
    {"x": 442, "y": 365},
    {"x": 467, "y": 314},
    {"x": 477, "y": 248},
    {"x": 425, "y": 207},
    {"x": 402, "y": 155},
    {"x": 369, "y": 196},
    {"x": 350, "y": 148},
    {"x": 539, "y": 222},
    {"x": 594, "y": 235},
    {"x": 582, "y": 185},
    {"x": 633, "y": 200}
  "links": [
    {"source":  0, "target":  1},
    {"source":  1, "target":  2},
    {"source":  2, "target":  0},
    {"source":  1, "target":  3},
    {"source":  3, "target":  2},
    {"source":  3, "target":  4},
    {"source":  4, "target":  5},
    {"source":  5, "target":  6},
    {"source":  5, "target":  7},
    {"source":  6, "target":  7},
    {"source":  6, "target":  8},
    {"source":  7, "target":  8},
    {"source":  9, "target":  4},
    {"source":  9, "target": 11},
    {"source":  9, "target": 10},
    {"source": 10, "target": 11},
    {"source": 11, "target": 12},
    {"source": 12, "target": 10}

My owl ontology is available on pastebin here (in json-ld format):[^]. If you take a peak at the context you can see that I'm modelling the ontology by the "isSubClass" property.

I know that to read json files in D3 I can use d3.json. I'm unsure how exactly to convert to the format above though.

I found this github repository[^] that says it should be able to convert to the format, but I'm having a lot of trouble running it, and I also want to keep it in javascript. Any tips/solutions? Thanks!
Updated 20-Sep-15 16:44pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900