Skip to content

Commit

Permalink
fix(timeline): Fix yaxis label color in dark mode (#3698) (#3757)
Browse files Browse the repository at this point in the history
- Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme
- Update CSS styles of yaxis label to match chart title
- Update HTML rendering to support custom color overrides via inline styles

Fixes #2250

Signed-off-by: Josh Romero <[email protected]>
(cherry picked from commit 868c822)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 6754c4d commit c731e7c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'Label" " class="axisLabels" style="position:absolute;">'
+ this.opts.axisLabel + '</div>');
this.plot.getPlaceholder().append(this.elem);
if (this.opts.axisLabelColour) {
this.elem.css('color', this.opts.axisLabelColour);
}
if (this.position == 'top') {
this.elem.css('left', box.left + box.width/2 - this.labelWidth/2 +
'px');
Expand Down Expand Up @@ -261,6 +264,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'Label" style="position:absolute; ' +
this.transforms(offsets.degrees, offsets.x, offsets.y) +
'">' + this.opts.axisLabel + '</div>');
if (this.opts.axisLabelColour) {
this.elem.css('color', this.opts.axisLabelColour);
}
this.plot.getPlaceholder().append(this.elem);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
// Custom Jquery FLOT / schema selectors
// Cannot change at the moment

.chart-top-title {
.chart-top-title,
.axisLabels {
@include euiFontSizeXS;

font-weight: $euiFontWeightBold;
}

.chart-top-title {
flex: 0;
text-align: center;
font-weight: $euiFontWeightBold;
}

.chart-canvas {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default new Chainable('yaxis', {
myAxis.axisLabelFontSizePixels = 11;
myAxis.axisLabel = label;
myAxis.axisLabelColour = color;
myAxis.axisLabelUseCanvas = true;
myAxis.axisLabelUseCanvas = false;

if (tickDecimals) {
myAxis.tickDecimals = tickDecimals < 0 ? 0 : tickDecimals;
Expand Down

0 comments on commit c731e7c

Please sign in to comment.