mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-05-06 20:09:18 +08:00
#136 save seedLayout settings
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
:value="modelValue.initialAlgorithm"
|
||||
:clearable="false"
|
||||
className="test_fa2_initial_layout_algorithm_select"
|
||||
@change="update('initialAlgorithm', $event)"
|
||||
@change="updateInitialAlgorithm"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
@@ -51,14 +51,34 @@ export default {
|
||||
layoutSettingsComponentMap: markRaw({
|
||||
random: RandomLayoutSettings,
|
||||
circlepack: CirclePackLayoutSettings
|
||||
})
|
||||
}),
|
||||
defaultSeedLayoutSettings: {
|
||||
circular: { initialAlgorithm: 'circular' },
|
||||
random: { initialAlgorithm: 'random', seedValue: 1 },
|
||||
circlepack: {
|
||||
initialAlgorithm: 'circlepack',
|
||||
hierarchyAttributes: [],
|
||||
seedValue: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update(attributeName, value) {
|
||||
updateInitialAlgorithm(newAlgorithm) {
|
||||
const newSettings = {
|
||||
...this.modelValue
|
||||
}
|
||||
|
||||
const prevAlgorithmSettings =
|
||||
this.defaultSeedLayoutSettings[this.modelValue.initialAlgorithm]
|
||||
Object.keys(prevAlgorithmSettings).forEach(key => {
|
||||
delete newSettings[key]
|
||||
prevAlgorithmSettings[key] = this.modelValue[key]
|
||||
})
|
||||
|
||||
this.$emit('update:modelValue', {
|
||||
...this.modelValue,
|
||||
[attributeName]: value
|
||||
...newSettings,
|
||||
...this.defaultSeedLayoutSettings[newAlgorithm]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +791,6 @@ export default {
|
||||
const sensibleSettings = forceAtlas2.default.inferSettings(this.graph)
|
||||
this.settings.layout.options = {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
|
||||
@@ -24,7 +24,6 @@ export default {
|
||||
inquiry.viewOptions.layout.type === 'forceAtlas2'
|
||||
) {
|
||||
inquiry.viewOptions.layout.options.initialAlgorithm = 'circular'
|
||||
inquiry.viewOptions.layout.options.seedValue = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1350,7 +1350,6 @@ describe('GraphEditor', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 55,
|
||||
gravity: 1.5,
|
||||
scalingRatio: 1.2,
|
||||
@@ -1543,7 +1542,6 @@ describe('GraphEditor', () => {
|
||||
expect(startSpy.callCount).to.equal(2)
|
||||
expect(wrapper.vm.settings.layout.options).to.eql({
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 55,
|
||||
gravity: 1.5,
|
||||
scalingRatio: 1.2,
|
||||
@@ -1590,7 +1588,6 @@ describe('GraphEditor', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 55,
|
||||
gravity: 1.5,
|
||||
scalingRatio: 1.2,
|
||||
@@ -1949,6 +1946,7 @@ describe('GraphEditor', () => {
|
||||
layout: {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
initialIterationsAmount: 50,
|
||||
gravity: 1.5,
|
||||
scalingRatio: 1.2,
|
||||
|
||||
@@ -2248,13 +2248,17 @@ describe('graphHelper.js', () => {
|
||||
{
|
||||
key: '1',
|
||||
attributes: {
|
||||
data: { type: 0, node_id: 1, label: 'cat' }
|
||||
data: { type: 0, node_id: 1, label: 'cat' },
|
||||
x: undefined,
|
||||
y: undefined
|
||||
}
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
attributes: {
|
||||
data: { type: 0, node_id: 2, label: 'dog' }
|
||||
data: { type: 0, node_id: 2, label: 'dog' },
|
||||
x: undefined,
|
||||
y: undefined
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
@@ -149,7 +149,6 @@ describe('_migrations.js', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
@@ -280,7 +279,6 @@ describe('_migrations.js', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
|
||||
@@ -164,7 +164,6 @@ describe('storedInquiries.js', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
@@ -442,7 +441,6 @@ describe('storedInquiries.js', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
@@ -715,7 +713,6 @@ describe('storedInquiries.js', () => {
|
||||
type: 'forceAtlas2',
|
||||
options: {
|
||||
initialAlgorithm: 'circular',
|
||||
seedValue: 1,
|
||||
initialIterationsAmount: 50,
|
||||
adjustSizes: false,
|
||||
barnesHutOptimize: false,
|
||||
|
||||
Reference in New Issue
Block a user