Skip to content

Commit 60864f4

Browse files
committed
Add ability for reference photopeak lines to have individually specified colors.
1 parent 8893d5d commit 60864f4

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

d3_resources/SpectrumChartD3.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ SpectrumChartD3 = function(elem, options) {
8585
if( (typeof this.options.doubleClickDelay) !== 'number' ) this.options.doubleClickDelay = 500;
8686

8787
this.options.refLineTopPad = 30;
88+
this.options.refLineWidth = 1;
89+
this.options.refLineWidthHover = 2;
90+
this.options.featureLineWidth = 2;
8891

8992
self.options.logYFracTop = 0.05;
9093
self.options.logYFracBottom = 0.025;
@@ -3983,7 +3986,7 @@ SpectrumChartD3.prototype.drawHighlightRegions = function(){
39833986
* -------------- Reference Gamma Lines Functions --------------
39843987
*/
39853988
SpectrumChartD3.prototype.drawRefGammaLines = function() {
3986-
/*Drawing of the refrenece lines is super duper un-optimized!!! */
3989+
/*Drawing of the reference lines is super duper un-optimized!!! */
39873990
const self = this;
39883991

39893992
if( !self.refLines || !self.refLines.length || !self.refLines[0].lines || !self.refLines[0].lines.length ) {
@@ -4013,13 +4016,13 @@ SpectrumChartD3.prototype.drawRefGammaLines = function() {
40134016
var gy = self.vis.selectAll("g.ref")
40144017
.data( reflines, function(d){return d.id;} )
40154018
.attr("transform", tx)
4016-
.attr("stroke-width",1);
4019+
.attr("stroke-width", self.options.refLineWidth );
40174020

40184021
var gye = gy.enter().insert("g", "a")
40194022
.attr("class", "ref")
40204023
.attr("transform", tx);
40214024

4022-
function stroke(d){ return d.parent.color; };
4025+
function stroke(d){ return d.color ? d.color : d.parent.color; };
40234026

40244027
function dashfunc(d){
40254028
const particles = ["gamma", "xray", "beta", "alpha", "positron", "electronCapture", "cascade-sum", "S.E.", "D.E." ];
@@ -4413,8 +4416,10 @@ SpectrumChartD3.prototype.updateMouseCoordText = function() {
44134416
self.refLineInfoTxt.attr("transform", tx );
44144417
}
44154418

4416-
4417-
d3.select(nearestline).attr("stroke-width",2).select("line").attr("dx", "-1" );
4419+
d3.select(nearestline)
4420+
.attr("stroke-width",self.options.refLineWidthHover)
4421+
.select("line")
4422+
.attr("dx", "-1" );
44184423
}
44194424

44204425
SpectrumChartD3.prototype.setShowMouseStats = function(d) {
@@ -8174,7 +8179,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
81748179
if( !self.doubleEscape && doubleEscapeEnergy >= 0 ) {
81758180
self.doubleEscape = self.vis.append("line") /* create double escape line */
81768181
.attr("class", "peakLine")
8177-
.attr("stroke-width", 2)
8182+
.attr("stroke-width", self.options.featureLineWidth)
81788183
.attr("x1", doubleEscapePix)
81798184
.attr("x2", doubleEscapePix)
81808185
.attr("y1", 0)
@@ -8235,7 +8240,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
82358240
/* draw compton edge line here */
82368241
self.comptonPeak = self.vis.append("line")
82378242
.attr("class", "peakLine")
8238-
.attr("stroke-width", 2)
8243+
.attr("stroke-width", self.options.featureLineWidth)
82398244
.attr("y1", 0);
82408245
self.comptonPeakText = self.vis.append("text")
82418246
.attr("class", "peakText")
@@ -8294,7 +8299,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
82948299
/* draw compton edge line here */
82958300
self.comptonEdge = self.vis.append("line")
82968301
.attr("class", "peakLine")
8297-
.attr("stroke-width", 2);
8302+
.attr("stroke-width", self.options.featureLineWidth);
82988303
self.comptonEdgeText = self.vis.append("text")
82998304
.attr("class", "peakText")
83008305
.text( self.options.txt.comptonEdge );
@@ -8386,7 +8391,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
83868391
/* draw compton edge line here */
83878392
self.clickedSumPeak = self.vis.append("line")
83888393
.attr("class", "peakLine")
8389-
.attr("stroke-width", 2);
8394+
.attr("stroke-width", self.options.featureLineWidth);
83908395
self.clickedSumPeakMeas = self.vis.append("text")
83918396
.attr("class", "peakText");
83928397
}
@@ -8435,7 +8440,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
84358440
/* draw left-sum peak line here */
84368441
self.leftSumPeak = self.vis.append("line")
84378442
.attr("class", "peakLine")
8438-
.attr("stroke-width", 2);
8443+
.attr("stroke-width", self.options.featureLineWidth);
84398444
self.leftSumPeakText = self.vis.append("text")
84408445
.attr("class", "peakText")
84418446
.text( self.options.txt.clickedPeak );
@@ -8481,7 +8486,7 @@ SpectrumChartD3.prototype.updateFeatureMarkers = function( mouseDownEnergy, over
84818486
/* draw sum peak line here */
84828487
self.sumPeak = self.vis.append("line")
84838488
.attr("class", "peakLine")
8484-
.attr("stroke-width", 2);
8489+
.attr("stroke-width", self.options.featureLineWidth);
84858490
self.sumPeakText = self.vis.append("text")
84868491
.attr("class", "peakText")
84878492
.text( self.options.txt.sumPeak );

0 commit comments

Comments
 (0)