Skip to content

Commit 0e2eaa6

Browse files
authored
Adjusted height of title so that plot filled up more space (#27)
* Adjusted height of title so that plot filled up more space * Fixed title initial render in wrong location * Changed title font size from 24px to 20px
1 parent a44f1e1 commit 0e2eaa6

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

dist/topsoil.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15500,7 +15500,7 @@ class AbstractPlot {
1550015500
constructor(root, data, options, layers) {
1550115501
this.root = root;
1550215502
this._margin = {
15503-
top: 110,
15503+
top: 50,
1550415504
right: 75,
1550515505
bottom: 75,
1550615506
left: 75
@@ -15523,7 +15523,8 @@ class AbstractPlot {
1552315523
.append("text")
1552415524
.attr("class", "title-text")
1552515525
.attr("font-family", "sans-serif")
15526-
.attr("font-size", "24px");
15526+
.attr("font-size", "20px")
15527+
.style("text-anchor", "middle");
1552715528
this.leftTextBox = this.svg
1552815529
.append("text")
1552915530
.attr("class", "left textbox")
@@ -15606,24 +15607,25 @@ class AbstractPlot {
1560615607
.attr("width", this._canvasWidth)
1560715608
.attr("height", this._canvasHeight);
1560815609
const titleDimensions = this.titleLabel.node().getBoundingClientRect();
15610+
console.log(this._margin.left + "," + this._margin.top);
1560915611
this.titleLabel
1561015612
.text(this._options.title)
15611-
.attr("x", (this._canvasWidth / 2) - (titleDimensions.width / 2))
15612-
.attr("y", -(this._margin.top / 2) + (titleDimensions.height / 3));
15613+
.attr("x", (this._canvasWidth / 2))
15614+
.attr("y", -(this._margin.top / 2));
1561315615
const textBoxWidth = (width / 2) - (titleDimensions.width / 2) - 10;
1561415616
//TODO: correct positioning
1561515617
this.leftTextBox
1561615618
//.text(this.leftText())
1561715619
.attr("x", ((width - this._canvasWidth) / 2))
15618-
.attr("y", ((height - this._canvasHeight) / 2) + 10)
15620+
.attr("y", ((height - this._canvasHeight) / 2) - 18)
1561915621
.attr("fill", "red")
1562015622
.attr("width", textBoxWidth);
1562115623
//TODO: correct positioning
1562215624
this.rightTextBox
1562315625
//.text(this.rightText())
1562415626
.attr("text-anchor", "end")
1562515627
.attr("x", this._canvasWidth + ((width - this._canvasWidth) / 2))
15626-
.attr("y", ((height - this._canvasHeight) / 2) + 10)
15628+
.attr("y", ((height - this._canvasHeight) / 2) - 18)
1562715629
.attr("fill", "red")
1562815630
.attr("width", textBoxWidth);
1562915631
}

dist/topsoil.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plots/plot-abstract.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default abstract class AbstractPlot implements Plot {
1313
protected _data: DataEntry[];
1414
protected _options: Config;
1515
protected _margin = {
16-
top: 110,
16+
top: 50,
1717
right: 75,
1818
bottom: 75,
1919
left: 75
@@ -56,7 +56,8 @@ export default abstract class AbstractPlot implements Plot {
5656
.append("text")
5757
.attr("class", "title-text")
5858
.attr("font-family", "sans-serif")
59-
.attr("font-size", "24px");
59+
.attr("font-size", "20px")
60+
.style("text-anchor", "middle")
6061

6162
this.leftTextBox = this.svg
6263
.append("text")
@@ -163,18 +164,20 @@ export default abstract class AbstractPlot implements Plot {
163164

164165
const titleDimensions = (this.titleLabel.node() as SVGElement).getBoundingClientRect();
165166

167+
console.log(this._margin.left + "," + this._margin.top);
168+
166169
this.titleLabel
167170
.text(this._options.title)
168-
.attr("x", (this._canvasWidth / 2) - (titleDimensions.width / 2))
169-
.attr("y", -(this._margin.top / 2) + (titleDimensions.height / 3));
171+
.attr("x", (this._canvasWidth / 2))
172+
.attr("y", -(this._margin.top / 2));
170173

171174
const textBoxWidth = (width / 2) - (titleDimensions.width / 2) - 10;
172175

173176
//TODO: correct positioning
174177
this.leftTextBox
175178
//.text(this.leftText())
176179
.attr("x", ((width - this._canvasWidth) / 2))
177-
.attr("y", ((height - this._canvasHeight) / 2) + 10)
180+
.attr("y", ((height - this._canvasHeight) / 2) - 18)
178181
.attr("fill", "red")
179182
.attr("width", textBoxWidth);
180183

@@ -183,7 +186,7 @@ export default abstract class AbstractPlot implements Plot {
183186
//.text(this.rightText())
184187
.attr("text-anchor", "end")
185188
.attr("x", this._canvasWidth + ((width - this._canvasWidth) / 2))
186-
.attr("y", ((height - this._canvasHeight) / 2) + 10)
189+
.attr("y", ((height - this._canvasHeight) / 2) - 18)
187190
.attr("fill", "red")
188191
.attr("width", textBoxWidth);
189192
}

0 commit comments

Comments
 (0)