Commit 7354b08e authored by Lukas Pravda's avatar Lukas Pravda
Browse files

fix depiction labels

parent 10a89cb4
Pipeline #87943 passed with stages
in 1 minute and 19 seconds
......@@ -97,13 +97,13 @@ class Depiction {
}
public highlightSubgraph(atoms: Array<string>, color: string = undefined) {
if (!this.atoms || !atoms) return;
if (!this.atoms || !atoms) return;
this.highlight.selectAll('*').remove();
color = color ? color : "#BFBFBF";
let atomsToHighlight = this.atoms.filter(x => atoms.includes(x.name));
this.highlight.selectAll()
.data(atomsToHighlight)
.enter()
......@@ -123,7 +123,7 @@ class Depiction {
.attr('style', `fill:none;fill-rule:evenodd;stroke:${color};stroke-width:22px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1`)
}
public addContour(data: any) {
public addContour(data: any) {
this.contour.selectAll('*').remove();
this.contour.append('div').text(`'contour data goes here: ${data}`);
......@@ -155,12 +155,14 @@ class Depiction {
*/
private appendTexts(): void {
this.structure.selectAll()
.data(this.atoms.filter(x => Object.keys(x.label).length !== 0).map(x => x.label))
.data(this.atoms.filter(x => Object.keys(x.labels).length !== 0).map(x => x.labels).reduce((a, b) => a.concat(b)))
.enter()
.append('text')
.attr('style', (x: any) => x.style)
.attr('x', (x: any) => x.x)
.attr('y', (x: any) => x.y)
.attr('dominant-baseline', (x: any) => x['dominant-baseline'])
.attr('text-anchor', (x: any) => x['text-anchor'])
.each(function (x: any) {
for (var i = 0; i < x.tspans.length; i++) {
d3.select(this)
......@@ -179,7 +181,7 @@ class Depiction {
*/
private appendClarityNodes(): void {
this.structure.selectAll()
.data(this.atoms.filter(x => Object.keys(x.label).length != 0))
.data(this.atoms.filter(x => Object.keys(x.labels).length != 0))
.enter().append('circle')
.classed('pdb-lig-env-svg-shadow-node', true)
.attr('cx', (x: any) => x.position.x)
......@@ -190,7 +192,7 @@ class Depiction {
public getCenter(ids: string[]): Vector2D {
let coords = new Array<Vector2D>();
ids.forEach(x => {
let pos = this.atoms.find(y => y.name === x).position;
coords.push(pos);
......@@ -232,16 +234,16 @@ class Depiction {
*
* @class Atom
* @param {string} name Unique atom name.
* @param {any} label Atom label
* @param {any} labels Atom label
* @param {Vector2D} position Position of the atom in 2D coordinate system.
*/
class Atom {
name: string;
label: any;
labels: any;
position: Vector2D;
constructor(item: any) {
this.name = item.name;
this.label = item.label;
this.labels = item.labels;
this.position = new Vector2D(item.x, item.y)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment