Skip to content

Instantly share code, notes, and snippets.

@aleksandrenko
Last active January 21, 2016 15:14
Show Gist options
  • Save aleksandrenko/42c2d6965a12df008628 to your computer and use it in GitHub Desktop.
Save aleksandrenko/42c2d6965a12df008628 to your computer and use it in GitHub Desktop.
graph editor
{"description":"graph editor","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/Z4ghHZY.png","fullscreen":false,"ajax-caching":true}
var svg = d3.select("svg");
edges = [{"startNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"endNode":{"_location":{"x":"513","y":"265"},"label":"ActivityType","_type":"node","_uid":"7e12e782-e968-88f4-d188","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#4f9cd3"},"middlePoint":{"x":"619","y":"485"},"label":"is","_snappedToMiddle":"true","_type":"edge","_uid":"42cc032f-506f-43f2-f31f"},{"startNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"610.5","y":"527.5"},"label":"can_be_done_in","_snappedToMiddle":"true","_type":"edge","_uid":"945fab65-1da3-9f8d-97b0"},{"startNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"endNode":{"_location":{"x":"430","y":"658"},"label":"ServiceProvider","_type":"node","_uid":"d01e63b5-349c-4ee9-93f4","_color":"#b6a949"},"middlePoint":{"x":"659.5","y":"528.5"},"label":"offered_by","_snappedToMiddle":"true","_type":"edge","_uid":"762c24f7-a38a-4798-7631"},{"startNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"endNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"middlePoint":{"x":"807","y":"552"},"label":"service","_snappedToMiddle":"true","_type":"edge","_uid":"7387581b-ff71-3961-ebfa"},{"startNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"692.5","y":"374.5"},"label":"at","_snappedToMiddle":"true","_type":"edge","_uid":"cfb945e4-f14f-6b6b-a3d3"},{"startNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"endNode":{"_location":{"x":"362","y":"258"},"label":"PlaceType","_type":"node","_uid":"b5e6e3d3-0aaa-6ff0-fce9","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#d93728"},"middlePoint":{"x":"429","y":"304"},"label":"is","_snappedToMiddle":"true","_type":"edge","_uid":"927eba42-09da-6589-7aa8"},{"startNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"591","y":"352"},"label":"is_in","_snappedToMiddle":"true","_type":"edge","_uid":"2df70dca-4c5b-2f53-08bd"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"middlePoint":{"x":"239","y":"594"},"label":"author","_snappedToMiddle":"true","_type":"edge","_uid":"c7cf20de-3dd4-427e-34fb"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"middlePoint":{"x":"213","y":"436"},"label":"comment_on","_snappedToMiddle":"true","_type":"edge","_uid":"c2a5924a-2a4f-19b9-19e5"},{"startNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"endNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"middlePoint":{"x":"482.5","y":"457.5"},"label":"photo_of","_snappedToMiddle":"true","_type":"edge","_uid":"59f1f289-fdfc-641b-b20c"},{"startNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"endNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"middlePoint":{"x":"818.5","y":"640"},"label":"photo_of","_snappedToMiddle":"true","_type":"edge","_uid":"e675f6f9-e39a-3836-85ec"},{"startNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"274.5","y":"345"},"label":"at","_snappedToMiddle":"true","_type":"edge","_uid":"4218d86f-dd7c-8c54-b595"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"middlePoint":{"x":"642.5","y":"553.5"},"label":"comment_on","_snappedToMiddle":"true","_type":"edge","_uid":"e59ef8e9-2f4e-d3f5-5005"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"middlePoint":{"x":"549","y":"618.5"},"label":"comment_on","_snappedToMiddle":"true","_type":"edge","_uid":"c848defc-9953-5b9f-faff"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"434.5","y":"441"},"label":"comment_on","_snappedToMiddle":"true","_type":"edge","_uid":"ed2ac8e5-e3e5-14c8-9753"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"middlePoint":{"x":"631","y":"465.5"},"label":"commented_on","_snappedToMiddle":"true","_type":"edge","_uid":"613e34af-9a6c-859c-0f2a"},{"startNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"endNode":{"_location":{"x":"430","y":"658"},"label":"ServiceProvider","_type":"node","_uid":"d01e63b5-349c-4ee9-93f4","_color":"#b6a949"},"middlePoint":{"x":"401.5","y":"595"},"label":"comment_on","_snappedToMiddle":"true","_type":"edge","_uid":"8a2b4b85-a6eb-8119-0803"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"middlePoint":{"x":"-16","y":"627"},"label":"follows","_snappedToMiddle":"true","_type":"edge","_uid":"02223f1e-3cf6-64cf-ac6e"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"middlePoint":{"x":"115","y":"737"},"label":"is_friend_with","_snappedToMiddle":"true","_type":"edge","_uid":"f3c94e3c-8cb5-9965-4980","properties":[{"type":"date","default":"now","key":"created_at"}]},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"middlePoint":{"x":"508.5","y":"615.5"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"844555a3-cca4-1e04-b493"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},"middlePoint":{"x":"300","y":"626"},"label":"likes","_snappedToMiddle":"false","_type":"edge","_uid":"391188ca-ea73-e0b6-e054"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"middlePoint":{"x":"79","y":"498"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"8a7bd427-5a63-efaa-0e9d"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"513","y":"265"},"label":"ActivityType","_type":"node","_uid":"7e12e782-e968-88f4-d188","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#4f9cd3"},"middlePoint":{"x":"309","y":"460.5"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"57504963-5bdb-9f71-da6d"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"middlePoint":{"x":"415","y":"680.5"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"2ac1f708-ddf3-c2f3-80f5"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"middlePoint":{"x":"497","y":"527.5"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"0630cc25-9ebe-10e9-338c"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"430","y":"658"},"label":"ServiceProvider","_type":"node","_uid":"d01e63b5-349c-4ee9-93f4","_color":"#b6a949"},"middlePoint":{"x":"267.5","y":"657"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"60c3cd42-2efc-eab7-bd70"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"300.5","y":"503"},"label":"likes","_snappedToMiddle":"true","_type":"edge","_uid":"18e10913-bc23-00ca-86ff"},{"startNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"endNode":{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},"middlePoint":{"x":"704","y":"462.5"},"label":"photo_of","_snappedToMiddle":"true","_type":"edge","_uid":"e3575a96-2c39-a9db-254f"},{"startNode":{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},"endNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"middlePoint":{"x":"409","y":"591"},"label":"photo_of","_snappedToMiddle":"false","_type":"edge","_uid":"d4d62b43-34bb-e3eb-97be"},{"startNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"endNode":{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},"middlePoint":{"x":"389","y":"522.5"},"label":"is","_snappedToMiddle":"true","_type":"edge","_uid":"3787939b-fa36-f19d-5d40"},{"startNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"endNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"middlePoint":{"x":"141","y":"452"},"label":"perticipates_in","_snappedToMiddle":"false","_type":"edge","_uid":"589e7fde-1dd3-f59a-cdaa"},{"startNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"endNode":{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},"middlePoint":{"x":"-32","y":"484"},"label":"organiser","_snappedToMiddle":"false","_type":"edge","_uid":"c20bc16b-2ca5-e373-2005"},{"startNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"endNode":{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},"middlePoint":{"x":"474","y":"416"},"label":"using","_snappedToMiddle":"false","_type":"edge","_uid":"c4509b3d-f3d9-bf81-9ade"},{"startNode":{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},"endNode":{"_location":{"x":"430","y":"658"},"label":"ServiceProvider","_type":"node","_uid":"d01e63b5-349c-4ee9-93f4","_color":"#b6a949"},"middlePoint":{"x":"241.5","y":"499"},"label":"service_from","_snappedToMiddle":"true","_type":"edge","_uid":"758306d1-acf5-7dbb-b114"}];
nodes = [{"_location":{"x":"105","y":"656"},"label":"Person","_type":"node","_uid":"4a43d86e-9862-277a-f5b7","properties":[{"type":"string","default":"ddd","maxLength":"100","minLength":"10","required":"true","key":"name"},{"type":"date","default":"now","key":"registered_at"},{"type":"url","key":"avatar"},{"type":"string","key":"eyes_color"}],"_color":"#b447c0","isSelected":"true"},{"_location":{"x":"912","y":"575"},"label":"Photo","_type":"node","_uid":"76040b5b-ab63-68ad-d456","_color":"#cb4743"},{"_location":{"x":"53","y":"340"},"label":"Experience","_type":"node","_uid":"6bc5b3d9-7245-a14a-c2e6","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#e52800"},{"_location":{"x":"430","y":"658"},"label":"ServiceProvider","_type":"node","_uid":"d01e63b5-349c-4ee9-93f4","_color":"#b6a949"},{"_location":{"x":"725","y":"705"},"label":"Activity","_type":"node","_uid":"d174b234-2c1a-1d8a-8396","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#56e847"},{"_location":{"x":"513","y":"265"},"label":"ActivityType","_type":"node","_uid":"7e12e782-e968-88f4-d188","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#4f9cd3"},{"_location":{"x":"373","y":"532"},"label":"Comment","_type":"node","_uid":"42b742c3-737d-7ffa-f3ed","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","maxLength":"500","minLength":"2","required":"true","key":"text"}],"_color":"#9ac362"},{"_location":{"x":"496","y":"350"},"label":"Place","_type":"node","_uid":"4b7bfa9e-dce9-9929-a521","properties":[{"type":"date","default":"now","key":"created_at"},{"type":"string","required":"true","key":"name"},{"type":"latlng","key":"location"}],"_color":"#3c3b21"},{"_location":{"x":"889","y":"399"},"label":"Service","_type":"node","_uid":"9c54c2e8-5d7e-9516-b167","_color":"#3f9ee5"},{"_location":{"x":"362","y":"258"},"label":"PlaceType","_type":"node","_uid":"b5e6e3d3-0aaa-6ff0-fce9","properties":[{"type":"string","required":"true","key":"name"}],"_color":"#d93728"}];
var height = 500;
var width = 800;
var nodeRadius = 20;
var nodeXCordinates = nodes.map(function(node) { return parseInt(node._location.x, 10); });
var nodeYCordinates = nodes.map(function(node) { return parseInt(node._location.y, 10); });
var background = svg.append('rect').classed('background', true).attr({
fill: 'white',
x: 0,
y: 0,
width: width,
height: height
});
background.on('click', function() {
console.log('background click');
console.log('create new node on (x,y): ' + d3.mouse(this));
});
var g = svg.append('g').classed('root', true);
var nodes = g.selectAll('.node').data(nodes);
var sizeYScale = d3.scale.linear().domain(d3.extent(nodeYCordinates)).range([nodeRadius, height - nodeRadius]);
var sizeXScale = d3.scale.linear().domain(d3.extent(nodeXCordinates)).range([nodeRadius, width - nodeRadius]);
var nodeElement = nodes.enter().append('g').attr({
uid: function(d) { return d._uid; }
});
nodeElement.append('circle').classed('node', true).attr({
cx: function(d) {
return sizeXScale(parseInt(d._location.x, 10));
},
cy: function(d) {
return sizeYScale(parseInt(d._location.y, 10));
},
r: nodeRadius,
fill: 'green',
stroke: 'red',
'stroke-width': '3'
}).on('click', function(node) {
console.log(node);
var clickedNode = d3.select('[uid="' + node._uid + '"]');
});
nodeElement.append('text').text(function(d) { return d.label; }).attr({
x: function(d) { return sizeXScale(parseInt(d._location.x, 10) + 28); },
y: function(d) { return sizeYScale(parseInt(d._location.y, 10)) + 7; },
fill: 'red',
color: 'blue'
});
g.exit().remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment