diff --git a/docs/reference.html.haml b/docs/reference.html.haml
index ca78719eb..b63feb745 100644
--- a/docs/reference.html.haml
+++ b/docs/reference.html.haml
@@ -154,6 +154,7 @@
= partial :reference_menu_item, locals: { id: 'subchart.show', experimental: true }
= partial :reference_menu_item, locals: { id: 'subchart.size.height', experimental: true }
= partial :reference_menu_item, locals: { id: 'subchart.onbrush', experimental: true }
+ = partial :reference_menu_item, locals: { id: 'subchart.axis.x.show', experimental: true }
%li Zoom
= partial :reference_menu_item, locals: { id: 'zoom.enabled', experimental: true }
@@ -3009,6 +3010,25 @@
}
%hr
+ %section
+ %h3
+ = partial :reference_item_link, locals: { id: 'subchart.axis.x.show', experimental: true }
+ %p Show or hide x axis of subchart.
+ %h5 Default:
+ true
+ %h5 Format:
+ %div.sourcecode
+ %pre
+ %code.html.javascript
+ subchart: {
+ axis: {
+ x: {
+ show: true
+ }
+ }
+ }
+ %hr
+
%section
%h3
= partial :reference_item_link, locals: { id: 'zoom.enabled', experimental: true }
diff --git a/src/core.ts b/src/core.ts
index 5a40587bc..1cf6778f8 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -421,9 +421,10 @@ ChartInternal.prototype.updateSizes = function() {
hasArc = $$.hasArcType(),
xAxisHeight =
config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'),
+ subchartXAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x',true),
subchartHeight =
config.subchart_show && !hasArc
- ? config.subchart_size_height + xAxisHeight
+ ? config.subchart_size_height + subchartXAxisHeight
: 0
$$.currentWidth = $$.getCurrentWidth()
@@ -462,7 +463,7 @@ ChartInternal.prototype.updateSizes = function() {
: {
top: $$.currentHeight - subchartHeight - legendHeightForBottom,
right: NaN,
- bottom: xAxisHeight + legendHeightForBottom,
+ bottom: subchartXAxisHeight + legendHeightForBottom,
left: $$.margin.left
}
diff --git a/src/size.ts b/src/size.ts
index c383a2025..2a77d2ee0 100644
--- a/src/size.ts
+++ b/src/size.ts
@@ -1,6 +1,6 @@
import CLASS from './class'
import { ChartInternal } from './core'
-import { isValue, ceil10 } from './util'
+import { isValue, ceil10, isDefined } from './util'
ChartInternal.prototype.getCurrentWidth = function() {
var $$ = this,
@@ -127,11 +127,11 @@ ChartInternal.prototype.getAxisWidthByAxisId = function(id, withoutRecompute) {
$$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40)
)
}
-ChartInternal.prototype.getHorizontalAxisHeight = function(axisId) {
+ChartInternal.prototype.getHorizontalAxisHeight = function(axisId, isSubchart) {
var $$ = this,
config = $$.config,
h = 30
- if (axisId === 'x' && !config.axis_x_show) {
+ if (axisId === 'x' && !(isDefined(isSubchart) && isSubchart ? config.subchart_axis_x_show : config.axis_x_show)) {
return 8
}
if (axisId === 'x' && config.axis_x_height) {
diff --git a/src/subchart.ts b/src/subchart.ts
index f54b66def..1c593dbd3 100644
--- a/src/subchart.ts
+++ b/src/subchart.ts
@@ -120,6 +120,7 @@ ChartInternal.prototype.initSubchart = function() {
.attr('class', CLASS.axisX)
.attr('transform', $$.getTranslate('subx'))
.attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis)
+ .style('visibility', config.subchart_axis_x_show ? 'visible' : 'hidden');
}
ChartInternal.prototype.initSubchartBrush = function() {
var $$ = this