Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <template>
  2. <div id="graph"></div>
  3. </template>
  4.  
  5. <script>
  6. import vis from 'vis'
  7. import swal from 'sweetalert'
  8. import axios from 'axios'
  9. /* eslint-disable */
  10.  
  11. export default {
  12. data: () => ({
  13. shit: 'name',
  14. pasmo: {},
  15. nodes: new vis.DataSet([]),
  16. edges: new vis.DataSet([]),
  17. legends: [
  18. {
  19. name: 'Parent',
  20. image: require('@/assets/hex1.png'),
  21. },{
  22. name: 'Downlines',
  23. image: require('@/assets/yellow/0.png'),
  24. },{
  25. name: 'Downline`s downline',
  26. image: require('@/assets/blue/0.png'),
  27. }
  28. ],
  29. options: {
  30. nodes: {
  31. borderWidth:0,
  32. size:42,
  33. color: {
  34. border: '#222',
  35. background: 'transparent'
  36. },
  37. font: {
  38. color: '#111',
  39. face: 'Walter Turncoat',
  40. size: 16,
  41. strokeWidth: 1,
  42. strokeColor: '#222'
  43. }
  44. },
  45. edges: {
  46. color: {
  47. color: '#CCC',
  48. highlight: '#A22'
  49. },
  50. width: 3,
  51. length: 275,
  52. hoverWidth: .05
  53. }
  54. }
  55. }),
  56. methods: {
  57. get () {
  58. axios.get('http://localhost:8000/users/profiles/37/network-view/')
  59. .then((response) => {
  60. this.nodes.add(response.data.data.nodes)
  61. this.edges.add(response.data.data.edges)
  62. });
  63. }
  64. },
  65. created () {
  66. console.log('created')
  67. this.get()
  68. },
  69. mounted () {
  70. const container = document.querySelector('#graph')
  71.  
  72. const data = {
  73. nodes: this.nodes,
  74. edges: this.edges
  75. }
  76.  
  77. let network = new vis.Network(container, data, this.options)
  78.  
  79. network.on("doubleClick", function(properties) {
  80. var ids = properties.nodes[0]
  81. var clickedNodes = nodes.get(ids)
  82.  
  83. swal(clickedNodes.label, {
  84. icon: clickedNodes.image,
  85. button: false
  86. })
  87. })
  88. }
  89. }
  90. </script>
  91. <!-- Add "scoped" attribute to limit CSS to this component only -->
  92. <style scoped>
  93. @import url(https://fonts.googleapis.com/css?family=Walter+Turncoat);
  94.  
  95. #graph {
  96. width:900px;
  97. height:85vh;
  98. margin:auto;
  99. /*background:#EEE;
  100. border:2px solid #DDD;*/
  101. }
  102.  
  103. ul {
  104. list-style-type: none;
  105. }
  106.  
  107. .center {
  108. display: -ms-flexbox;
  109. display: -webkit-flex;
  110. display: flex;
  111.  
  112. -ms-flex-align: center;
  113. -webkit-align-items: center;
  114. -webkit-box-align: center;
  115.  
  116. align-items: center;
  117. }
  118. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement