Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit 8f29938

Browse files
authored
Merge pull request #170 from ldsec/more-flexible-legend
legend is not cropped any more
2 parents 633b367 + 04d31ca commit 8f29938

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/app/modules/gb-analysis-module/panel-components/gb-cohort-landing-zone/gb-cohort-landing-zone.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { CohortService } from '../../../../services/cohort.service';
1616
import { ApiI2b2Timing } from '../../../../models/api-request-models/medco-node/api-i2b2-timing';
1717
import { QueryService } from '../../../../services/query.service';
1818

19-
const nameMaxLength = 12
19+
const nameMaxLength = 10
2020

2121
@Component({
2222
selector: 'gb-cohort-landing-zone',
@@ -103,7 +103,7 @@ export class GbCohortLandingZoneComponent implements OnInit {
103103
MessageHelper.alert('error', `Subgroup name ${this.name} can only contain alphanumerical symbols (without ö é ç ...) and underscores "_"`)
104104
return
105105
}
106-
if (this.name.length === nameMaxLength) {
106+
if (this.name.length > nameMaxLength) {
107107
MessageHelper.alert('error', `Subgroup name length cannot exceed ${nameMaxLength}`)
108108
return
109109
}

src/app/utilities/rendering/survival-curves-drawing.ts

+24-9
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ export class SurvivalCurvesDrawing {
6262
_rectHeight: number
6363
_div: Selection<HTMLDivElement, unknown, HTMLElement, any>
6464
_groupButton = new Map<string, Selection<SVGCircleElement, unknown, HTMLElement, any>>()
65+
_groupTitleText = new Map<string, Selection<SVGTextElement, unknown, HTMLElement, any>>()
6566

6667
_legendInterval: number
67-
_legendxPos: number
6868
_legendyPos: number
6969
_legendRadius: number
7070

@@ -94,7 +94,6 @@ export class SurvivalCurvesDrawing {
9494
public grid: boolean = false
9595
) {
9696

97-
this._legendxPos = (this.width - this.curves.curves.length) / 2.0 - 30
9897
this._legendyPos = -25
9998
this._legendRadius = 4
10099
this._legendInterval = 60
@@ -168,11 +167,13 @@ export class SurvivalCurvesDrawing {
168167
this._colorSet = scaleOrdinal<string, string>().domain(this.curves.curves.map(c => c.groupId)).range(colorRange)
169168

170169
// interactive title
170+
let textAndCircleOffset = 0
171+
171172
this.curves.curves.forEach((curve => {
172173
this._groupButton.set(curve.groupId, this.toggleStyle(curve.groupId,
173174
this._svgRef.append('circle')
174175

175-
.attr('cx', this._legendxPos)
176+
.attr('cx', textAndCircleOffset)
176177
.attr('cy', this._legendyPos)
177178
.attr('r', this._legendRadius)
178179
.on('mousedown', (() => {
@@ -204,15 +205,29 @@ export class SurvivalCurvesDrawing {
204205
)
205206
)
206207

207-
let title = curve.groupId.length > 8 ? curve.groupId.slice(0, 9) : curve.groupId
208-
this._svgRef.append('text')
209-
.attr('x', this._legendxPos + 7)
210-
.attr('y', this._legendyPos + 5)
211-
.text(title)
212-
this._legendxPos += this._legendInterval
208+
textAndCircleOffset += this._legendRadius + 5
209+
210+
let addedText = this._svgRef.append('text')
211+
.attr('x', textAndCircleOffset)
212+
.attr('y', this._legendyPos + 4)
213+
.text(curve.groupId)
214+
215+
textAndCircleOffset += addedText.node().getComputedTextLength() + 15
216+
this._groupTitleText.set(curve.groupId, addedText)
213217

214218
}).bind(this))
215219

220+
// center buttons and titles
221+
222+
this._groupButton.forEach(value => {
223+
224+
value.attr('cx', +value.attr('cx') + (this.width - textAndCircleOffset) / 2.0 + this.margins * 3.0)
225+
})
226+
227+
this._groupTitleText.forEach(value => {
228+
value.attr('x', +value.attr('x') + (this.width - textAndCircleOffset) / 2.0 + this.margins * 3.0)
229+
})
230+
216231
// curve references
217232
let curvePerSe = this._svgRef.append('g').attr('id', 'resultDrawing')
218233
this.curves.curves.forEach(({ groupId }) => {

0 commit comments

Comments
 (0)