Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #5230, a horizontal and opposite axis used to have wrong alignm…
…ent for its title.
- Loading branch information
1 parent
0c2ad39
commit 45b062b
Showing
7 changed files
with
178 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
resources: | ||
- https://code.jquery.com/qunit/qunit-1.19.0.js | ||
- https://code.jquery.com/qunit/qunit-1.19.0.css | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script src="https://code.highcharts.com/highcharts.js"></script> | ||
|
||
|
||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
|
||
<div id="container" style="width: 600px; margin: 0 auto"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
QUnit.test('textAlign', function (assert) { | ||
var chart = Highcharts.chart('container', { | ||
yAxis: [{ | ||
title: { | ||
text: 'Vertical Axis' | ||
} | ||
}], | ||
xAxis: [{ | ||
title: { | ||
text: 'Horizontal Axis' | ||
} | ||
}], | ||
series: [{ | ||
data: [] | ||
}] | ||
}), | ||
getTitleTextAlign = function (axis) { | ||
var align = { start: 'left', middle: 'center', end: 'right' }; | ||
// Ideally there should the renderer should have an alignGetter. Alternative syntax axis.axisTitle.attr('align'); | ||
return align[axis.axisTitle.element.getAttribute('text-anchor')]; | ||
} | ||
horizontalAxis = chart.xAxis[0], | ||
verticalAxis = chart.yAxis[0]; | ||
|
||
// Test the horizontal axis | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'center', | ||
'horizontal Axis default textAlign:middle' | ||
); | ||
horizontalAxis.update({ title: { align: 'low' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'left', | ||
'horizontal Axis align:low has textAlign:left' | ||
); | ||
horizontalAxis.update({ title: { align: 'middle' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'center', | ||
'horizontal Axis align:middle has textAlign:center' | ||
); | ||
horizontalAxis.update({ title: { align: 'high' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'right', | ||
'horizontal Axis align:high has textAlign:right' | ||
); | ||
horizontalAxis.update({ opposite: true }); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'right', | ||
'horizontal and opposite Axis align:high has textAlign:right' | ||
); | ||
horizontalAxis.update({ title: { align: 'middle' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'center', | ||
'horizontal and opposite Axis align:middle has textAlign:center' | ||
); | ||
horizontalAxis.update({ title: { align: 'low' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(horizontalAxis), | ||
'left', | ||
'horizontal and opposite Axis align:low has textAlign:left' | ||
); | ||
|
||
// Test the vertical axis | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'center', | ||
'vertical Axis default textAlign:middle' | ||
); | ||
verticalAxis.update({ title: { align: 'low' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'left', | ||
'vertical Axis align:low has textAlign:left' | ||
); | ||
verticalAxis.update({ title: { align: 'middle' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'center', | ||
'vertical Axis align:middle has textAlign:center' | ||
); | ||
verticalAxis.update({ title: { align: 'high' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'right', | ||
'vertical Axis align:high has textAlign:right' | ||
); | ||
verticalAxis.update({ opposite: true }); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'left', | ||
'vertical opposite Axis align:high has textAlign:left' | ||
); | ||
verticalAxis.update({ title: { align: 'middle' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'center', | ||
'vertical opposite Axis align:middle has textAlign:center' | ||
); | ||
verticalAxis.update({ title: { align: 'low' }}); | ||
assert.strictEqual( | ||
getTitleTextAlign(verticalAxis), | ||
'right', | ||
'vertical opposite Axis align:low has textAlign:right' | ||
); | ||
}); |