Skip to content

Commit fdc4c86

Browse files
digEmAllMarco Giuliano
and
Marco Giuliano
authored
Parameter subchart_axis_x_show is now working (#2806)
Co-authored-by: Marco Giuliano <marco.giuliano@tesisquare.com>
1 parent 062a185 commit fdc4c86

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

docs/reference.html.haml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
= partial :reference_menu_item, locals: { id: 'subchart.show', experimental: true }
155155
= partial :reference_menu_item, locals: { id: 'subchart.size.height', experimental: true }
156156
= partial :reference_menu_item, locals: { id: 'subchart.onbrush', experimental: true }
157+
= partial :reference_menu_item, locals: { id: 'subchart.axis.x.show', experimental: true }
157158

158159
%li Zoom
159160
= partial :reference_menu_item, locals: { id: 'zoom.enabled', experimental: true }
@@ -3009,6 +3010,25 @@
30093010
}
30103011
%hr
30113012

3013+
%section
3014+
%h3
3015+
= partial :reference_item_link, locals: { id: 'subchart.axis.x.show', experimental: true }
3016+
%p Show or hide x axis of subchart.
3017+
%h5 Default:
3018+
<code>true</code>
3019+
%h5 Format:
3020+
%div.sourcecode
3021+
%pre
3022+
%code.html.javascript
3023+
subchart: {
3024+
&nbsp;&nbsp;axis: {
3025+
&nbsp;&nbsp;&nbsp;&nbsp;x: {
3026+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;show: true
3027+
&nbsp;&nbsp;&nbsp;&nbsp;}
3028+
&nbsp;&nbsp;}
3029+
}
3030+
%hr
3031+
30123032
%section
30133033
%h3
30143034
= partial :reference_item_link, locals: { id: 'zoom.enabled', experimental: true }

src/core.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,10 @@ ChartInternal.prototype.updateSizes = function() {
421421
hasArc = $$.hasArcType(),
422422
xAxisHeight =
423423
config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'),
424+
subchartXAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x',true),
424425
subchartHeight =
425426
config.subchart_show && !hasArc
426-
? config.subchart_size_height + xAxisHeight
427+
? config.subchart_size_height + subchartXAxisHeight
427428
: 0
428429

429430
$$.currentWidth = $$.getCurrentWidth()
@@ -462,7 +463,7 @@ ChartInternal.prototype.updateSizes = function() {
462463
: {
463464
top: $$.currentHeight - subchartHeight - legendHeightForBottom,
464465
right: NaN,
465-
bottom: xAxisHeight + legendHeightForBottom,
466+
bottom: subchartXAxisHeight + legendHeightForBottom,
466467
left: $$.margin.left
467468
}
468469

src/size.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import CLASS from './class'
22
import { ChartInternal } from './core'
3-
import { isValue, ceil10 } from './util'
3+
import { isValue, ceil10, isDefined } from './util'
44

55
ChartInternal.prototype.getCurrentWidth = function() {
66
var $$ = this,
@@ -127,11 +127,11 @@ ChartInternal.prototype.getAxisWidthByAxisId = function(id, withoutRecompute) {
127127
$$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40)
128128
)
129129
}
130-
ChartInternal.prototype.getHorizontalAxisHeight = function(axisId) {
130+
ChartInternal.prototype.getHorizontalAxisHeight = function(axisId, isSubchart) {
131131
var $$ = this,
132132
config = $$.config,
133133
h = 30
134-
if (axisId === 'x' && !config.axis_x_show) {
134+
if (axisId === 'x' && !(isDefined(isSubchart) && isSubchart ? config.subchart_axis_x_show : config.axis_x_show)) {
135135
return 8
136136
}
137137
if (axisId === 'x' && config.axis_x_height) {

src/subchart.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ ChartInternal.prototype.initSubchart = function() {
120120
.attr('class', CLASS.axisX)
121121
.attr('transform', $$.getTranslate('subx'))
122122
.attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis)
123+
.style('visibility', config.subchart_axis_x_show ? 'visible' : 'hidden');
123124
}
124125
ChartInternal.prototype.initSubchartBrush = function() {
125126
var $$ = this

0 commit comments

Comments
 (0)