mirror of
https://github.com/simon987/music-graph-ui.git
synced 2025-04-16 00:26:42 +00:00
UI tweaks
This commit is contained in:
parent
2efff0e15e
commit
8c45a7f519
@ -40,6 +40,7 @@ export function MusicGraph(data) {
|
|||||||
|
|
||||||
this.nodeById = new Map()
|
this.nodeById = new Map()
|
||||||
this.expandedNodes = new Set()
|
this.expandedNodes = new Set()
|
||||||
|
this.graphSize = 0
|
||||||
this.nodes = []
|
this.nodes = []
|
||||||
this.links = []
|
this.links = []
|
||||||
this._originSet = false
|
this._originSet = false
|
||||||
@ -197,6 +198,7 @@ export function MusicGraph(data) {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.newNodes.length > 0) {
|
if (data.newNodes.length > 0) {
|
||||||
this.expandedNodes.add(d.id)
|
this.expandedNodes.add(d.id)
|
||||||
|
this.graphSize++
|
||||||
this.addNodes(data.newNodes, data.relations, d.id)
|
this.addNodes(data.newNodes, data.relations, d.id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -428,6 +430,13 @@ export function MusicGraph(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nodesToAdd.length > 100) {
|
||||||
|
// That's a lot of nodes, increase spacing
|
||||||
|
this.graphSize++
|
||||||
|
}
|
||||||
|
if (nodesToAdd.length > 200) {
|
||||||
|
this.graphSize++
|
||||||
|
}
|
||||||
this.nodes.push(...nodesToAdd)
|
this.nodes.push(...nodesToAdd)
|
||||||
this.links.push(...linksToAdd)
|
this.links.push(...linksToAdd)
|
||||||
|
|
||||||
@ -471,7 +480,10 @@ export function MusicGraph(data) {
|
|||||||
// Remove nodes
|
// Remove nodes
|
||||||
idSetToRemove.forEach(id => {
|
idSetToRemove.forEach(id => {
|
||||||
this.nodeById.delete(id)
|
this.nodeById.delete(id)
|
||||||
this.expandedNodes.delete(id)
|
if (this.expandedNodes.has(id)) {
|
||||||
|
this.expandedNodes.delete(id)
|
||||||
|
this.graphSize--
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.nodes = this.nodes.filter(d => !idSetToRemove.has(d.id))
|
this.nodes = this.nodes.filter(d => !idSetToRemove.has(d.id))
|
||||||
|
|
||||||
@ -484,7 +496,7 @@ export function MusicGraph(data) {
|
|||||||
.force('link', d3.forceLink(this.links)
|
.force('link', d3.forceLink(this.links)
|
||||||
.id(d => d.id)
|
.id(d => d.id)
|
||||||
.strength(l => l.weight)
|
.strength(l => l.weight)
|
||||||
.distance(d => (1.12 / d.weight) * 80 * (this.expandedNodes.size + 1))
|
.distance(d => (1.12 / d.weight) * 80 * (this.graphSize))
|
||||||
)
|
)
|
||||||
|
|
||||||
this.simulation.alphaTarget(0.03).restart()
|
this.simulation.alphaTarget(0.03).restart()
|
||||||
@ -550,6 +562,10 @@ export function MusicGraph(data) {
|
|||||||
this.svg.classed('pan-mode', false)
|
this.svg.classed('pan-mode', false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.body.onmouseleave = () => {
|
||||||
|
this.svg.classed('pan-mode', false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setOrigin = function () {
|
this._setOrigin = function () {
|
||||||
@ -565,6 +581,7 @@ export function MusicGraph(data) {
|
|||||||
|
|
||||||
// Remember that we expanded origin node
|
// Remember that we expanded origin node
|
||||||
this.expandedNodes.add(this.originNode.id)
|
this.expandedNodes.add(this.originNode.id)
|
||||||
|
this.graphSize++
|
||||||
}
|
}
|
||||||
|
|
||||||
this._getNodeColor = function (node) {
|
this._getNodeColor = function (node) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-main>
|
<el-main>
|
||||||
<span>This is the about page</span>
|
<span>This is the about page</span>
|
||||||
<object data="/static/diagram.svg" type="image/svg+xml"></object>
|
<object data="/static/data.svg" type="image/svg+xml"></object>
|
||||||
</el-main>
|
</el-main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ export default {
|
|||||||
#playing {
|
#playing {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: calc(100% - 30px);
|
top: calc(100% - 30px);
|
||||||
left: calc(1% + 12em);
|
left: calc(20px + 12em);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
color: rgba(255, 23, 68, 0.69);
|
color: rgba(255, 23, 68, 0.69);
|
||||||
font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||||
|
@ -99,7 +99,6 @@ export default {
|
|||||||
svg .link {
|
svg .link {
|
||||||
stroke: #FFE082;
|
stroke: #FFE082;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
stroke-opacity: 0.3;
|
|
||||||
stroke-width: 1;
|
stroke-width: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
>
|
>
|
||||||
<template slot-scope="{ item }">
|
<template slot-scope="{ item }">
|
||||||
<div class="value" v-bind:class="{tag: item.type === 'tag'}">{{ item.value }} <span class="year"
|
<div class="value" v-bind:class="{tag: item.type === 'tag'}">{{ item.value }} <span class="year"
|
||||||
v-if="item.year">[{{item.year}}]</span>
|
v-if="item.year">[{{item.year}}]</span>
|
||||||
<span v-if="item.type === 'tag'" class="year">[tag]</span>
|
<span v-if="item.type === 'tag'" class="year">[tag]</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="comment" v-if="item.comment">{{ item.comment }}</span>
|
<span class="comment" v-if="item.comment">{{ item.comment }}</span>
|
||||||
@ -77,12 +77,20 @@ export default {
|
|||||||
.inline-input {
|
.inline-input {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 600px) {
|
||||||
|
.inline-input {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.comment {
|
.comment {
|
||||||
color: #919ba3;
|
color: #919ba3;
|
||||||
margin-top: -0.8em;
|
margin-top: -0.8em;
|
||||||
padding-left: 0.3em;
|
padding-left: 0.3em;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.year {
|
.year {
|
||||||
color: #828c94;
|
color: #828c94;
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
|
@ -15,7 +15,7 @@ export default {
|
|||||||
#watermark {
|
#watermark {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: calc(100% - 30px);
|
top: calc(100% - 30px);
|
||||||
left: 1%;
|
left: 20px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
color: rgba(0,0,0,0.67);
|
color: rgba(0,0,0,0.67);
|
||||||
font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user