Skip to content

Commit 844e205

Browse files
committed
Apply line-styles to gridlines.
For some reason, all line-styling related settings on gridlines were not set. This sets them, incuding the previously-not-exported line-width, see mpld3/mplexporter#72 As usual, disclaimer this was co-developed with gpt-5.1-codex, with my deep involvement. And as usual, I'll re-generate `make javascript` and update submodule once you approve this commit.
1 parent 9a4ff42 commit 844e205

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

mplexporter

src/core/grid.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mpld3_Grid.prototype.defaultProps = {
1111
color: "gray",
1212
dasharray: "2,2",
1313
alpha: "0.5",
14+
linewidth: 1,
1415
nticks: 10,
1516
gridOn: true,
1617
tickvalues: null,
@@ -54,12 +55,15 @@ mpld3_Grid.prototype.draw = function() {
5455
.attr("transform", this.transform)
5556
.call(this.grid);
5657

58+
this.applyGridStyle();
59+
5760
// We create header-level CSS to style these elements, because
5861
// zooming/panning creates new elements with these classes.
5962
mpld3.insert_css("div#" + this.ax.fig.figid +
6063
" ." + this.cssclass + " .tick", {
6164
"stroke": this.props.color,
6265
"stroke-dasharray": this.props.dasharray,
66+
"stroke-width": this.props.linewidth,
6367
"stroke-opacity": this.props.alpha
6468
});
6569
mpld3.insert_css("div#" + this.ax.fig.figid +
@@ -84,4 +88,13 @@ mpld3_Grid.prototype.zoomed = function(transform) {
8488
// Backwards compatibility.
8589
this.elem.call(this.grid);
8690
}
91+
this.applyGridStyle();
92+
};
93+
94+
mpld3_Grid.prototype.applyGridStyle = function() {
95+
this.elem.selectAll(".tick line")
96+
.attr("stroke", this.props.color)
97+
.attr("stroke-dasharray", this.props.dasharray)
98+
.attr("stroke-width", this.props.linewidth)
99+
.attr("stroke-opacity", this.props.alpha);
87100
};

0 commit comments

Comments
 (0)