perf: move point tooltip below x-axis label
It is much easier to read when it is in a fixed location.
For golang/go#48803.
Change-Id: I3d085284820b5582f472b965e60c7f6a46067b1a
Reviewed-on: https://go-review.googlesource.com/c/build/+/412995
Reviewed-by: Michael Knyszek <mknyszek@google.com>
diff --git a/third_party/bandchart/bandchart.js b/third_party/bandchart/bandchart.js
index bb293c5..93fb0b3 100644
--- a/third_party/bandchart/bandchart.js
+++ b/third_party/bandchart/bandchart.js
@@ -272,35 +272,13 @@
.attr("pointer-events", "none")
)
.call(g => g.append('text')
- .attr("x", (() => {
- let base = xScale(X[i]);
- if (base < marginLeft+100) {
- base += 10;
- } else if (base > width-marginRight-100) {
- base -= 10;
- }
- return base;
- })())
- .attr("y", (() => {
- let base = yScale(Y[i]);
- if (base < marginTop+100) {
- base += 30;
- } else if (base > height-marginBottom-100) {
- base -= 30;
- }
- return base;
- }))
+ // Point metadata (commit hash and date).
+ // Below the x-axis "Commits" label.
+ .attr("x", xRange[0] + (xRange[1]-xRange[0])/2)
+ .attr("y", yRange[0] + (yRange[0]-yRange[1])*0.12*2)
.attr("pointer-events", "none")
.attr("fill", "currentColor")
- .attr("text-anchor", (() => {
- let base = xScale(X[i]);
- if (base < marginLeft+100) {
- return "start";
- } else if (base > width-marginRight-100) {
- return "end";
- }
- return "middle";
- })())
+ .attr("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.text(C[i].slice(0, 7) + " ("