visgraph: with reversed relationship, reverse arrow and not title

This commit is contained in:
Mathieu Jaumotte 2021-11-03 15:56:25 +01:00
parent 58f7715643
commit 6c52233a5a
2 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import { createStore } from 'vuex' import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api' import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, splitId } from './vis-network' import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, getRelationshipDirection, splitId } from './vis-network'
const debug = process.env.NODE_ENV !== 'production' const debug = process.env.NODE_ENV !== 'production'
@ -291,7 +291,7 @@ const store = createStore({
from: `person_${r.fromPerson.id}`, from: `person_${r.fromPerson.id}`,
to: `person_${r.toPerson.id}`, to: `person_${r.toPerson.id}`,
id: 'r' + splitId(r.id,'id') + '_p' + r.fromPerson.id + '_p' + r.toPerson.id, id: 'r' + splitId(r.id,'id') + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
arrows: 'to', arrows: getRelationshipDirection(r),
color: 'lightblue', color: 'lightblue',
font: { color: '#33839d' }, font: { color: '#33839d' },
dashes: true, //physics: false, dashes: true, //physics: false,

View File

@ -289,14 +289,23 @@ const getHouseholdWidth = (member) => {
return 1 return 1
} }
/**
* Return direction edge
* @param relationship
* @returns string
*/
const getRelationshipDirection = (relationship) => {
return (!relationship.reverse) ? 'to' : 'from'
}
/** /**
* Return label edge * Return label edge
* !! always set label in title direction (arrow is reversed, see in previous method) !!
* @param relationship * @param relationship
* @returns string * @returns string
*/ */
const getRelationshipLabel = (relationship) => { const getRelationshipLabel = (relationship) => {
return (!relationship.reverse) ? return relationship.relation.title.fr
relationship.relation.title.fr : relationship.relation.reverseTitle.fr
} }
/** /**
@ -331,6 +340,7 @@ export {
adapt2vis, adapt2vis,
getHouseholdLabel, getHouseholdLabel,
getHouseholdWidth, getHouseholdWidth,
getRelationshipDirection,
getRelationshipLabel, getRelationshipLabel,
getRelationshipTitle, getRelationshipTitle,
splitId splitId